You've already forked golang-saas-starter-kit
mirror of
https://github.com/raseels-repos/golang-saas-starter-kit.git
synced 2025-07-05 00:58:54 +02:00
Imported github.com/ardanlabs/service as base example project
This commit is contained in:
9
example-project/vendor/github.com/leodido/go-urn/.gitignore
generated
vendored
Normal file
9
example-project/vendor/github.com/leodido/go-urn/.gitignore
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
*.exe
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
|
||||
*.test
|
||||
|
||||
*.out
|
||||
*.txt
|
15
example-project/vendor/github.com/leodido/go-urn/.travis.yml
generated
vendored
Normal file
15
example-project/vendor/github.com/leodido/go-urn/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
language: go
|
||||
|
||||
go:
|
||||
- 1.9.x
|
||||
- 1.10.x
|
||||
- tip
|
||||
|
||||
before_install:
|
||||
- go get -t -v ./...
|
||||
|
||||
script:
|
||||
- go test -race -coverprofile=coverage.txt -covermode=atomic
|
||||
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
55
example-project/vendor/github.com/leodido/go-urn/README.md
generated
vendored
Normal file
55
example-project/vendor/github.com/leodido/go-urn/README.md
generated
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
[](https://travis-ci.org/leodido/go-urn) [](https://codecov.io/gh/leodido/go-urn) [](https://godoc.org/github.com/leodido/go-urn)
|
||||
|
||||
**A parser for URNs**.
|
||||
|
||||
> As seen on [RFC 2141](https://tools.ietf.org/html/rfc2141#ref-1).
|
||||
|
||||
[API documentation](https://godoc.org/github.com/leodido/go-urn).
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
go get github.com/leodido/go-urn
|
||||
```
|
||||
|
||||
## Performances
|
||||
|
||||
This implementation results to be really fast.
|
||||
|
||||
Usually below ½ microsecond on my machine<sup>[1](#mymachine)</sup>.
|
||||
|
||||
Notice it also performs, while parsing:
|
||||
|
||||
1. fine-grained and informative erroring
|
||||
2. specific-string normalization
|
||||
|
||||
```
|
||||
ok/00/urn:a:b______________________________________/-4 20000000 265 ns/op 182 B/op 6 allocs/op
|
||||
ok/01/URN:foo:a123,456_____________________________/-4 30000000 296 ns/op 200 B/op 6 allocs/op
|
||||
ok/02/urn:foo:a123%2c456___________________________/-4 20000000 331 ns/op 208 B/op 6 allocs/op
|
||||
ok/03/urn:ietf:params:scim:schemas:core:2.0:User___/-4 20000000 430 ns/op 280 B/op 6 allocs/op
|
||||
ok/04/urn:ietf:params:scim:schemas:extension:enterp/-4 20000000 411 ns/op 312 B/op 6 allocs/op
|
||||
ok/05/urn:ietf:params:scim:schemas:extension:enterp/-4 20000000 472 ns/op 344 B/op 6 allocs/op
|
||||
ok/06/urn:burnout:nss______________________________/-4 30000000 257 ns/op 192 B/op 6 allocs/op
|
||||
ok/07/urn:abcdefghilmnopqrstuvzabcdefghilm:x_______/-4 20000000 375 ns/op 213 B/op 6 allocs/op
|
||||
ok/08/urn:urnurnurn:urn____________________________/-4 30000000 265 ns/op 197 B/op 6 allocs/op
|
||||
ok/09/urn:ciao:@!=%2c(xyz)+a,b.*@g=$_'_____________/-4 20000000 307 ns/op 248 B/op 6 allocs/op
|
||||
ok/10/URN:x:abc%1dz%2f%3az_________________________/-4 30000000 259 ns/op 212 B/op 6 allocs/op
|
||||
no/11/URN:-xxx:x___________________________________/-4 20000000 445 ns/op 320 B/op 6 allocs/op
|
||||
no/12/urn::colon:nss_______________________________/-4 20000000 461 ns/op 320 B/op 6 allocs/op
|
||||
no/13/urn:abcdefghilmnopqrstuvzabcdefghilmn:specifi/-4 10000000 660 ns/op 320 B/op 6 allocs/op
|
||||
no/14/URN:a!?:x____________________________________/-4 20000000 507 ns/op 320 B/op 6 allocs/op
|
||||
no/15/urn:urn:NSS__________________________________/-4 20000000 429 ns/op 288 B/op 6 allocs/op
|
||||
no/16/urn:white_space:NSS__________________________/-4 20000000 482 ns/op 320 B/op 6 allocs/op
|
||||
no/17/urn:concat:no_spaces_________________________/-4 20000000 539 ns/op 328 B/op 7 allocs/op
|
||||
no/18/urn:a:/______________________________________/-4 20000000 470 ns/op 320 B/op 7 allocs/op
|
||||
no/19/urn:UrN:NSS__________________________________/-4 20000000 399 ns/op 288 B/op 6 allocs/op
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
* <a name="mymachine">[1]</a>: Intel Core i7-7600U CPU @ 2.80GHz
|
||||
|
||||
---
|
||||
|
||||
[](https://github.com/igrigorik/ga-beacon)
|
1670
example-project/vendor/github.com/leodido/go-urn/machine.go
generated
vendored
Normal file
1670
example-project/vendor/github.com/leodido/go-urn/machine.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
159
example-project/vendor/github.com/leodido/go-urn/machine.go.rl
generated
vendored
Normal file
159
example-project/vendor/github.com/leodido/go-urn/machine.go.rl
generated
vendored
Normal file
@ -0,0 +1,159 @@
|
||||
package urn
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var (
|
||||
errPrefix = "expecting the prefix to be the \"urn\" string (whatever case) [col %d]"
|
||||
errIdentifier = "expecting the identifier to be string (1..31 alnum chars, also containing dashes but not at its start) [col %d]"
|
||||
errSpecificString = "expecting the specific string to be a string containing alnum, hex, or others ([()+,-.:=@;$_!*']) chars [col %d]"
|
||||
errNoUrnWithinID = "expecting the identifier to not contain the \"urn\" reserved string [col %d]"
|
||||
errHex = "expecting the specific string hex chars to be well-formed (%%alnum{2}) [col %d]"
|
||||
errParse = "parsing error [col %d]"
|
||||
)
|
||||
|
||||
%%{
|
||||
machine urn;
|
||||
|
||||
# unsigned alphabet
|
||||
alphtype uint8;
|
||||
|
||||
action mark {
|
||||
m.pb = m.p
|
||||
}
|
||||
|
||||
action tolower {
|
||||
m.tolower = append(m.tolower, m.p - m.pb)
|
||||
}
|
||||
|
||||
action set_pre {
|
||||
output.prefix = string(m.text())
|
||||
}
|
||||
|
||||
action set_nid {
|
||||
output.ID = string(m.text())
|
||||
}
|
||||
|
||||
action set_nss {
|
||||
raw := m.text()
|
||||
output.SS = string(raw)
|
||||
// Iterate upper letters lowering them
|
||||
for _, i := range m.tolower {
|
||||
raw[i] = raw[i] + 32
|
||||
}
|
||||
output.norm = string(raw)
|
||||
}
|
||||
|
||||
action err_pre {
|
||||
m.err = fmt.Errorf(errPrefix, m.p)
|
||||
fhold;
|
||||
fgoto fail;
|
||||
}
|
||||
|
||||
action err_nid {
|
||||
m.err = fmt.Errorf(errIdentifier, m.p)
|
||||
fhold;
|
||||
fgoto fail;
|
||||
}
|
||||
|
||||
action err_nss {
|
||||
m.err = fmt.Errorf(errSpecificString, m.p)
|
||||
fhold;
|
||||
fgoto fail;
|
||||
}
|
||||
|
||||
action err_urn {
|
||||
m.err = fmt.Errorf(errNoUrnWithinID, m.p)
|
||||
fhold;
|
||||
fgoto fail;
|
||||
}
|
||||
|
||||
action err_hex {
|
||||
m.err = fmt.Errorf(errHex, m.p)
|
||||
fhold;
|
||||
fgoto fail;
|
||||
}
|
||||
|
||||
action err_parse {
|
||||
m.err = fmt.Errorf(errParse, m.p)
|
||||
fhold;
|
||||
fgoto fail;
|
||||
}
|
||||
|
||||
pre = ([uU][rR][nN] @err(err_pre)) >mark %set_pre;
|
||||
|
||||
nid = (alnum >mark (alnum | '-'){0,31}) %set_nid;
|
||||
|
||||
hex = '%' (digit | lower | upper >tolower){2} $err(err_hex);
|
||||
|
||||
sss = (alnum | [()+,\-.:=@;$_!*']);
|
||||
|
||||
nss = (sss | hex)+ $err(err_nss);
|
||||
|
||||
fail := (any - [\n\r])* @err{ fgoto main; };
|
||||
|
||||
main := (pre ':' (nid - pre %err(err_urn)) $err(err_nid) ':' nss >mark %set_nss) $err(err_parse);
|
||||
|
||||
}%%
|
||||
|
||||
%% write data noerror noprefix;
|
||||
|
||||
// Machine is the interface representing the FSM
|
||||
type Machine interface {
|
||||
Error() error
|
||||
Parse(input []byte) (*URN, error)
|
||||
}
|
||||
|
||||
type machine struct {
|
||||
data []byte
|
||||
cs int
|
||||
p, pe, eof, pb int
|
||||
err error
|
||||
tolower []int
|
||||
}
|
||||
|
||||
// NewMachine creates a new FSM able to parse RFC 2141 strings.
|
||||
func NewMachine() Machine {
|
||||
m := &machine{}
|
||||
|
||||
%% access m.;
|
||||
%% variable p m.p;
|
||||
%% variable pe m.pe;
|
||||
%% variable eof m.eof;
|
||||
%% variable data m.data;
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
// Err returns the error that occurred on the last call to Parse.
|
||||
//
|
||||
// If the result is nil, then the line was parsed successfully.
|
||||
func (m *machine) Error() error {
|
||||
return m.err
|
||||
}
|
||||
|
||||
func (m *machine) text() []byte {
|
||||
return m.data[m.pb:m.p]
|
||||
}
|
||||
|
||||
// Parse parses the input byte array as a RFC 2141 string.
|
||||
func (m *machine) Parse(input []byte) (*URN, error) {
|
||||
m.data = input
|
||||
m.p = 0
|
||||
m.pb = 0
|
||||
m.pe = len(input)
|
||||
m.eof = len(input)
|
||||
m.err = nil
|
||||
m.tolower = []int{}
|
||||
output := &URN{}
|
||||
|
||||
%% write init;
|
||||
%% write exec;
|
||||
|
||||
if m.cs < first_final || m.cs == en_fail {
|
||||
return nil, m.err
|
||||
}
|
||||
|
||||
return output, nil
|
||||
}
|
17
example-project/vendor/github.com/leodido/go-urn/makefile
generated
vendored
Normal file
17
example-project/vendor/github.com/leodido/go-urn/makefile
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
SHELL := /bin/bash
|
||||
|
||||
machine.go: machine.go.rl
|
||||
ragel -Z -G2 -e -o $@ $<
|
||||
@gofmt -w -s $@
|
||||
@sed -i '/^\/\/line/d' $@
|
||||
|
||||
.PHONY: build
|
||||
build: machine.go
|
||||
|
||||
.PHONY: bench
|
||||
bench: *_test.go machine.go
|
||||
go test -bench=. -benchmem -benchtime=5s ./...
|
||||
|
||||
.PHONY: tests
|
||||
tests: *_test.go machine.go
|
||||
go test -race -timeout 10s -coverprofile=coverage.out -covermode=atomic -v ./...
|
63
example-project/vendor/github.com/leodido/go-urn/urn.go
generated
vendored
Normal file
63
example-project/vendor/github.com/leodido/go-urn/urn.go
generated
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
package urn
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// URN represents an Uniform Resource Name.
|
||||
//
|
||||
// The general form represented is:
|
||||
//
|
||||
// urn:<id>:<ss>
|
||||
//
|
||||
// Details at https://tools.ietf.org/html/rfc2141.
|
||||
type URN struct {
|
||||
prefix string // Static prefix. Equal to "urn" when empty.
|
||||
ID string // Namespace identifier
|
||||
SS string // Namespace specific string
|
||||
norm string // Normalized namespace specific string
|
||||
}
|
||||
|
||||
// Normalize turns the receiving URN into its norm version.
|
||||
//
|
||||
// Which means: lowercase prefix, lowercase namespace identifier, and immutate namespace specific string chars (except <hex> tokens which are lowercased).
|
||||
func (u *URN) Normalize() *URN {
|
||||
return &URN{
|
||||
prefix: "urn",
|
||||
ID: strings.ToLower(u.ID),
|
||||
SS: u.norm,
|
||||
}
|
||||
}
|
||||
|
||||
// Equal checks the lexical equivalence of the current URN with another one.
|
||||
func (u *URN) Equal(x *URN) bool {
|
||||
return *u.Normalize() == *x.Normalize()
|
||||
}
|
||||
|
||||
// String reassembles the URN into a valid URN string.
|
||||
//
|
||||
// This requires both ID and SS fields to be non-empty.
|
||||
// Otherwise it returns an empty string.
|
||||
//
|
||||
// Default URN prefix is "urn".
|
||||
func (u *URN) String() string {
|
||||
var res string
|
||||
if u.ID != "" && u.SS != "" {
|
||||
if u.prefix == "" {
|
||||
res += "urn"
|
||||
}
|
||||
res += u.prefix + ":" + u.ID + ":" + u.SS
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
// Parse is responsible to create an URN instance from a byte array matching the correct URN syntax.
|
||||
func Parse(u []byte) (*URN, bool) {
|
||||
urn, err := NewMachine().Parse(u)
|
||||
if err != nil {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
return urn, true
|
||||
}
|
Reference in New Issue
Block a user