├── debuggingApplications ├── log1.log ├── main_test.go └── main.go ├── inline ├── go.mod └── main.go ├── moveRefactoring ├── userpkg │ └── user.go ├── go.mod └── main.go ├── goTemplates ├── go.mod ├── templates │ ├── tpl_example.gohtml │ └── tpl.gohtml └── main.go ├── introduceType ├── go.mod └── main.go ├── userSimpleAppGo ├── go.mod └── main.go ├── extractInterface ├── go.mod └── main.go ├── extractVariable ├── go.mod └── main.go ├── renameRefactoring ├── go.mod └── main.go ├── .gitignore ├── runDebugConfigurationsForTests ├── divisionMod │ ├── go.mod │ ├── divisionMod.go │ └── divisionMod_test.go ├── main.go ├── main_integration_test.go ├── main_test.go └── main_file_test.go ├── miniDumpDebugging ├── go.mod ├── go_build_main_go └── main.go ├── README.md ├── vendoringMode ├── go.mod ├── vendor │ └── rsc.io │ │ ├── text@v0.0.0-20170915032832-14c0d48ead0c │ │ ├── codereview.cfg │ │ ├── AUTHORS │ │ ├── CONTRIBUTORS │ │ ├── encoding │ │ │ ├── testdata │ │ │ │ ├── candide-gb18030.txt │ │ │ │ ├── candide-utf-16le.txt │ │ │ │ ├── candide-utf-32be.txt │ │ │ │ ├── rashomon-euc-jp.txt │ │ │ │ ├── rashomon-shift-jis.txt │ │ │ │ ├── candide-windows-1252.txt │ │ │ │ ├── unsu-joh-eun-nal-euc-kr.txt │ │ │ │ ├── sunzi-bingfa-simplified-gbk.txt │ │ │ │ └── sunzi-bingfa-traditional-big5.txt │ │ │ ├── japanese │ │ │ │ └── all.go │ │ │ ├── simplifiedchinese │ │ │ │ └── all.go │ │ │ ├── ianaindex │ │ │ │ └── example_test.go │ │ │ └── example_test.go │ │ ├── internal │ │ │ ├── export │ │ │ │ ├── README │ │ │ │ └── idna │ │ │ │ │ ├── common_test.go │ │ │ │ │ ├── gen_common.go │ │ │ │ │ ├── trie.go │ │ │ │ │ ├── example_test.go │ │ │ │ │ └── gen_test.go │ │ │ ├── testtext │ │ │ │ ├── gc.go │ │ │ │ ├── gccgo.go │ │ │ │ ├── go1_7.go │ │ │ │ ├── flag.go │ │ │ │ ├── go1_6.go │ │ │ │ └── codesize.go │ │ │ ├── number │ │ │ │ ├── roundingmode_string.go │ │ │ │ ├── common.go │ │ │ │ └── gen_common.go │ │ │ ├── internal_test.go │ │ │ ├── gen_test.go │ │ │ ├── internal.go │ │ │ ├── gen.go │ │ │ ├── colltab │ │ │ │ ├── weighter.go │ │ │ │ ├── weighter_test.go │ │ │ │ └── iter_test.go │ │ │ ├── format │ │ │ │ └── format.go │ │ │ ├── stringset │ │ │ │ ├── set_test.go │ │ │ │ └── set.go │ │ │ ├── tag │ │ │ │ └── tag_test.go │ │ │ ├── catmsg │ │ │ │ └── varint.go │ │ │ ├── triegen │ │ │ │ ├── example_compact_test.go │ │ │ │ ├── gen_test.go │ │ │ │ └── compact.go │ │ │ ├── match_test.go │ │ │ └── match.go │ │ ├── .gitignore │ │ ├── collate │ │ │ ├── tools │ │ │ │ └── colcmp │ │ │ │ │ └── Makefile │ │ │ ├── index.go │ │ │ ├── sort_test.go │ │ │ ├── export_test.go │ │ │ ├── sort.go │ │ │ └── build │ │ │ │ └── table.go │ │ ├── secure │ │ │ ├── doc.go │ │ │ ├── precis │ │ │ │ ├── doc.go │ │ │ │ ├── transformer.go │ │ │ │ ├── class.go │ │ │ │ ├── class_test.go │ │ │ │ ├── trieval.go │ │ │ │ ├── gen_trieval.go │ │ │ │ ├── tables_test.go │ │ │ │ ├── benchmark_test.go │ │ │ │ ├── profiles.go │ │ │ │ └── nickname.go │ │ │ └── bidirule │ │ │ │ └── bench_test.go │ │ ├── language │ │ │ ├── go1_2.go │ │ │ ├── common.go │ │ │ ├── Makefile │ │ │ ├── gen_common.go │ │ │ ├── go1_1.go │ │ │ ├── display │ │ │ │ └── dict_test.go │ │ │ └── httpexample_test.go │ │ ├── .gitattributes │ │ ├── unicode │ │ │ ├── doc.go │ │ │ ├── norm │ │ │ │ ├── norm_test.go │ │ │ │ ├── example_test.go │ │ │ │ ├── trie.go │ │ │ │ ├── readwriter_test.go │ │ │ │ ├── forminfo_test.go │ │ │ │ └── example_iter_test.go │ │ │ ├── cldr │ │ │ │ ├── examples_test.go │ │ │ │ └── cldr_test.go │ │ │ ├── runenames │ │ │ │ ├── runenames_test.go │ │ │ │ └── runenames.go │ │ │ ├── rangetable │ │ │ │ ├── rangetable_test.go │ │ │ │ └── rangetable.go │ │ │ └── bidi │ │ │ │ ├── ranges_test.go │ │ │ │ ├── gen_ranges.go │ │ │ │ ├── trieval.go │ │ │ │ ├── gen_trieval.go │ │ │ │ └── tables_test.go │ │ ├── width │ │ │ ├── kind_string.go │ │ │ ├── trieval.go │ │ │ ├── gen_trieval.go │ │ │ ├── example_test.go │ │ │ └── tables_test.go │ │ ├── doc.go │ │ ├── number │ │ │ ├── examples_test.go │ │ │ └── doc.go │ │ ├── currency │ │ │ ├── example_test.go │ │ │ ├── common.go │ │ │ ├── gen_common.go │ │ │ └── format_test.go │ │ ├── cmd │ │ │ └── gotext │ │ │ │ └── doc.go │ │ ├── transform │ │ │ └── examples_test.go │ │ ├── message │ │ │ ├── catalog.go │ │ │ ├── examples_test.go │ │ │ └── catalog │ │ │ │ └── dict.go │ │ ├── cases │ │ │ ├── fold.go │ │ │ ├── example_test.go │ │ │ ├── fold_test.go │ │ │ └── icu.go │ │ ├── CONTRIBUTING.md │ │ ├── search │ │ │ └── index.go │ │ ├── PATENTS │ │ ├── feature │ │ │ └── plural │ │ │ │ ├── example_test.go │ │ │ │ ├── common.go │ │ │ │ └── gen_common.go │ │ ├── LICENSE │ │ └── runes │ │ │ └── example_test.go │ │ ├── quote@v1.5.2 │ │ ├── go.mod │ │ ├── README.md │ │ ├── buggy │ │ │ └── buggy_test.go │ │ ├── quote.go │ │ ├── quote_test.go │ │ └── LICENSE │ │ └── sampler@v1.3.0 │ │ ├── go.mod │ │ ├── hello_test.go │ │ ├── glass_test.go │ │ ├── LICENSE │ │ └── sampler.go ├── main.go └── go.sum ├── wasmExample ├── main.wasm ├── main.go ├── .idea │ ├── misc.xml │ ├── vcs.xml │ ├── modules.xml │ └── wasmExample.iml └── index.html ├── debuggingTutorial ├── go.mod ├── Dockerfile ├── main_test.go └── main.go ├── nilnessAnalyzer ├── nilNoCheck.go └── nilCheck.go ├── appEngineExample ├── app.yaml └── main.go ├── appEngineIntegration ├── app.yaml └── main.go ├── liveTemplates └── main.go ├── handlingUnusedParameters └── main.go ├── .idea ├── vcs.xml ├── .gitignore ├── modules.xml └── documentation-code-examples.iml ├── inspectionLocksPassedByValue └── main.go ├── createMethodFunctionIfNoCall └── main.go ├── changeSignature ├── demo.go ├── main.go └── demo1.go ├── сallMethodOfEmbeddedField └── main.go ├── customPostfixTemplates └── main.go ├── codeCompletionPointers └── main.go ├── extractConstantVariable └── main.go ├── changeSignatureAddMissingParameters └── main.go ├── convertToExpectedType └── main.go ├── redundantTypeConsversions └── main.go ├── fillFieldsInCodecompletion └── main.go ├── extractMethodWithReturn └── main.go ├── usingMacros └── main.go ├── testifyToolkit └── testify_test.go ├── resultsOfStringMethodInDebugger └── main.go ├── malformedStructTag └── main.go ├── debuggerProfilerLabels └── main.go ├── creatingTests └── main.go ├── profilerLabels └── main.go ├── connectToPostgreSQL └── main.go ├── pullRequestExample └── main.go └── debuggerFunctionCalls └── main.go /debuggingApplications/log1.log: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /inline/go.mod: -------------------------------------------------------------------------------- 1 | module inline 2 | 3 | go 1.21 4 | -------------------------------------------------------------------------------- /moveRefactoring/userpkg/user.go: -------------------------------------------------------------------------------- 1 | package userpkg 2 | -------------------------------------------------------------------------------- /goTemplates/go.mod: -------------------------------------------------------------------------------- 1 | module goTemplates 2 | 3 | go 1.21.4 4 | -------------------------------------------------------------------------------- /introduceType/go.mod: -------------------------------------------------------------------------------- 1 | module introduceType 2 | 3 | go 1.21 4 | -------------------------------------------------------------------------------- /userSimpleAppGo/go.mod: -------------------------------------------------------------------------------- 1 | module simpleAppGo 2 | 3 | go 1.22 4 | -------------------------------------------------------------------------------- /extractInterface/go.mod: -------------------------------------------------------------------------------- 1 | module extractInterface 2 | 3 | go 1.21 4 | -------------------------------------------------------------------------------- /extractVariable/go.mod: -------------------------------------------------------------------------------- 1 | module extractVariable 2 | 3 | go 1.21 4 | -------------------------------------------------------------------------------- /moveRefactoring/go.mod: -------------------------------------------------------------------------------- 1 | module moveRefactoring 2 | 3 | go 1.21 4 | -------------------------------------------------------------------------------- /renameRefactoring/go.mod: -------------------------------------------------------------------------------- 1 | module renameRefactoring 2 | 3 | go 1.21 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Don't track content of these folders 2 | */.idea/* 3 | workspace.xml 4 | -------------------------------------------------------------------------------- /runDebugConfigurationsForTests/divisionMod/go.mod: -------------------------------------------------------------------------------- 1 | module divisionMod 2 | 3 | go 1.12 4 | -------------------------------------------------------------------------------- /miniDumpDebugging/go.mod: -------------------------------------------------------------------------------- 1 | module documentation-code-examples/miniDumpDebugging 2 | 3 | go 1.12 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # documentation-code-examples 2 | Code examples that are used in the documentation for GoLand. 3 | -------------------------------------------------------------------------------- /vendoringMode/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/you/hello 2 | 3 | require rsc.io/quote v1.5.2 4 | 5 | go 1.12 6 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/codereview.cfg: -------------------------------------------------------------------------------- 1 | issuerepo: golang/go 2 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/quote@v1.5.2/go.mod: -------------------------------------------------------------------------------- 1 | module "rsc.io/quote" 2 | 3 | require "rsc.io/sampler" v1.3.0 4 | -------------------------------------------------------------------------------- /wasmExample/main.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apronichev/documentation-code-examples/HEAD/wasmExample/main.wasm -------------------------------------------------------------------------------- /debuggingTutorial/go.mod: -------------------------------------------------------------------------------- 1 | module attachToRemoteProcess 2 | 3 | go 1.21 4 | 5 | require github.com/gorilla/mux v1.8.1 6 | -------------------------------------------------------------------------------- /wasmExample/main.go: -------------------------------------------------------------------------------- 1 | // +build js,wasm 2 | 3 | package main 4 | 5 | func main() { 6 | println("Hello World") 7 | } 8 | -------------------------------------------------------------------------------- /miniDumpDebugging/go_build_main_go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apronichev/documentation-code-examples/HEAD/miniDumpDebugging/go_build_main_go -------------------------------------------------------------------------------- /vendoringMode/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "quote" 6 | ) 7 | 8 | func main() { 9 | fmt.Println(quote.Hello()) 10 | } -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/sampler@v1.3.0/go.mod: -------------------------------------------------------------------------------- 1 | module "rsc.io/sampler" 2 | 3 | require "golang.org/x/text" v0.0.0-20170915032832-14c0d48ead0c 4 | -------------------------------------------------------------------------------- /nilnessAnalyzer/nilNoCheck.go: -------------------------------------------------------------------------------- 1 | package nilnessAnalyzer 2 | 3 | import "os" 4 | 5 | func main() { 6 | f, err := os.Open("input.txt") 7 | f.Close() 8 | } 9 | -------------------------------------------------------------------------------- /appEngineExample/app.yaml: -------------------------------------------------------------------------------- 1 | application: app_engine_integration 2 | version: 1 3 | runtime: go 4 | api_version: go1 5 | 6 | handlers: 7 | - url: /.* 8 | script: _go_app -------------------------------------------------------------------------------- /appEngineIntegration/app.yaml: -------------------------------------------------------------------------------- 1 | application: app_engine_integration 2 | version: 1 3 | runtime: go 4 | api_version: go1 5 | 6 | handlers: 7 | - url: /.* 8 | script: _go_app -------------------------------------------------------------------------------- /liveTemplates/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | //TODO 19/09/2019 6 | 7 | func main() { 8 | var name string = "Hello Space" 9 | fmt.Printf("%v", name) 10 | } 11 | -------------------------------------------------------------------------------- /handlingUnusedParameters/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type Person struct { 4 | name string 5 | } 6 | 7 | func (p *Person) Name(capitalize bool) string { 8 | return p.name 9 | } 10 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/quote@v1.5.2/README.md: -------------------------------------------------------------------------------- 1 | This package collects pithy sayings. 2 | 3 | It's part of a demonstration of 4 | [package versioning in Go](https://research.swtch.com/vgo1). 5 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /inline/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Println(hello()) 7 | print(hello()) 8 | } 9 | 10 | func hello() string { 11 | return "Hello World!" 12 | } 13 | -------------------------------------------------------------------------------- /introduceType/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | type myType struct { 5 | Field1 string 6 | Field2 int 7 | } 8 | _ = myType{ 9 | Field1: "Hello", 10 | Field2: 42, 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /wasmExample/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Editor-based HTTP Client requests 5 | /httpRequests/ 6 | # Datasource local storage ignored files 7 | /dataSources/ 8 | /dataSources.local.xml 9 | -------------------------------------------------------------------------------- /wasmExample/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /inspectionLocksPassedByValue/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "sync" 4 | 5 | type S struct { 6 | mu sync.Mutex 7 | } 8 | 9 | func F() { 10 | r := S{} 11 | r = S{} 12 | _ = r 13 | } 14 | 15 | func main() { 16 | F() 17 | } 18 | -------------------------------------------------------------------------------- /nilnessAnalyzer/nilCheck.go: -------------------------------------------------------------------------------- 1 | package nilnessAnalyzer 2 | 3 | import ( 4 | "log" 5 | "os" 6 | ) 7 | 8 | func main() { 9 | f, err := os.Open("input.txt") 10 | if err != nil { 11 | log.Fatal(err) 12 | } 13 | f.Close() 14 | } 15 | -------------------------------------------------------------------------------- /createMethodFunctionIfNoCall/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "net/http" 4 | 5 | type Handler struct { 6 | } 7 | 8 | func main() { 9 | h := Handler{} 10 | http.HandleFunc("/", h.handle) 11 | http.ListenAndServe(":8090", nil) 12 | } 13 | -------------------------------------------------------------------------------- /changeSignature/demo.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // Call intention actions: click the error and press Alt+Enter. 4 | // Apply the suggested quick-fixes. 5 | 6 | func main() { 7 | demo(2, "hello") 8 | } 9 | 10 | func demo() { 11 | return 0 12 | } 13 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /сallMethodOfEmbeddedField/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type Base struct{} 4 | type Derived struct { 5 | Base 6 | } 7 | 8 | func (b *Base) Method() int { return 4 } 9 | 10 | var d Derived 11 | 12 | func main() { 13 | println(d.Method()) 14 | } 15 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/encoding/testdata/candide-gb18030.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apronichev/documentation-code-examples/HEAD/vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/encoding/testdata/candide-gb18030.txt -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/encoding/testdata/candide-utf-16le.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apronichev/documentation-code-examples/HEAD/vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/encoding/testdata/candide-utf-16le.txt -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/encoding/testdata/candide-utf-32be.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apronichev/documentation-code-examples/HEAD/vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/encoding/testdata/candide-utf-32be.txt -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/encoding/testdata/rashomon-euc-jp.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apronichev/documentation-code-examples/HEAD/vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/encoding/testdata/rashomon-euc-jp.txt -------------------------------------------------------------------------------- /runDebugConfigurationsForTests/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func CalculatePlusTwo(x int) (result int) { 8 | result = x + 2 9 | return result 10 | } 11 | 12 | func main() { 13 | result := CalculatePlusTwo(4) 14 | fmt.Println(result) 15 | } 16 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/encoding/testdata/rashomon-shift-jis.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apronichev/documentation-code-examples/HEAD/vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/encoding/testdata/rashomon-shift-jis.txt -------------------------------------------------------------------------------- /runDebugConfigurationsForTests/main_integration_test.go: -------------------------------------------------------------------------------- 1 | // +build integration 2 | 3 | package main_test 4 | 5 | import ( 6 | "fmt" 7 | "testing" 8 | ) 9 | 10 | func TestCalculateIntegration(t *testing.T) { 11 | fmt.Println("This is the TestCalculateIntegration test") 12 | } 13 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/encoding/testdata/candide-windows-1252.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apronichev/documentation-code-examples/HEAD/vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/encoding/testdata/candide-windows-1252.txt -------------------------------------------------------------------------------- /appEngineIntegration/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | ) 7 | 8 | func init() { 9 | http.HandleFunc("/", handle) 10 | } 11 | 12 | func handle(w http.ResponseWriter, r *http.Request) { 13 | fmt.Fprint(w, "Hello, World!") 14 | } -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/encoding/testdata/unsu-joh-eun-nal-euc-kr.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apronichev/documentation-code-examples/HEAD/vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/encoding/testdata/unsu-joh-eun-nal-euc-kr.txt -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/internal/export/README: -------------------------------------------------------------------------------- 1 | The export directory contains packages that are generated using the x/text 2 | infrastructure, but live elsewhere. 3 | At some point we can expose some of the infrastructure, but for now this 4 | is not done. 5 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/.gitignore: -------------------------------------------------------------------------------- 1 | # Add no patterns to .gitignore except for files generated by the build. 2 | last-change 3 | /DATA 4 | # This file is rather large and the tests really only need to be run 5 | # after generation. 6 | /unicode/norm/data_test.go -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/encoding/testdata/sunzi-bingfa-simplified-gbk.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apronichev/documentation-code-examples/HEAD/vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/encoding/testdata/sunzi-bingfa-simplified-gbk.txt -------------------------------------------------------------------------------- /miniDumpDebugging/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | ) 7 | 8 | func main() { 9 | http.HandleFunc("/", handler) 10 | http.ListenAndServe(":8080", nil) 11 | } 12 | 13 | func handler(w http.ResponseWriter, r *http.Request) { 14 | fmt.Fprintf(w, "Hello World!") 15 | } -------------------------------------------------------------------------------- /runDebugConfigurationsForTests/divisionMod/divisionMod.go: -------------------------------------------------------------------------------- 1 | package divisionMod 2 | 3 | import "fmt" 4 | 5 | func CalculateDivisionTwo(x int) (result int) { 6 | result = x / 2 7 | return result 8 | } 9 | 10 | func main() { 11 | result := CalculateDivisionTwo(4) 12 | fmt.Println(result) 13 | } 14 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/encoding/testdata/sunzi-bingfa-traditional-big5.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apronichev/documentation-code-examples/HEAD/vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/encoding/testdata/sunzi-bingfa-traditional-big5.txt -------------------------------------------------------------------------------- /customPostfixTemplates/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | //Add the following template to Settings/Preferences| Editor | General | Postfix Completion. 4 | //for i := len($EXPR$) - 1; i >= 0; i-- {$END$} 5 | 6 | func main() { 7 | a := [...]int{1, 2, 3, 4, 5, 6, 7} 8 | for i := len(a) - 1; i >= 0; i-- { 9 | } 10 | } 11 | § -------------------------------------------------------------------------------- /wasmExample/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /wasmExample/.idea/wasmExample.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/quote@v1.5.2/buggy/buggy_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package buggy 6 | 7 | import "testing" 8 | 9 | func Test(t *testing.T) { 10 | t.Fatal("buggy!") 11 | } 12 | -------------------------------------------------------------------------------- /codeCompletionPointers/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bytes" 5 | ) 6 | // Place the caret between brackets of b.WriteTo. Call the SmartType action. 7 | // Select '*myBPointerPointer' from the suggestion list. 8 | 9 | func main() { 10 | b := bytes.Buffer{} 11 | myBPointer := &b 12 | myBPointerPointer := &myBPointer 13 | b.WriteTo() 14 | } 15 | -------------------------------------------------------------------------------- /extractConstantVariable/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func plus(a int, b int) int { 6 | return a + b 7 | } 8 | 9 | func plusPlus(a, b, c int) int { 10 | return a + b + c 11 | } 12 | 13 | func main() { 14 | res := plus(1, 2) 15 | fmt.Println("1+2+3·=", res) 16 | 17 | res = plusPlus(1, 2, 3) 18 | fmt.Println("1+2+3·=", res) 19 | } 20 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/collate/tools/colcmp/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2012 The Go Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style 3 | # license that can be found in the LICENSE file. 4 | 5 | chars: 6 | go run ../../maketables.go -tables=chars -package=main > chars.go 7 | gofmt -w -s chars.go 8 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/secure/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // secure is a repository of text security related packages. 6 | package secure // import "golang.org/x/text/secure" 7 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/language/go1_2.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.2 6 | 7 | package language 8 | 9 | import "sort" 10 | 11 | var sortStable = sort.Stable 12 | -------------------------------------------------------------------------------- /appEngineExample/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | ) 7 | 8 | func init() { 9 | http.HandleFunc("/", handle) 10 | } 11 | 12 | func handle(w http.ResponseWriter, r *http.Request) { 13 | _, err := fmt.Fprint(w, "Hello, World!") 14 | if err != nil { 15 | w.WriteHeader(http.StatusInternalServerError) 16 | } 17 | } -------------------------------------------------------------------------------- /.idea/documentation-code-examples.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /changeSignatureAddMissingParameters/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // Click (2, "string"), press Alt + Enter, and select 'Change parameters of function 'demo' to (int, string)' 4 | // Click return 0, press Alt + Enter, and select 'Add 'int' as 1st result parameter to function 'demo' 5 | 6 | func main() { 7 | demo(2, "string") 8 | } 9 | 10 | func demo() { 11 | return 0 12 | } 13 | -------------------------------------------------------------------------------- /convertToExpectedType/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | ) 7 | 8 | func getUserAgent(w http.ResponseWriter, r *http.Request) { 9 | ua := r.UserAgent() 10 | fmt.Printf("user agent is: %s \n", ua) 11 | w.Write("user agent is " + ua) 12 | } 13 | 14 | func main() { 15 | http.HandleFunc("/", getUserAgent) 16 | http.ListenAndServe(":8080", nil) 17 | } -------------------------------------------------------------------------------- /moveRefactoring/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | // user represents a user in the system. 8 | type user struct { 9 | Name string 10 | } 11 | 12 | func main() { 13 | user := newUser("John Doe") 14 | fmt.Println(user.Name) 15 | } 16 | 17 | // newUser creates a new user instance. 18 | func newUser(name string) user { 19 | return user{Name: name} 20 | } 21 | -------------------------------------------------------------------------------- /redundantTypeConsversions/main.go: -------------------------------------------------------------------------------- 1 | package redundantTypeConsversions 2 | 3 | import "io/ioutil" 4 | 5 | // Hover the mouse pointer over []byte in []byte(getData()). 6 | // Click the []byte part in []byte(getData()), press Alt + Enter and select Delete conversion. 7 | 8 | func main() { 9 | _ = ioutil.WriteFile("./out.txt", []byte(getData()), 0644) 10 | } 11 | 12 | func getData() []byte { 13 | return []byte("data") 14 | } -------------------------------------------------------------------------------- /fillFieldsInCodecompletion/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type Person struct { 6 | name string 7 | age int 8 | address Address 9 | } 10 | 11 | type Address struct { 12 | street string 13 | } 14 | 15 | func main() { 16 | // Continue typing `Person` below, select `Person` from the completion list. 17 | // Select `Fill All Fields` from the completion list. 18 | p := P 19 | fmt.Println(p) 20 | } 21 | -------------------------------------------------------------------------------- /changeSignature/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type Person struct { 6 | ID int 7 | Name string 8 | } 9 | 10 | func (p *Person) String() { 11 | fmt.Printf("Person:\n\tID:\t%d\n\tName:t%s\n", p.ID, p.Name) 12 | } 13 | 14 | func NewPerson (name string, id int) *Person { 15 | return &Person{ID:id, Name:name} 16 | } 17 | 18 | func main() { 19 | person := NewPerson("Admin", 1) 20 | fmt.Printf("person: %v\n", person) 21 | } -------------------------------------------------------------------------------- /goTemplates/templates/tpl_example.gohtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {{- /*gotype: goTemplates.UsersPage*/ -}} 6 | {{.Title}} 7 | 8 | 9 | {{range .Users}} 10 |
{{.Name}}'s address is {{(index .Locations "Home").ZipCode}} {{(index .Locations "Home").Street}}
11 | {{else}} 12 |
No users found
13 | {{end}} 14 | 15 | 16 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/.gitattributes: -------------------------------------------------------------------------------- 1 | # Treat all files in this repo as binary, with no git magic updating 2 | # line endings. Windows users contributing to Go will need to use a 3 | # modern version of git and editors capable of LF line endings. 4 | # 5 | # We'll prevent accidental CRLF line endings from entering the repo 6 | # via the git-review gofmt checks. 7 | # 8 | # See golang.org/issue/9281 9 | 10 | * -text 11 | -------------------------------------------------------------------------------- /changeSignature/demo1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // Click the myHandler error, press Alt + Enter and select the Change signature option. 4 | // Click the "/" error, press Alt + Enter and select the Change signature option. 5 | 6 | type HandlerFunc func(in int, out []byte) 7 | 8 | func myHandler() { 9 | 10 | } 11 | 12 | func HandleFunc(path []byte, handler HandlerFunc) { 13 | _, _ = path, handler 14 | } 15 | 16 | func main() { 17 | HandleFunc("/", myHandler) 18 | } 19 | -------------------------------------------------------------------------------- /extractMethodWithReturn/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bufio" 5 | "fmt" 6 | "os" 7 | "strings" 8 | ) 9 | 10 | func main() { 11 | for { 12 | reader := bufio.NewReader(os.Stdin) 13 | fmt.Printf("Enter text: ") 14 | text, _ := reader.ReadString('\n') 15 | text = strings.TrimSpace(text) 16 | if text == "quit"{ 17 | return 18 | } else if text == "foo" { 19 | fmt.Printf("foo") 20 | } else { 21 | fmt.Printf("bar") 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/encoding/japanese/all.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package japanese 6 | 7 | import ( 8 | "golang.org/x/text/encoding" 9 | ) 10 | 11 | // All is a list of all defined encodings in this package. 12 | var All = []encoding.Encoding{EUCJP, ISO2022JP, ShiftJIS} 13 | -------------------------------------------------------------------------------- /usingMacros/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "strconv" 7 | ) 8 | 9 | func sum() { 10 | // An integer to copy: 95 11 | var sum int 12 | n, err := strconv.ParseInt(os.Args[1], 0, 0) 13 | 14 | if err != nil { 15 | fmt.Println("First input parameter must be integer") 16 | os.Exit(1) 17 | } 18 | 19 | for i := 0; i < int(n); i++ { 20 | sum += i 21 | } 22 | fmt.Print("Sum : ", sum, "\n") 23 | } 24 | 25 | func main() { 26 | sum() 27 | } 28 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/encoding/simplifiedchinese/all.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package simplifiedchinese 6 | 7 | import ( 8 | "golang.org/x/text/encoding" 9 | ) 10 | 11 | // All is a list of all defined encodings in this package. 12 | var All = []encoding.Encoding{GB18030, GBK, HZGB2312} 13 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/unicode/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // unicode holds packages with implementations of Unicode standards that are 6 | // mostly used as building blocks for other packages in golang.org/x/text, 7 | // layout engines, or are otherwise more low-level in nature. 8 | package unicode 9 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/internal/testtext/gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | package testtext 8 | 9 | import "testing" 10 | 11 | // AllocsPerRun wraps testing.AllocsPerRun. 12 | func AllocsPerRun(runs int, f func()) (avg float64) { 13 | return testing.AllocsPerRun(runs, f) 14 | } 15 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/unicode/norm/norm_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package norm_test 6 | 7 | import ( 8 | "testing" 9 | ) 10 | 11 | func TestPlaceHolder(t *testing.T) { 12 | // Does nothing, just allows the Makefile to be canonical 13 | // while waiting for the package itself to be written. 14 | } 15 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/internal/testtext/gccgo.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo 6 | 7 | package testtext 8 | 9 | // AllocsPerRun always returns 0 for gccgo until gccgo implements escape 10 | // analysis equal or better to that of gc. 11 | func AllocsPerRun(runs int, f func()) (avg float64) { return 0 } 12 | -------------------------------------------------------------------------------- /testifyToolkit/testify_test.go: -------------------------------------------------------------------------------- 1 | package testify 2 | 3 | import ( 4 | "github.com/stretchr/testify/suite" 5 | "testing" 6 | ) 7 | 8 | type MySuite struct{ suite.Suite } 9 | 10 | func TestSuite(t *testing.T) { 11 | suite.Run(t, new(MySuite)) 12 | } 13 | 14 | func (s *MySuite) TestOne() { 15 | s.T().Run("subTest", func(t *testing.T) { 16 | t.Log("Hello") 17 | }) 18 | } 19 | 20 | func (s *MySuite) TestTwo() { 21 | s.Equal("Hello\nWorld", "Hello\nWorld!") 22 | } 23 | 24 | func TestFoo(t *testing.T) { 25 | } 26 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/language/common.go: -------------------------------------------------------------------------------- 1 | // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. 2 | 3 | package language 4 | 5 | // This file contains code common to the maketables.go and the package code. 6 | 7 | // langAliasType is the type of an alias in langAliasMap. 8 | type langAliasType int8 9 | 10 | const ( 11 | langDeprecated langAliasType = iota 12 | langMacro 13 | langLegacy 14 | 15 | langAliasTypeUnknown langAliasType = -1 16 | ) 17 | -------------------------------------------------------------------------------- /vendoringMode/go.sum: -------------------------------------------------------------------------------- 1 | golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c h1:qgOY6WgZOaTkIIMiVjBQcw93ERBE4m30iBm00nkL0i8= 2 | golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 3 | rsc.io/quote v1.5.2 h1:w5fcysjrx7yqtD/aO+QwRjYZOKnaM9Uh2b40tElTs3Y= 4 | rsc.io/quote v1.5.2/go.mod h1:LzX7hefJvL54yjefDEDHNONDjII0t9xZLPXsUe+TKr0= 5 | rsc.io/sampler v1.3.0 h1:7uVkIFmeBqHfdjD+gZwtXXI+RODJ2Wc4O7MPEh/QiW4= 6 | rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= 7 | -------------------------------------------------------------------------------- /extractVariable/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | // CalculateAverage calculates the average of a list of numbers. 6 | func CalculateAverage(numbers ...float64) float64 { 7 | if len(numbers) == 0 { 8 | return 0 9 | } 10 | var total float64 11 | for _, number := range numbers { 12 | total += number 13 | } 14 | return total / float64(len(numbers)) 15 | } 16 | 17 | func main() { 18 | mySlice := []float64{10, 20, 30, 40, 50} 19 | avg := CalculateAverage(mySlice...) 20 | fmt.Printf("Average: %.2f\n", avg) 21 | } 22 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/language/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2013 The Go Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style 3 | # license that can be found in the LICENSE file. 4 | 5 | CLEANFILES+=maketables 6 | 7 | maketables: maketables.go 8 | go build $^ 9 | 10 | tables: maketables 11 | ./maketables > tables.go 12 | gofmt -w -s tables.go 13 | 14 | # Build (but do not run) maketables during testing, 15 | # just to make sure it still compiles. 16 | testshort: maketables 17 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/internal/testtext/go1_7.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.7 6 | 7 | package testtext 8 | 9 | import "testing" 10 | 11 | func Run(t *testing.T, name string, fn func(t *testing.T)) bool { 12 | return t.Run(name, fn) 13 | } 14 | 15 | func Bench(b *testing.B, name string, fn func(b *testing.B)) bool { 16 | return b.Run(name, fn) 17 | } 18 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/unicode/cldr/examples_test.go: -------------------------------------------------------------------------------- 1 | package cldr_test 2 | 3 | import ( 4 | "fmt" 5 | 6 | "golang.org/x/text/unicode/cldr" 7 | ) 8 | 9 | func ExampleSlice() { 10 | var dr *cldr.CLDR // assume this is initialized 11 | 12 | x, _ := dr.LDML("en") 13 | cs := x.Collations.Collation 14 | // remove all but the default 15 | cldr.MakeSlice(&cs).Filter(func(e cldr.Elem) bool { 16 | return e.GetCommon().Type != x.Collations.Default() 17 | }) 18 | for i, c := range cs { 19 | fmt.Println(i, c.Type) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/width/kind_string.go: -------------------------------------------------------------------------------- 1 | // Code generated by "stringer -type=Kind"; DO NOT EDIT. 2 | 3 | package width 4 | 5 | import "fmt" 6 | 7 | const _Kind_name = "NeutralEastAsianAmbiguousEastAsianWideEastAsianNarrowEastAsianFullwidthEastAsianHalfwidth" 8 | 9 | var _Kind_index = [...]uint8{0, 7, 25, 38, 53, 71, 89} 10 | 11 | func (i Kind) String() string { 12 | if i < 0 || i >= Kind(len(_Kind_index)-1) { 13 | return fmt.Sprintf("Kind(%d)", i) 14 | } 15 | return _Kind_name[_Kind_index[i]:_Kind_index[i+1]] 16 | } 17 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:generate go run gen.go 6 | 7 | // text is a repository of text-related packages related to internationalization 8 | // (i18n) and localization (l10n), such as character encodings, text 9 | // transformations, and locale-specific text handling. 10 | package text 11 | 12 | // TODO: more documentation on general concepts, such as Transformers, use 13 | // of normalization, etc. 14 | -------------------------------------------------------------------------------- /runDebugConfigurationsForTests/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "testing" 4 | 5 | func TestCalculateTable(t *testing.T) { 6 | tests := []struct { 7 | input int 8 | wantResult int 9 | }{ 10 | {2, 4}, 11 | {6, 8}, 12 | {-2, 0}, 13 | {9999, 10001}, 14 | {3, 5}, 15 | } 16 | for _, tt := range tests { 17 | if gotResult := CalculatePlusTwo(tt.input); gotResult != tt.wantResult { 18 | t.Errorf("CalculatePlusTwo(%v) = %v, want %v", tt.input, gotResult, tt.wantResult) 19 | } 20 | } 21 | } 22 | func TestCalculate(t *testing.T) { 23 | if CalculatePlusTwo(0) != 2 { 24 | t.Error("Failed") 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/language/gen_common.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | package main 8 | 9 | // This file contains code common to the maketables.go and the package code. 10 | 11 | // langAliasType is the type of an alias in langAliasMap. 12 | type langAliasType int8 13 | 14 | const ( 15 | langDeprecated langAliasType = iota 16 | langMacro 17 | langLegacy 18 | 19 | langAliasTypeUnknown langAliasType = -1 20 | ) 21 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/internal/number/roundingmode_string.go: -------------------------------------------------------------------------------- 1 | // Code generated by "stringer -type RoundingMode"; DO NOT EDIT. 2 | 3 | package number 4 | 5 | import "fmt" 6 | 7 | const _RoundingMode_name = "ToNearestEvenToNearestZeroToNearestAwayToPositiveInfToNegativeInfToZeroAwayFromZeronumModes" 8 | 9 | var _RoundingMode_index = [...]uint8{0, 13, 26, 39, 52, 65, 71, 83, 91} 10 | 11 | func (i RoundingMode) String() string { 12 | if i >= RoundingMode(len(_RoundingMode_index)-1) { 13 | return fmt.Sprintf("RoundingMode(%d)", i) 14 | } 15 | return _RoundingMode_name[_RoundingMode_index[i]:_RoundingMode_index[i+1]] 16 | } 17 | -------------------------------------------------------------------------------- /debuggingTutorial/Dockerfile: -------------------------------------------------------------------------------- 1 | # Use a more recent version of Go 2 | FROM golang:1.21-alpine AS build-env 3 | 4 | ENV CGO_ENABLED=0 5 | 6 | # Allow Go to retrieve the dependencies for the build step 7 | RUN apk add --no-cache git 8 | 9 | WORKDIR /debuggingTutorial/ 10 | COPY . . 11 | 12 | # Build the application 13 | RUN go build -o /debuggingTutorial/app . 14 | 15 | # Install Delve 16 | RUN go install github.com/go-delve/delve/cmd/dlv@latest 17 | 18 | # Final stage 19 | FROM alpine:3.18 20 | 21 | WORKDIR / 22 | COPY --from=build-env /debuggingTutorial/app / 23 | COPY --from=build-env /go/bin/dlv / 24 | 25 | EXPOSE 8080 40000 26 | 27 | CMD ["/dlv", "--listen=:40000", "--headless=true", "--api-version=2", "exec", "/app"] -------------------------------------------------------------------------------- /goTemplates/templates/tpl.gohtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{/* 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | */}} 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /runDebugConfigurationsForTests/divisionMod/divisionMod_test.go: -------------------------------------------------------------------------------- 1 | package divisionMod 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestCalculateDivisionTwoTable(t *testing.T) { 8 | tests := []struct { 9 | input int 10 | wantResult int 11 | }{ 12 | {4, 2}, 13 | {12, 6}, 14 | {-4, -2}, 15 | {19998, 9999}, 16 | {6, 3}, 17 | } 18 | for _, tt := range tests { 19 | if gotResult := CalculateDivisionTwo(tt.input); gotResult != tt.wantResult { 20 | t.Errorf("CalculateMulitplyTwo(%v) = %v, want %v", tt.input, gotResult, tt.wantResult) 21 | } 22 | } 23 | } 24 | func TestCalculateDivisionTwo(t *testing.T) { 25 | if CalculateDivisionTwo(0) != 0 { 26 | t.Error("PackageTest: Failed") 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/unicode/norm/example_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package norm_test 6 | 7 | import ( 8 | "fmt" 9 | 10 | "golang.org/x/text/unicode/norm" 11 | ) 12 | 13 | func ExampleForm_NextBoundary() { 14 | s := norm.NFD.String("Mêlée") 15 | 16 | for i := 0; i < len(s); { 17 | d := norm.NFC.NextBoundaryInString(s[i:], true) 18 | fmt.Printf("%[1]s: %+[1]q\n", s[i:i+d]) 19 | i += d 20 | } 21 | // Output: 22 | // M: "M" 23 | // ê: "e\u0302" 24 | // l: "l" 25 | // é: "e\u0301" 26 | // e: "e" 27 | } 28 | -------------------------------------------------------------------------------- /resultsOfStringMethodInDebugger/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | type User struct { 8 | name string 9 | email string 10 | company Company 11 | } 12 | 13 | type Company struct { 14 | name string 15 | } 16 | 17 | func (u User) String() string { 18 | return fmt.Sprintf("%s <%s> (%s)", u.name, u.email, u.company.name) 19 | } 20 | 21 | func main() { 22 | u := User{ 23 | name: "John Smith", 24 | email: "john.smith@example.com", 25 | company: Company{name: "ACME"}, 26 | } 27 | // Place a breakpoint on the following println function, run a debugging session. 28 | // See how the result is displayed in the Debug tool window (the Variables pane). 29 | println(u.String()) 30 | } 31 | -------------------------------------------------------------------------------- /malformedStructTag/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "log" 7 | "os" 8 | "time" 9 | ) 10 | 11 | type User struct { 12 | FirstName string `json:"name"` 13 | LastName string `json:"name"` 14 | Password string `json:"password"` 15 | IsAdmin bool `json:"isAdmin"` 16 | CreatedAt time.Time `json:"createdAt"` 17 | } 18 | 19 | func main() { 20 | u := &User{ 21 | FirstName: "John", 22 | LastName: "Smith", 23 | Password: "myPassword", 24 | IsAdmin: true, 25 | CreatedAt: time.Now(), 26 | } 27 | 28 | output, err := json.MarshalIndent(u, "", " ") 29 | if err != nil { 30 | log.Println(err) 31 | os.Exit(1) 32 | } 33 | 34 | fmt.Println(string(output)) 35 | } 36 | -------------------------------------------------------------------------------- /renameRefactoring/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | ) 7 | 8 | // findMaximumNumber returns the maximum number in a slice. If the slice is empty, it returns an error. 9 | func findMaximumNumber(numbers []int) (int, error) { 10 | if len(numbers) == 0 { 11 | return 0, errors.New("cannot find the maximum of an empty slice") 12 | } 13 | 14 | max := numbers[0] 15 | for _, num := range numbers[1:] { 16 | if num > max { 17 | max = num 18 | } 19 | } 20 | 21 | return max, nil 22 | } 23 | 24 | func main() { 25 | numbers := []int{3, 5, 7, 2, 9, 1} 26 | maxNumber, err := findMaximumNumber(numbers) 27 | if err != nil { 28 | fmt.Println("Error:", err) 29 | } else { 30 | fmt.Println("The maximum number is:", maxNumber) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /debuggerProfilerLabels/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | /* 4 | Put a breakpoint at 'println("ok")' and debug the 'main' function. Once breakpoint is reached, check out a list of goroutines 5 | in the debugger. Goroutine names include the following information: /api/profile, userId: . You can use this 6 | information to find a particular goroutine during debugging and core dump analysis. 7 | 8 | To learn more about pprof labels, see https://rakyll.org/profiler-labels/. 9 | */ 10 | import ( 11 | "context" 12 | "time" 13 | ) 14 | 15 | func main() { 16 | ctx := context.Background() 17 | for i := 0; i < 10; i++ { 18 | f(ctx) 19 | } 20 | time.Sleep(time.Second) 21 | } 22 | 23 | func f(ctx context.Context) { 24 | time.Sleep(time.Millisecond) 25 | println("ok") 26 | } 27 | -------------------------------------------------------------------------------- /runDebugConfigurationsForTests/main_file_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func CalculateMulitplyTwo(x int) (result int) { 8 | return x * 2 9 | } 10 | 11 | func TestMultiplyTable(t *testing.T) { 12 | tests := []struct { 13 | input int 14 | wantResult int 15 | }{ 16 | {2, 4}, 17 | {6, 12}, 18 | {-2, -4}, 19 | {9999, 19998}, 20 | {3, 6}, 21 | } 22 | for _, tt := range tests { 23 | if gotResult := CalculateMulitplyTwo(tt.input); gotResult != tt.wantResult { 24 | t.Errorf("CalculateMulitplyTwo(%v) = %v, want %v", tt.input, gotResult, tt.wantResult) 25 | } 26 | } 27 | } 28 | func TestMultiply(t *testing.T) { 29 | if CalculateMulitplyTwo(0) != 2 { 30 | t.Error("Multiplication by zero must return zero") 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/internal/testtext/flag.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package testtext 6 | 7 | import ( 8 | "flag" 9 | "testing" 10 | 11 | "golang.org/x/text/internal/gen" 12 | ) 13 | 14 | var long = flag.Bool("long", false, 15 | "run tests that require fetching data online") 16 | 17 | // SkipIfNotLong returns whether long tests should be performed. 18 | func SkipIfNotLong(t *testing.T) { 19 | if testing.Short() || !(gen.IsLocal() || *long) { 20 | t.Skip("skipping test to prevent downloading; to run use -long or use -local or UNICODE_DIR to specify a local source") 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/internal/testtext/go1_6.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !go1.7 6 | 7 | package testtext 8 | 9 | import "testing" 10 | 11 | func Run(t *testing.T, name string, fn func(t *testing.T)) bool { 12 | t.Logf("Running %s...", name) 13 | fn(t) 14 | return t.Failed() 15 | } 16 | 17 | // Bench runs the given benchmark function. This pre-1.7 implementation renders 18 | // the measurement useless, but allows the code to be compiled at least. 19 | func Bench(b *testing.B, name string, fn func(b *testing.B)) bool { 20 | b.Logf("Running %s...", name) 21 | fn(b) 22 | return b.Failed() 23 | } 24 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/secure/precis/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package precis contains types and functions for the preparation, 6 | // enforcement, and comparison of internationalized strings ("PRECIS") as 7 | // defined in RFC 7564. It also contains several pre-defined profiles for 8 | // passwords, nicknames, and usernames as defined in RFC 7613 and RFC 7700. 9 | // 10 | // BE ADVISED: This package is under construction and the API may change in 11 | // backwards incompatible ways and without notice. 12 | package precis // import "golang.org/x/text/secure/precis" 13 | 14 | //go:generate go run gen.go gen_trieval.go 15 | -------------------------------------------------------------------------------- /creatingTests/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "github.com/jmoiron/sqlx" 6 | _ "github.com/lib/pq" 7 | "strings" 8 | ) 9 | 10 | type User struct { 11 | ID int 12 | firstName string 13 | middleName string 14 | lastName string 15 | } 16 | 17 | const ( 18 | dsn = "postgres://guest:guest@localhost:54332/guest?sslmode=disable" 19 | getUserQuery = "SELECT first_name FROM actor WHERE actor_id = 1") 20 | 21 | func main() { 22 | db, err := sqlx.Open("postgres", dsn) 23 | if err != nil { 24 | panic(err) 25 | } 26 | err = db.Ping() 27 | if err != nil { 28 | panic(err) 29 | } 30 | 31 | firstName := []string{} 32 | err = db.Select(&firstName, getUserQuery) 33 | if err != nil { 34 | panic(err) 35 | } 36 | 37 | fmt.Printf("First name: %#v\n", strings.Join(firstName, "")) 38 | } 39 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/number/examples_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package number_test 6 | 7 | import ( 8 | "golang.org/x/text/language" 9 | "golang.org/x/text/message" 10 | "golang.org/x/text/number" 11 | ) 12 | 13 | func ExampleMaxIntegerDigits() { 14 | const year = 1999 15 | p := message.NewPrinter(language.English) 16 | p.Println("Year:", number.Decimal(year, number.MaxIntegerDigits(2))) 17 | 18 | // Output: 19 | // Year: 99 20 | } 21 | 22 | func ExampleIncrementString() { 23 | p := message.NewPrinter(language.English) 24 | 25 | p.Println(number.Decimal(1.33, number.IncrementString("0.50"))) 26 | 27 | // Output: 1.50 28 | } 29 | -------------------------------------------------------------------------------- /extractInterface/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | // UserService handles operations related to a user. 6 | type UserService struct { 7 | // fields like database connection, etc. 8 | } 9 | 10 | // CreateUser creates a new user. 11 | func (s *UserService) CreateUser(name string) { 12 | fmt.Println("User created:", name) 13 | } 14 | 15 | // GetUser retrieves a user. 16 | func (s *UserService) GetUser(id int) string { 17 | // Simulate retrieving a user 18 | return "User Name" 19 | } 20 | 21 | // UpdateUser updates an existing user. 22 | func (s *UserService) UpdateUser(id int, newName string) { 23 | fmt.Println("User updated:", id, newName) 24 | } 25 | 26 | func main() { 27 | service := UserService{} 28 | service.CreateUser("John") 29 | fmt.Println("Retrieved user:", service.GetUser(1)) 30 | service.UpdateUser(1, "Jane") 31 | } 32 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/encoding/ianaindex/example_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ianaindex_test 6 | 7 | import ( 8 | "fmt" 9 | 10 | "golang.org/x/text/encoding/charmap" 11 | "golang.org/x/text/encoding/ianaindex" 12 | ) 13 | 14 | func ExampleIndex() { 15 | fmt.Println(ianaindex.MIME.Name(charmap.ISO8859_7)) 16 | fmt.Println(ianaindex.IANA.Name(charmap.ISO8859_7)) 17 | fmt.Println(ianaindex.MIB.Name(charmap.ISO8859_7)) 18 | 19 | e, _ := ianaindex.IANA.Encoding("cp437") 20 | fmt.Println(ianaindex.IANA.Name(e)) 21 | 22 | // Output: 23 | // ISO-8859-7 24 | // ISO_8859-7:1987 25 | // ISOLatinGreek 26 | // IBM437 27 | } 28 | -------------------------------------------------------------------------------- /debuggingTutorial/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "net/http" 5 | "net/http/httptest" 6 | "testing" 7 | ) 8 | 9 | func TestIndexHandler(t *testing.T) { 10 | tests := []struct { 11 | name string 12 | r *http.Request 13 | w *httptest.ResponseRecorder 14 | expectedStatus int 15 | }{ 16 | { 17 | name: "good", 18 | r: httptest.NewRequest("GET", "/", nil), 19 | w: httptest.NewRecorder(), 20 | expectedStatus: http.StatusOK, 21 | }, 22 | } 23 | for _, test := range tests { 24 | test := test 25 | t.Run(test.name, func(t *testing.T) { 26 | indexHandler(test.w, test.r) 27 | if test.w.Code != test.expectedStatus { 28 | t.Errorf("Failed to produce expected status code %d, got %d", test.expectedStatus, test.w.Code) 29 | } 30 | }) 31 | } 32 | } -------------------------------------------------------------------------------- /debuggingApplications/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "net/http" 5 | "net/http/httptest" 6 | "testing" 7 | ) 8 | 9 | func TestIndexHandler(t *testing.T) { 10 | tests := []struct { 11 | name string 12 | r *http.Request 13 | w *httptest.ResponseRecorder 14 | expectedStatus int 15 | }{ 16 | { 17 | name: "good", 18 | r: httptest.NewRequest("GET", "/", nil), 19 | w: httptest.NewRecorder(), 20 | expectedStatus: http.StatusOK, 21 | }, 22 | } 23 | for _, test := range tests { 24 | test := test 25 | t.Run(test.name, func(t *testing.T) { 26 | indexHandler(test.w, test.r) 27 | if test.w.Code != test.expectedStatus { 28 | t.Errorf("Failed to produce expected status code %d, got %d", test.expectedStatus, test.w.Code) 29 | } 30 | }) 31 | } 32 | } -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/currency/example_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package currency_test 6 | 7 | import ( 8 | "fmt" 9 | "time" 10 | 11 | "golang.org/x/text/currency" 12 | ) 13 | 14 | func ExampleQuery() { 15 | t1799, _ := time.Parse("2006-01-02", "1799-01-01") 16 | for it := currency.Query(currency.Date(t1799)); it.Next(); { 17 | from := "" 18 | if t, ok := it.From(); ok { 19 | from = t.Format("2006-01-01") 20 | } 21 | fmt.Printf("%v is used in %v since: %v\n", it.Unit(), it.Region(), from) 22 | } 23 | // Output: 24 | // GBP is used in GB since: 1694-07-07 25 | // GIP is used in GI since: 1713-01-01 26 | // USD is used in US since: 1792-01-01 27 | } 28 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/sampler@v1.3.0/hello_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package sampler 6 | 7 | import ( 8 | "testing" 9 | 10 | "golang.org/x/text/language" 11 | ) 12 | 13 | var helloTests = []struct { 14 | prefs []language.Tag 15 | text string 16 | }{ 17 | { 18 | []language.Tag{language.Make("en-US"), language.Make("fr")}, 19 | "Hello, world.", 20 | }, 21 | { 22 | []language.Tag{language.Make("fr"), language.Make("en-US")}, 23 | "Bonjour le monde.", 24 | }, 25 | } 26 | 27 | func TestHello(t *testing.T) { 28 | for _, tt := range helloTests { 29 | text := Hello(tt.prefs...) 30 | if text != tt.text { 31 | t.Errorf("Hello(%v) = %q, want %q", tt.prefs, text, tt.text) 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /profilerLabels/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | /* 3 | Put a breakpoint at 'println("ok")' and debug the 'main' function. Once breakpoint is reached, check out a list of goroutines 4 | in the debugger. Goroutine names include the following information: /api/profile, userId: . You can use this 5 | information to find a particular goroutine during debugging and core dump analysis. 6 | To learn more about pprof labels, see https://rakyll.org/profiler-labels/. 7 | */ 8 | import ( 9 | "context" 10 | "time" 11 | ) 12 | 13 | func main() { 14 | ctx := context.Background() 15 | for i := 0; i < 10; i++ { 16 | /* labels := pprof.Labels("path", "/api/profile", "userId", strconv.Itoa(rand.Intn(100))) 17 | go pprof.Do(ctx, labels, f)*/ 18 | f(ctx) 19 | } 20 | time.Sleep(time.Second) 21 | } 22 | 23 | func f(ctx context.Context) { 24 | time.Sleep(time.Millisecond) 25 | println("ok") 26 | } -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/unicode/cldr/cldr_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package cldr 6 | 7 | import "testing" 8 | 9 | func TestParseDraft(t *testing.T) { 10 | tests := []struct { 11 | in string 12 | draft Draft 13 | err bool 14 | }{ 15 | {"unconfirmed", Unconfirmed, false}, 16 | {"provisional", Provisional, false}, 17 | {"contributed", Contributed, false}, 18 | {"approved", Approved, false}, 19 | {"", Approved, false}, 20 | {"foo", Approved, true}, 21 | } 22 | for _, tt := range tests { 23 | if d, err := ParseDraft(tt.in); d != tt.draft || (err != nil) != tt.err { 24 | t.Errorf("%q: was %v, %v; want %v, %v", tt.in, d, err != nil, tt.draft, tt.err) 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /connectToPostgreSQL/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "github.com/jmoiron/sqlx" 6 | _ "github.com/lib/pq" 7 | "strings" 8 | ) 9 | 10 | type User struct { 11 | ID int 12 | firstName string 13 | middleName string 14 | lastName string 15 | } 16 | 17 | const ( 18 | dsn = "postgres://guest:guest@localhost:54333/guest?sslmode=disable" 19 | getUserQuery = "SELECT first_name FROM actor WHERE actor_id = 2;" + 20 | "SELECT last_name FROM actor WHERE actor_id = 1;" 21 | ) 22 | 23 | func main() { 24 | db, err := sqlx.Open("postgres", dsn) 25 | if err != nil { 26 | panic(err) 27 | } 28 | err = db.Ping() 29 | if err != nil { 30 | panic(err) 31 | } 32 | 33 | var firstName []string 34 | err = db.Select(&firstName, getUserQuery) 35 | if err != nil { 36 | panic(err) 37 | } 38 | 39 | fmt.Printf("First name: %#v\n", strings.Join(firstName, "")) 40 | } 41 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/width/trieval.go: -------------------------------------------------------------------------------- 1 | // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. 2 | 3 | package width 4 | 5 | // elem is an entry of the width trie. The high byte is used to encode the type 6 | // of the rune. The low byte is used to store the index to a mapping entry in 7 | // the inverseData array. 8 | type elem uint16 9 | 10 | const ( 11 | tagNeutral elem = iota << typeShift 12 | tagAmbiguous 13 | tagWide 14 | tagNarrow 15 | tagFullwidth 16 | tagHalfwidth 17 | ) 18 | 19 | const ( 20 | numTypeBits = 3 21 | typeShift = 16 - numTypeBits 22 | 23 | // tagNeedsFold is true for all fullwidth and halfwidth runes except for 24 | // the Won sign U+20A9. 25 | tagNeedsFold = 0x1000 26 | 27 | // The Korean Won sign is halfwidth, but SHOULD NOT be mapped to a wide 28 | // variant. 29 | wonSign rune = 0x20A9 30 | ) 31 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/sampler@v1.3.0/glass_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package sampler 6 | 7 | import ( 8 | "testing" 9 | 10 | "golang.org/x/text/language" 11 | ) 12 | 13 | var glassTests = []struct { 14 | prefs []language.Tag 15 | text string 16 | }{ 17 | { 18 | []language.Tag{language.Make("en-US"), language.Make("fr")}, 19 | "I can eat glass and it doesn't hurt me.", 20 | }, 21 | { 22 | []language.Tag{language.Make("fr"), language.Make("en-US")}, 23 | "Je peux manger du verre, ça ne me fait pas mal.", 24 | }, 25 | } 26 | 27 | func TestGlass(t *testing.T) { 28 | for _, tt := range glassTests { 29 | text := Glass(tt.prefs...) 30 | if text != tt.text { 31 | t.Errorf("Glass(%v) = %q, want %q", tt.prefs, text, tt.text) 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/language/go1_1.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !go1.2 6 | 7 | package language 8 | 9 | import "sort" 10 | 11 | func sortStable(s sort.Interface) { 12 | ss := stableSort{ 13 | s: s, 14 | pos: make([]int, s.Len()), 15 | } 16 | for i := range ss.pos { 17 | ss.pos[i] = i 18 | } 19 | sort.Sort(&ss) 20 | } 21 | 22 | type stableSort struct { 23 | s sort.Interface 24 | pos []int 25 | } 26 | 27 | func (s *stableSort) Len() int { 28 | return len(s.pos) 29 | } 30 | 31 | func (s *stableSort) Less(i, j int) bool { 32 | return s.s.Less(i, j) || !s.s.Less(j, i) && s.pos[i] < s.pos[j] 33 | } 34 | 35 | func (s *stableSort) Swap(i, j int) { 36 | s.s.Swap(i, j) 37 | s.pos[i], s.pos[j] = s.pos[j], s.pos[i] 38 | } 39 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/quote@v1.5.2/quote.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package quote collects pithy sayings. 6 | package quote // import "rsc.io/quote" 7 | 8 | import "rsc.io/sampler" 9 | 10 | // Hello returns a greeting. 11 | func Hello() string { 12 | return sampler.Hello() 13 | } 14 | 15 | // Glass returns a useful phrase for world travelers. 16 | func Glass() string { 17 | // See http://www.oocities.org/nodotus/hbglass.html. 18 | return "I can eat glass and it doesn't hurt me." 19 | } 20 | 21 | // Go returns a Go proverb. 22 | func Go() string { 23 | return "Don't communicate by sharing memory, share memory by communicating." 24 | } 25 | 26 | // Opt returns an optimization truth. 27 | func Opt() string { 28 | // Wisdom from ken. 29 | return "If a program is too slow, it must have a loop." 30 | } 31 | -------------------------------------------------------------------------------- /pullRequestExample/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "log" 7 | "os" 8 | "time" 9 | ) 10 | 11 | type User struct { 12 | FirstName string `json:"firstname"` 13 | LastName string `json:"lastname"` 14 | Password string `json:"password"` 15 | IsAdmin bool `json:"isAdmin"` 16 | CreatedAt time.Time `json:"createdAt"` 17 | } 18 | 19 | func main() { 20 | u := &User{ 21 | FirstName: "John", 22 | LastName: "Smith", 23 | Password: "myPassword", 24 | IsAdmin: true, 25 | CreatedAt: time.Now(), 26 | } 27 | output := createJSON(u) 28 | printJSON(output) 29 | } 30 | 31 | //Prints JSON received from the createJSON function 32 | func printJSON(output []byte) { 33 | fmt.Println(string(output)) 34 | } 35 | 36 | //Generates JSON 37 | func createJSON(u *User) []byte { 38 | output, err := json.MarshalIndent(u, "", " ") 39 | if err != nil { 40 | log.Println(err) 41 | os.Exit(1) 42 | } 43 | return output 44 | } 45 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/internal/number/common.go: -------------------------------------------------------------------------------- 1 | // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. 2 | 3 | package number 4 | 5 | import "unicode/utf8" 6 | 7 | // A system identifies a CLDR numbering system. 8 | type system byte 9 | 10 | type systemData struct { 11 | id system 12 | digitSize byte // number of UTF-8 bytes per digit 13 | zero [utf8.UTFMax]byte // UTF-8 sequence of zero digit. 14 | } 15 | 16 | // A SymbolType identifies a symbol of a specific kind. 17 | type SymbolType int 18 | 19 | const ( 20 | SymDecimal SymbolType = iota 21 | SymGroup 22 | SymList 23 | SymPercentSign 24 | SymPlusSign 25 | SymMinusSign 26 | SymExponential 27 | SymSuperscriptingExponent 28 | SymPerMille 29 | SymInfinity 30 | SymNan 31 | SymTimeSeparator 32 | 33 | NumSymbolTypes 34 | ) 35 | 36 | type altSymData struct { 37 | compactTag uint16 38 | system system 39 | symIndex byte 40 | } 41 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/cmd/gotext/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // DO NOT EDIT THIS FILE. GENERATED BY go generate. 6 | // Edit the documentation in other files and rerun go generate to generate this one. 7 | 8 | // gotext is a tool for managing text in Go source code. 9 | // 10 | // Usage: 11 | // 12 | // gotext command [arguments] 13 | // 14 | // The commands are: 15 | // 16 | // extract extract strings to be translated from code 17 | // 18 | // Use "go help [command]" for more information about a command. 19 | // 20 | // Additional help topics: 21 | // 22 | // 23 | // Use "gotext help [topic]" for more information about that topic. 24 | // 25 | // 26 | // Extract strings to be translated from code 27 | // 28 | // Usage: 29 | // 30 | // go extract * 31 | // 32 | // 33 | // 34 | // 35 | package main 36 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/width/gen_trieval.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | package main 8 | 9 | // elem is an entry of the width trie. The high byte is used to encode the type 10 | // of the rune. The low byte is used to store the index to a mapping entry in 11 | // the inverseData array. 12 | type elem uint16 13 | 14 | const ( 15 | tagNeutral elem = iota << typeShift 16 | tagAmbiguous 17 | tagWide 18 | tagNarrow 19 | tagFullwidth 20 | tagHalfwidth 21 | ) 22 | 23 | const ( 24 | numTypeBits = 3 25 | typeShift = 16 - numTypeBits 26 | 27 | // tagNeedsFold is true for all fullwidth and halfwidth runes except for 28 | // the Won sign U+20A9. 29 | tagNeedsFold = 0x1000 30 | 31 | // The Korean Won sign is halfwidth, but SHOULD NOT be mapped to a wide 32 | // variant. 33 | wonSign rune = 0x20A9 34 | ) 35 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/transform/examples_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package transform_test 6 | 7 | import ( 8 | "fmt" 9 | "unicode" 10 | 11 | "golang.org/x/text/transform" 12 | "golang.org/x/text/unicode/norm" 13 | ) 14 | 15 | func ExampleRemoveFunc() { 16 | input := []byte(`tschüß; до свидания`) 17 | 18 | b := make([]byte, len(input)) 19 | 20 | t := transform.RemoveFunc(unicode.IsSpace) 21 | n, _, _ := t.Transform(b, input, true) 22 | fmt.Println(string(b[:n])) 23 | 24 | t = transform.RemoveFunc(func(r rune) bool { 25 | return !unicode.Is(unicode.Latin, r) 26 | }) 27 | n, _, _ = t.Transform(b, input, true) 28 | fmt.Println(string(b[:n])) 29 | 30 | n, _, _ = t.Transform(b, norm.NFD.Bytes(input), true) 31 | fmt.Println(string(b[:n])) 32 | 33 | // Output: 34 | // tschüß;досвидания 35 | // tschüß 36 | // tschuß 37 | } 38 | -------------------------------------------------------------------------------- /wasmExample/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Go wasm 6 | 7 | 8 | 9 | 10 | 11 | 12 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/internal/internal_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package internal 6 | 7 | import ( 8 | "fmt" 9 | "strings" 10 | "testing" 11 | 12 | "golang.org/x/text/language" 13 | ) 14 | 15 | func TestUnique(t *testing.T) { 16 | testCases := []struct { 17 | in, want string 18 | }{ 19 | {"", "[]"}, 20 | {"en", "[en]"}, 21 | {"en en", "[en]"}, 22 | {"en en en", "[en]"}, 23 | {"en-u-cu-eur en", "[en en-u-cu-eur]"}, 24 | {"nl en", "[en nl]"}, 25 | {"pt-Pt pt", "[pt pt-PT]"}, 26 | } 27 | for _, tc := range testCases { 28 | tags := []language.Tag{} 29 | for _, s := range strings.Split(tc.in, " ") { 30 | if s != "" { 31 | tags = append(tags, language.MustParse(s)) 32 | } 33 | } 34 | if got := fmt.Sprint(UniqueTags(tags)); got != tc.want { 35 | t.Errorf("Unique(%s) = %s; want %s", tc.in, got, tc.want) 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/message/catalog.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package message 6 | 7 | // TODO: some types in this file will need to be made public at some time. 8 | // Documentation and method names will reflect this by using the exported name. 9 | 10 | import ( 11 | "golang.org/x/text/language" 12 | "golang.org/x/text/message/catalog" 13 | ) 14 | 15 | // DefaultCatalog is used by SetString. 16 | var DefaultCatalog *catalog.Catalog = defaultCatalog 17 | 18 | var defaultCatalog = catalog.New() 19 | 20 | // SetString calls SetString on the initial default Catalog. 21 | func SetString(tag language.Tag, key string, msg string) error { 22 | return defaultCatalog.SetString(tag, key, msg) 23 | } 24 | 25 | // Set calls Set on the initial default Catalog. 26 | func Set(tag language.Tag, key string, msg ...catalog.Message) error { 27 | return defaultCatalog.Set(tag, key, msg...) 28 | } 29 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/collate/index.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package collate 6 | 7 | import "golang.org/x/text/internal/colltab" 8 | 9 | const blockSize = 64 10 | 11 | func getTable(t tableIndex) *colltab.Table { 12 | return &colltab.Table{ 13 | Index: colltab.Trie{ 14 | Index0: mainLookup[:][blockSize*t.lookupOffset:], 15 | Values0: mainValues[:][blockSize*t.valuesOffset:], 16 | Index: mainLookup[:], 17 | Values: mainValues[:], 18 | }, 19 | ExpandElem: mainExpandElem[:], 20 | ContractTries: colltab.ContractTrieSet(mainCTEntries[:]), 21 | ContractElem: mainContractElem[:], 22 | MaxContractLen: 18, 23 | VariableTop: varTop, 24 | } 25 | } 26 | 27 | // tableIndex holds information for constructing a table 28 | // for a certain locale based on the main table. 29 | type tableIndex struct { 30 | lookupOffset uint32 31 | valuesOffset uint32 32 | } 33 | -------------------------------------------------------------------------------- /debuggingApplications/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "net/http" 7 | "os" 8 | "time" 9 | 10 | "github.com/gorilla/mux" 11 | ) 12 | 13 | const ( 14 | readTimeout = 5 15 | writeTimeout = 10 16 | idleTimeout = 120 17 | ) 18 | 19 | func indexHandler(w http.ResponseWriter, r *http.Request) { 20 | w.Header().Set("Content-Type", "text/plain") 21 | returnStatus := http.StatusOK 22 | w.WriteHeader(returnStatus) 23 | message := fmt.Sprintf("Hello %s!", r.UserAgent()) 24 | w.Write([]byte(message)) 25 | } 26 | 27 | func main() { 28 | serverAddress := ":8080" 29 | l := log.New(os.Stdout, "sample-srv ", log.LstdFlags|log.Lshortfile) 30 | m := mux.NewRouter() 31 | 32 | m.HandleFunc("/", indexHandler) 33 | 34 | srv := &http.Server{ 35 | Addr: serverAddress, 36 | ReadTimeout: readTimeout * time.Second, 37 | WriteTimeout: writeTimeout * time.Second, 38 | IdleTimeout: idleTimeout * time.Second, 39 | Handler: m, 40 | } 41 | 42 | l.Println("server started") 43 | if err := srv.ListenAndServe(); err != nil { 44 | panic(err) 45 | } 46 | } -------------------------------------------------------------------------------- /debuggingTutorial/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "net/http" 7 | "os" 8 | "time" 9 | 10 | "github.com/gorilla/mux" 11 | ) 12 | 13 | const ( 14 | readTimeout = 5 15 | writeTimeout = 10 16 | idleTimeout = 120 17 | ) 18 | 19 | func indexHandler(w http.ResponseWriter, r *http.Request) { 20 | w.Header().Set("Content-Type", "text/plain") 21 | returnStatus := http.StatusOK 22 | w.WriteHeader(returnStatus) 23 | message := fmt.Sprintf("Hello %s!", r.UserAgent()) 24 | w.Write([]byte(message)) 25 | } 26 | 27 | func main() { 28 | serverAddress := ":8080" 29 | l := log.New(os.Stdout, "sample-srv ", log.LstdFlags|log.Lshortfile) 30 | m := mux.NewRouter() 31 | 32 | m.HandleFunc("/", indexHandler) 33 | 34 | srv := &http.Server{ 35 | Addr: serverAddress, 36 | ReadTimeout: readTimeout * time.Second, 37 | WriteTimeout: writeTimeout * time.Second, 38 | IdleTimeout: idleTimeout * time.Second, 39 | Handler: m, 40 | } 41 | 42 | l.Println("server started") 43 | if err := srv.ListenAndServe(); err != nil { 44 | panic(err) 45 | } 46 | } -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/internal/number/gen_common.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | package main 8 | 9 | import "unicode/utf8" 10 | 11 | // A system identifies a CLDR numbering system. 12 | type system byte 13 | 14 | type systemData struct { 15 | id system 16 | digitSize byte // number of UTF-8 bytes per digit 17 | zero [utf8.UTFMax]byte // UTF-8 sequence of zero digit. 18 | } 19 | 20 | // A SymbolType identifies a symbol of a specific kind. 21 | type SymbolType int 22 | 23 | const ( 24 | SymDecimal SymbolType = iota 25 | SymGroup 26 | SymList 27 | SymPercentSign 28 | SymPlusSign 29 | SymMinusSign 30 | SymExponential 31 | SymSuperscriptingExponent 32 | SymPerMille 33 | SymInfinity 34 | SymNan 35 | SymTimeSeparator 36 | 37 | NumSymbolTypes 38 | ) 39 | 40 | type altSymData struct { 41 | compactTag uint16 42 | system system 43 | symIndex byte 44 | } 45 | -------------------------------------------------------------------------------- /userSimpleAppGo/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | type Person struct { 8 | Name string 9 | Age int 10 | Address []string 11 | } 12 | 13 | type Location struct { 14 | Street string 15 | City string 16 | State string 17 | } 18 | 19 | func (p *Person) PrintPersonDetails() { 20 | city := p.Address[1] 21 | fmt.Println(p.formatDetails(city)) 22 | } 23 | 24 | func (p *Person) formatDetails(city string) string { 25 | return fmt.Sprintf("Name: %s, Age: %d, City: %s", p.Name, p.Age, city) 26 | } 27 | 28 | const birthdayMessage = "Happy Birthday %s! You are now %d years old.\n" 29 | 30 | func (p *Person) celebrateBirthday() { 31 | p.Age += 1 32 | newAge := p.Age 33 | name := p.Name 34 | fmt.Printf(birthdayMessage, name, newAge) 35 | } 36 | 37 | func (p *Person) IsAdult() bool { 38 | return p.Age >= 18 39 | } 40 | 41 | func main() { 42 | person := Person{Name: "John Doe", Age: 25, Address: []string{"123 Main St", "Anytown", "NY"}} 43 | 44 | if person.IsAdult() { 45 | fmt.Printf("%s is an adult.\n", person.Name) 46 | } else { 47 | fmt.Printf("%s is not an adult.\n", person.Name) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/quote@v1.5.2/quote_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package quote 6 | 7 | import ( 8 | "os" 9 | "testing" 10 | ) 11 | 12 | func init() { 13 | os.Setenv("LC_ALL", "en") 14 | } 15 | 16 | func TestHello(t *testing.T) { 17 | hello := "Hello, world." 18 | if out := Hello(); out != hello { 19 | t.Errorf("Hello() = %q, want %q", out, hello) 20 | } 21 | } 22 | 23 | func TestGlass(t *testing.T) { 24 | glass := "I can eat glass and it doesn't hurt me." 25 | if out := Glass(); out != glass { 26 | t.Errorf("Glass() = %q, want %q", out, glass) 27 | } 28 | } 29 | 30 | func TestGo(t *testing.T) { 31 | go1 := "Don't communicate by sharing memory, share memory by communicating." 32 | if out := Go(); out != go1 { 33 | t.Errorf("Go() = %q, want %q", out, go1) 34 | } 35 | } 36 | 37 | func TestOpt(t *testing.T) { 38 | opt := "If a program is too slow, it must have a loop." 39 | if out := Opt(); out != opt { 40 | t.Errorf("Opt() = %q, want %q", out, opt) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/cases/fold.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package cases 6 | 7 | import "golang.org/x/text/transform" 8 | 9 | type caseFolder struct{ transform.NopResetter } 10 | 11 | // caseFolder implements the Transformer interface for doing case folding. 12 | func (t *caseFolder) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) { 13 | c := context{dst: dst, src: src, atEOF: atEOF} 14 | for c.next() { 15 | foldFull(&c) 16 | c.checkpoint() 17 | } 18 | return c.ret() 19 | } 20 | 21 | func (t *caseFolder) Span(src []byte, atEOF bool) (n int, err error) { 22 | c := context{src: src, atEOF: atEOF} 23 | for c.next() && isFoldFull(&c) { 24 | c.checkpoint() 25 | } 26 | return c.retSpan() 27 | } 28 | 29 | func makeFold(o options) transform.SpanningTransformer { 30 | // TODO: Special case folding, through option Language, Special/Turkic, or 31 | // both. 32 | // TODO: Implement Compact options. 33 | return &caseFolder{} 34 | } 35 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/secure/precis/transformer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package precis 6 | 7 | import "golang.org/x/text/transform" 8 | 9 | // Transformer implements the transform.Transformer interface. 10 | type Transformer struct { 11 | t transform.Transformer 12 | } 13 | 14 | // Reset implements the transform.Transformer interface. 15 | func (t Transformer) Reset() { t.t.Reset() } 16 | 17 | // Transform implements the transform.Transformer interface. 18 | func (t Transformer) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) { 19 | return t.t.Transform(dst, src, atEOF) 20 | } 21 | 22 | // Bytes returns a new byte slice with the result of applying t to b. 23 | func (t Transformer) Bytes(b []byte) []byte { 24 | b, _, _ = transform.Bytes(t, b) 25 | return b 26 | } 27 | 28 | // String returns a string with the result of applying t to s. 29 | func (t Transformer) String(s string) string { 30 | s, _, _ = transform.String(t, s) 31 | return s 32 | } 33 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/internal/gen_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package internal 6 | 7 | import ( 8 | "testing" 9 | 10 | "golang.org/x/text/language" 11 | ) 12 | 13 | func TestParents(t *testing.T) { 14 | testCases := []struct { 15 | tag, parent string 16 | }{ 17 | {"af", "und"}, 18 | {"en", "und"}, 19 | {"en-001", "en"}, 20 | {"en-AU", "en-001"}, 21 | {"en-US", "en"}, 22 | {"en-US-u-va-posix", "en-US"}, 23 | {"ca-ES-valencia", "ca-ES"}, 24 | } 25 | for _, tc := range testCases { 26 | tag, ok := language.CompactIndex(language.MustParse(tc.tag)) 27 | if !ok { 28 | t.Fatalf("Could not get index of flag %s", tc.tag) 29 | } 30 | want, ok := language.CompactIndex(language.MustParse(tc.parent)) 31 | if !ok { 32 | t.Fatalf("Could not get index of parent %s of tag %s", tc.parent, tc.tag) 33 | } 34 | if got := int(Parent[tag]); got != want { 35 | t.Errorf("Parent[%s] = %d; want %d (%s)", tc.tag, got, want, tc.parent) 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/language/display/dict_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package display 6 | 7 | import ( 8 | "fmt" 9 | "testing" 10 | 11 | "golang.org/x/text/internal/testtext" 12 | ) 13 | 14 | func TestLinking(t *testing.T) { 15 | base := getSize(t, `display.Tags(language.English).Name(language.English)`) 16 | compact := getSize(t, `display.English.Languages().Name(language.English)`) 17 | 18 | if d := base - compact; d < 1.5*1024*1024 { 19 | t.Errorf("size(base)-size(compact) was %d; want > 1.5MB", base, compact) 20 | } 21 | } 22 | 23 | func getSize(t *testing.T, main string) int { 24 | size, err := testtext.CodeSize(fmt.Sprintf(body, main)) 25 | if err != nil { 26 | t.Skipf("skipping link size test; binary size could not be determined: %v", err) 27 | } 28 | return size 29 | } 30 | 31 | const body = `package main 32 | import ( 33 | "golang.org/x/text/language" 34 | "golang.org/x/text/language/display" 35 | ) 36 | func main() { 37 | %s 38 | } 39 | ` 40 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/unicode/runenames/runenames_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package runenames 6 | 7 | import ( 8 | "strings" 9 | "testing" 10 | "unicode" 11 | 12 | "golang.org/x/text/internal/gen" 13 | "golang.org/x/text/internal/testtext" 14 | "golang.org/x/text/internal/ucd" 15 | ) 16 | 17 | func TestName(t *testing.T) { 18 | testtext.SkipIfNotLong(t) 19 | 20 | wants := make([]string, 1+unicode.MaxRune) 21 | ucd.Parse(gen.OpenUCDFile("UnicodeData.txt"), func(p *ucd.Parser) { 22 | r, s := p.Rune(0), p.String(ucd.Name) 23 | if s == "" { 24 | return 25 | } 26 | if s[0] == '<' { 27 | const first = ", First>" 28 | if i := strings.Index(s, first); i >= 0 { 29 | s = s[:i] + ">" 30 | } 31 | } 32 | wants[r] = s 33 | }) 34 | 35 | nErrors := 0 36 | for r, want := range wants { 37 | got := Name(rune(r)) 38 | if got != want { 39 | t.Errorf("r=%#08x: got %q, want %q", r, got, want) 40 | nErrors++ 41 | if nErrors == 100 { 42 | t.Fatal("too many errors") 43 | } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Go 2 | 3 | Go is an open source project. 4 | 5 | It is the work of hundreds of contributors. We appreciate your help! 6 | 7 | 8 | ## Filing issues 9 | 10 | When [filing an issue](https://golang.org/issue/new), make sure to answer these five questions: 11 | 12 | 1. What version of Go are you using (`go version`)? 13 | 2. What operating system and processor architecture are you using? 14 | 3. What did you do? 15 | 4. What did you expect to see? 16 | 5. What did you see instead? 17 | 18 | General questions should go to the [golang-nuts mailing list](https://groups.google.com/group/golang-nuts) instead of the issue tracker. 19 | The gophers there will answer or ask you to file an issue if you've tripped over a bug. 20 | 21 | ## Contributing code 22 | 23 | Please read the [Contribution Guidelines](https://golang.org/doc/contribute.html) 24 | before sending patches. 25 | 26 | **We do not accept GitHub pull requests** 27 | (we use [Gerrit](https://code.google.com/p/gerrit/) instead for code review). 28 | 29 | Unless otherwise noted, the Go source files are distributed under 30 | the BSD-style license found in the LICENSE file. 31 | 32 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/search/index.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Note: this file is identical to the file text/collate/index.go. Both files 6 | // will be removed when the new colltab package is finished and in use. 7 | 8 | package search 9 | 10 | import "golang.org/x/text/internal/colltab" 11 | 12 | const blockSize = 64 13 | 14 | func getTable(t tableIndex) *colltab.Table { 15 | return &colltab.Table{ 16 | Index: colltab.Trie{ 17 | Index0: mainLookup[:][blockSize*t.lookupOffset:], 18 | Values0: mainValues[:][blockSize*t.valuesOffset:], 19 | Index: mainLookup[:], 20 | Values: mainValues[:], 21 | }, 22 | ExpandElem: mainExpandElem[:], 23 | ContractTries: colltab.ContractTrieSet(mainCTEntries[:]), 24 | ContractElem: mainContractElem[:], 25 | MaxContractLen: 18, 26 | VariableTop: varTop, 27 | } 28 | } 29 | 30 | // tableIndex holds information for constructing a table 31 | // for a certain locale based on the main table. 32 | type tableIndex struct { 33 | lookupOffset uint32 34 | valuesOffset uint32 35 | } 36 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/cases/example_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package cases_test 6 | 7 | import ( 8 | "fmt" 9 | 10 | "golang.org/x/text/cases" 11 | "golang.org/x/text/language" 12 | ) 13 | 14 | func Example() { 15 | src := []string{ 16 | "hello world!", 17 | "i with dot", 18 | "'n ijsberg", 19 | "here comes O'Brian", 20 | } 21 | for _, c := range []cases.Caser{ 22 | cases.Lower(language.Und), 23 | cases.Upper(language.Turkish), 24 | cases.Title(language.Dutch), 25 | cases.Title(language.Und, cases.NoLower), 26 | } { 27 | fmt.Println() 28 | for _, s := range src { 29 | fmt.Println(c.String(s)) 30 | } 31 | } 32 | 33 | // Output: 34 | // hello world! 35 | // i with dot 36 | // 'n ijsberg 37 | // here comes o'brian 38 | // 39 | // HELLO WORLD! 40 | // İ WİTH DOT 41 | // 'N İJSBERG 42 | // HERE COMES O'BRİAN 43 | // 44 | // Hello World! 45 | // I With Dot 46 | // 'n IJsberg 47 | // Here Comes O'brian 48 | // 49 | // Hello World! 50 | // I With Dot 51 | // 'N Ijsberg 52 | // Here Comes O'Brian 53 | } 54 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/collate/sort_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package collate_test 6 | 7 | import ( 8 | "fmt" 9 | "testing" 10 | 11 | "golang.org/x/text/collate" 12 | "golang.org/x/text/language" 13 | ) 14 | 15 | func ExampleCollator_Strings() { 16 | c := collate.New(language.Und) 17 | strings := []string{ 18 | "ad", 19 | "ab", 20 | "äb", 21 | "ac", 22 | } 23 | c.SortStrings(strings) 24 | fmt.Println(strings) 25 | // Output: [ab äb ac ad] 26 | } 27 | 28 | type sorter []string 29 | 30 | func (s sorter) Len() int { 31 | return len(s) 32 | } 33 | 34 | func (s sorter) Swap(i, j int) { 35 | s[j], s[i] = s[i], s[j] 36 | } 37 | 38 | func (s sorter) Bytes(i int) []byte { 39 | return []byte(s[i]) 40 | } 41 | 42 | func TestSort(t *testing.T) { 43 | c := collate.New(language.English) 44 | strings := []string{ 45 | "bcd", 46 | "abc", 47 | "ddd", 48 | } 49 | c.Sort(sorter(strings)) 50 | res := fmt.Sprint(strings) 51 | want := "[abc bcd ddd]" 52 | if res != want { 53 | t.Errorf("found %s; want %s", res, want) 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/message/examples_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package message_test 6 | 7 | import ( 8 | "net/http" 9 | 10 | "golang.org/x/text/language" 11 | "golang.org/x/text/message" 12 | ) 13 | 14 | func Example_http() { 15 | // languages supported by this service: 16 | matcher := language.NewMatcher(message.DefaultCatalog.Languages()) 17 | 18 | http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { 19 | lang, _ := r.Cookie("lang") 20 | accept := r.Header.Get("Accept-Language") 21 | fallback := "en" 22 | tag, _ := language.MatchStrings(matcher, lang.String(), accept, fallback) 23 | 24 | p := message.NewPrinter(tag) 25 | 26 | p.Fprintln(w, "User language is", tag) 27 | }) 28 | } 29 | 30 | func ExamplePrinter_numbers() { 31 | for _, lang := range []string{"en", "de", "de-CH", "fr", "bn"} { 32 | p := message.NewPrinter(language.Make(lang)) 33 | p.Printf("%-6s %g\n", lang, 123456.78) 34 | } 35 | 36 | // Output: 37 | // en 123,456.78 38 | // de 123.456,78 39 | // de-CH 123’456.78 40 | // fr 123 456,78 41 | // bn ১,২৩,৪৫৬.৭৮ 42 | } 43 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/number/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package number formats numbers according to the customs of different locales. 6 | // 7 | // The number formats of this package allow for greater formatting flexibility 8 | // than passing values to message.Printf calls as is. It currently supports the 9 | // builtin Go types and anything that implements the Convert interface 10 | // (currently internal). 11 | // 12 | // p := message.NewPrinter(language.English) 13 | // 14 | // p.Printf("%v bottles of beer on the wall.", number.Decimal(1234)) 15 | // // Prints: 1,234 bottles of beer on the wall. 16 | // 17 | // p.Printf("%v of gophers lose too much fur", number.Percent(0.12)) 18 | // // Prints: 12% of gophers lose too much fur. 19 | // 20 | // p := message.NewPrinter(language.Dutch) 21 | // 22 | // p.Printf("There are %v bikes per household.", number.Decimal(1.2)) 23 | // // Prints: Er zijn 1,2 fietsen per huishouden. 24 | // 25 | // 26 | // The width and scale specified in the formatting directives override the 27 | // configuration of the formatter. 28 | package number 29 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/unicode/rangetable/rangetable_test.go: -------------------------------------------------------------------------------- 1 | package rangetable 2 | 3 | import ( 4 | "reflect" 5 | "testing" 6 | "unicode" 7 | ) 8 | 9 | var ( 10 | empty = &unicode.RangeTable{} 11 | many = &unicode.RangeTable{ 12 | R16: []unicode.Range16{{0, 0xffff, 5}}, 13 | R32: []unicode.Range32{{0x10004, 0x10009, 5}}, 14 | LatinOffset: 0, 15 | } 16 | ) 17 | 18 | func TestVisit(t *testing.T) { 19 | Visit(empty, func(got rune) { 20 | t.Error("call from empty RangeTable") 21 | }) 22 | 23 | var want rune 24 | Visit(many, func(got rune) { 25 | if got != want { 26 | t.Errorf("got %U; want %U", got, want) 27 | } 28 | want += 5 29 | }) 30 | if want -= 5; want != 0x10009 { 31 | t.Errorf("last run was %U; want U+10009", want) 32 | } 33 | } 34 | 35 | func TestNew(t *testing.T) { 36 | for i, rt := range []*unicode.RangeTable{ 37 | empty, 38 | unicode.Co, 39 | unicode.Letter, 40 | unicode.ASCII_Hex_Digit, 41 | many, 42 | maxRuneTable, 43 | } { 44 | var got, want []rune 45 | Visit(rt, func(r rune) { 46 | want = append(want, r) 47 | }) 48 | Visit(New(want...), func(r rune) { 49 | got = append(got, r) 50 | }) 51 | if !reflect.DeepEqual(got, want) { 52 | t.Errorf("%d:\ngot %v;\nwant %v", i, got, want) 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/secure/precis/class.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package precis 6 | 7 | import ( 8 | "unicode/utf8" 9 | ) 10 | 11 | // TODO: Add contextual character rules from Appendix A of RFC5892. 12 | 13 | // A class is a set of characters that match certain derived properties. The 14 | // PRECIS framework defines two classes: The Freeform class and the Identifier 15 | // class. The freeform class should be used for profiles where expressiveness is 16 | // prioritized over safety such as nicknames or passwords. The identifier class 17 | // should be used for profiles where safety is the first priority such as 18 | // addressable network labels and usernames. 19 | type class struct { 20 | validFrom property 21 | } 22 | 23 | // Contains satisfies the runes.Set interface and returns whether the given rune 24 | // is a member of the class. 25 | func (c class) Contains(r rune) bool { 26 | b := make([]byte, 4) 27 | n := utf8.EncodeRune(b, r) 28 | 29 | trieval, _ := dpTrie.lookup(b[:n]) 30 | return c.validFrom <= property(trieval) 31 | } 32 | 33 | var ( 34 | identifier = &class{validFrom: pValid} 35 | freeform = &class{validFrom: idDisOrFreePVal} 36 | ) 37 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/internal/internal.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:generate go run gen.go 6 | 7 | // Package internal contains non-exported functionality that are used by 8 | // packages in the text repository. 9 | package internal // import "golang.org/x/text/internal" 10 | 11 | import ( 12 | "sort" 13 | 14 | "golang.org/x/text/language" 15 | ) 16 | 17 | // SortTags sorts tags in place. 18 | func SortTags(tags []language.Tag) { 19 | sort.Sort(sorter(tags)) 20 | } 21 | 22 | type sorter []language.Tag 23 | 24 | func (s sorter) Len() int { 25 | return len(s) 26 | } 27 | 28 | func (s sorter) Swap(i, j int) { 29 | s[i], s[j] = s[j], s[i] 30 | } 31 | 32 | func (s sorter) Less(i, j int) bool { 33 | return s[i].String() < s[j].String() 34 | } 35 | 36 | // UniqueTags sorts and filters duplicate tags in place and returns a slice with 37 | // only unique tags. 38 | func UniqueTags(tags []language.Tag) []language.Tag { 39 | if len(tags) <= 1 { 40 | return tags 41 | } 42 | SortTags(tags) 43 | k := 0 44 | for i := 1; i < len(tags); i++ { 45 | if tags[k].String() < tags[i].String() { 46 | k++ 47 | tags[k] = tags[i] 48 | } 49 | } 50 | return tags[:k+1] 51 | } 52 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/collate/export_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package collate 6 | 7 | // Export for testing. 8 | // TODO: no longer necessary. Remove at some point. 9 | 10 | import ( 11 | "fmt" 12 | 13 | "golang.org/x/text/internal/colltab" 14 | ) 15 | 16 | const ( 17 | defaultSecondary = 0x20 18 | defaultTertiary = 0x2 19 | ) 20 | 21 | type Weights struct { 22 | Primary, Secondary, Tertiary, Quaternary int 23 | } 24 | 25 | func W(ce ...int) Weights { 26 | w := Weights{ce[0], defaultSecondary, defaultTertiary, 0} 27 | if len(ce) > 1 { 28 | w.Secondary = ce[1] 29 | } 30 | if len(ce) > 2 { 31 | w.Tertiary = ce[2] 32 | } 33 | if len(ce) > 3 { 34 | w.Quaternary = ce[3] 35 | } 36 | return w 37 | } 38 | func (w Weights) String() string { 39 | return fmt.Sprintf("[%X.%X.%X.%X]", w.Primary, w.Secondary, w.Tertiary, w.Quaternary) 40 | } 41 | 42 | func convertFromWeights(ws []Weights) []colltab.Elem { 43 | out := make([]colltab.Elem, len(ws)) 44 | for i, w := range ws { 45 | out[i], _ = colltab.MakeElem(w.Primary, w.Secondary, w.Tertiary, 0) 46 | if out[i] == colltab.Ignore && w.Quaternary > 0 { 47 | out[i] = colltab.MakeQuaternary(w.Quaternary) 48 | } 49 | } 50 | return out 51 | } 52 | -------------------------------------------------------------------------------- /goTemplates/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | "net/http" 6 | "os" 7 | "text/template" 8 | ) 9 | 10 | type Location struct { 11 | Street string 12 | ZipCode string 13 | } 14 | 15 | type User struct { 16 | Name string 17 | Locations map[string]Location 18 | } 19 | 20 | type UsersPage struct { 21 | Title string 22 | Users []User 23 | } 24 | 25 | func main() { 26 | message, err := os.ReadFile("templates/tpl_example.gohtml") 27 | if err != nil { 28 | panic(err) 29 | } 30 | 31 | tmpl, err := template.New("UsersPage").Parse(string(message)) 32 | if err != nil { 33 | panic(err) 34 | } 35 | 36 | // Define the handler function 37 | http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { 38 | // Example users data 39 | p := UsersPage{ 40 | Title: "Users location", 41 | Users: []User{ 42 | { 43 | Name: "John", 44 | Locations: map[string]Location{ 45 | "Home": { 46 | Street: "Main Street", 47 | ZipCode: "20192", 48 | }, 49 | }, 50 | }, 51 | }, 52 | } 53 | 54 | // Execute the template with users data 55 | err := tmpl.Execute(w, p) 56 | if err != nil { 57 | http.Error(w, err.Error(), http.StatusInternalServerError) 58 | return 59 | } 60 | }) 61 | 62 | // Start the server 63 | log.Println("Starting server on http://localhost:8080") 64 | log.Fatal(http.ListenAndServe(":8080", nil)) 65 | } 66 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/internal/export/idna/common_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. 2 | 3 | package idna 4 | 5 | // This file contains code that is common between the generation code and the 6 | // package's test code. 7 | 8 | import ( 9 | "log" 10 | 11 | "golang.org/x/text/internal/ucd" 12 | ) 13 | 14 | func catFromEntry(p *ucd.Parser) (cat category) { 15 | r := p.Rune(0) 16 | switch s := p.String(1); s { 17 | case "valid": 18 | cat = valid 19 | case "disallowed": 20 | cat = disallowed 21 | case "disallowed_STD3_valid": 22 | cat = disallowedSTD3Valid 23 | case "disallowed_STD3_mapped": 24 | cat = disallowedSTD3Mapped 25 | case "mapped": 26 | cat = mapped 27 | case "deviation": 28 | cat = deviation 29 | case "ignored": 30 | cat = ignored 31 | default: 32 | log.Fatalf("%U: Unknown category %q", r, s) 33 | } 34 | if s := p.String(3); s != "" { 35 | if cat != valid { 36 | log.Fatalf(`%U: %s defined for %q; want "valid"`, r, s, p.String(1)) 37 | } 38 | switch s { 39 | case "NV8": 40 | cat = validNV8 41 | case "XV8": 42 | cat = validXV8 43 | default: 44 | log.Fatalf("%U: Unexpected exception %q", r, s) 45 | } 46 | } 47 | return cat 48 | } 49 | 50 | var joinType = map[string]info{ 51 | "L": joiningL, 52 | "D": joiningD, 53 | "T": joiningT, 54 | "R": joiningR, 55 | } 56 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/internal/gen.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | package main 8 | 9 | import ( 10 | "log" 11 | 12 | "golang.org/x/text/internal/gen" 13 | "golang.org/x/text/language" 14 | "golang.org/x/text/unicode/cldr" 15 | ) 16 | 17 | func main() { 18 | r := gen.OpenCLDRCoreZip() 19 | defer r.Close() 20 | 21 | d := &cldr.Decoder{} 22 | data, err := d.DecodeZip(r) 23 | if err != nil { 24 | log.Fatalf("DecodeZip: %v", err) 25 | } 26 | 27 | w := gen.NewCodeWriter() 28 | defer w.WriteGoFile("tables.go", "internal") 29 | 30 | // Create parents table. 31 | parents := make([]uint16, language.NumCompactTags) 32 | for _, loc := range data.Locales() { 33 | tag := language.MustParse(loc) 34 | index, ok := language.CompactIndex(tag) 35 | if !ok { 36 | continue 37 | } 38 | parentIndex := 0 // und 39 | for p := tag.Parent(); p != language.Und; p = p.Parent() { 40 | if x, ok := language.CompactIndex(p); ok { 41 | parentIndex = x 42 | break 43 | } 44 | } 45 | parents[index] = uint16(parentIndex) 46 | } 47 | 48 | w.WriteComment(` 49 | Parent maps a compact index of a tag to the compact index of the parent of 50 | this tag.`) 51 | w.WriteVar("Parent", parents) 52 | } 53 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/internal/colltab/weighter.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package colltab // import "golang.org/x/text/internal/colltab" 6 | 7 | // A Weighter can be used as a source for Collator and Searcher. 8 | type Weighter interface { 9 | // Start finds the start of the segment that includes position p. 10 | Start(p int, b []byte) int 11 | 12 | // StartString finds the start of the segment that includes position p. 13 | StartString(p int, s string) int 14 | 15 | // AppendNext appends Elems to buf corresponding to the longest match 16 | // of a single character or contraction from the start of s. 17 | // It returns the new buf and the number of bytes consumed. 18 | AppendNext(buf []Elem, s []byte) (ce []Elem, n int) 19 | 20 | // AppendNextString appends Elems to buf corresponding to the longest match 21 | // of a single character or contraction from the start of s. 22 | // It returns the new buf and the number of bytes consumed. 23 | AppendNextString(buf []Elem, s string) (ce []Elem, n int) 24 | 25 | // Domain returns a slice of all single characters and contractions for which 26 | // collation elements are defined in this table. 27 | Domain() []string 28 | 29 | // Top returns the highest variable primary value. 30 | Top() uint32 31 | } 32 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/feature/plural/example_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package plural_test 6 | 7 | import ( 8 | "golang.org/x/text/feature/plural" 9 | "golang.org/x/text/language" 10 | "golang.org/x/text/message" 11 | ) 12 | 13 | func ExampleSelect() { 14 | // Manually set some translations. This is typically done programmatically. 15 | message.Set(language.English, "%d files remaining", 16 | plural.Selectf(1, "%d", 17 | "=0", "done!", 18 | plural.One, "one file remaining", 19 | plural.Other, "%[1]d files remaining", 20 | )) 21 | message.Set(language.Dutch, "%d files remaining", 22 | plural.Selectf(1, "%d", 23 | "=0", "klaar!", 24 | // One can also use a string instead of a Kind 25 | "one", "nog één bestand te gaan", 26 | "other", "nog %[1]d bestanden te gaan", 27 | )) 28 | 29 | p := message.NewPrinter(language.English) 30 | p.Printf("%d files remaining", 5) 31 | p.Println() 32 | p.Printf("%d files remaining", 1) 33 | p.Println() 34 | 35 | p = message.NewPrinter(language.Dutch) 36 | p.Printf("%d files remaining", 1) 37 | p.Println() 38 | p.Printf("%d files remaining", 0) 39 | p.Println() 40 | 41 | // Output: 42 | // 5 files remaining 43 | // one file remaining 44 | // nog één bestand te gaan 45 | // klaar! 46 | } 47 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/internal/format/format.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package format contains types for defining language-specific formatting of 6 | // values. 7 | // 8 | // This package is internal now, but will eventually be exposed after the API 9 | // settles. 10 | package format // import "golang.org/x/text/internal/format" 11 | 12 | import ( 13 | "fmt" 14 | 15 | "golang.org/x/text/language" 16 | ) 17 | 18 | // State represents the printer state passed to custom formatters. It provides 19 | // access to the fmt.State interface and the sentence and language-related 20 | // context. 21 | type State interface { 22 | fmt.State 23 | 24 | // Language reports the requested language in which to render a message. 25 | Language() language.Tag 26 | 27 | // TODO: consider this and removing rune from the Format method in the 28 | // Formatter interface. 29 | // 30 | // Verb returns the format variant to render, analogous to the types used 31 | // in fmt. Use 'v' for the default or only variant. 32 | // Verb() rune 33 | 34 | // TODO: more info: 35 | // - sentence context such as linguistic features passed by the translator. 36 | } 37 | 38 | // Formatter is analogous to fmt.Formatter. 39 | type Formatter interface { 40 | Format(state State, verb rune) 41 | } 42 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/secure/bidirule/bench_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package bidirule 6 | 7 | import ( 8 | "testing" 9 | 10 | "golang.org/x/text/internal/testtext" 11 | ) 12 | 13 | var benchData = []struct{ name, data string }{ 14 | {"ascii", "Scheveningen"}, 15 | {"arabic", "دبي"}, 16 | {"hangul", "다음과"}, 17 | } 18 | 19 | func doBench(b *testing.B, fn func(b *testing.B, data string)) { 20 | for _, d := range benchData { 21 | testtext.Bench(b, d.name, func(b *testing.B) { fn(b, d.data) }) 22 | } 23 | } 24 | 25 | func BenchmarkSpan(b *testing.B) { 26 | r := New() 27 | doBench(b, func(b *testing.B, str string) { 28 | b.SetBytes(int64(len(str))) 29 | data := []byte(str) 30 | for i := 0; i < b.N; i++ { 31 | r.Reset() 32 | r.Span(data, true) 33 | } 34 | }) 35 | } 36 | 37 | func BenchmarkDirectionASCII(b *testing.B) { 38 | doBench(b, func(b *testing.B, str string) { 39 | b.SetBytes(int64(len(str))) 40 | data := []byte(str) 41 | for i := 0; i < b.N; i++ { 42 | Direction(data) 43 | } 44 | }) 45 | } 46 | 47 | func BenchmarkDirectionStringASCII(b *testing.B) { 48 | doBench(b, func(b *testing.B, str string) { 49 | b.SetBytes(int64(len(str))) 50 | for i := 0; i < b.N; i++ { 51 | DirectionString(str) 52 | } 53 | }) 54 | } 55 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/encoding/example_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package encoding_test 6 | 7 | import ( 8 | "fmt" 9 | "io" 10 | "os" 11 | "strings" 12 | 13 | "golang.org/x/text/encoding" 14 | "golang.org/x/text/encoding/charmap" 15 | "golang.org/x/text/encoding/unicode" 16 | "golang.org/x/text/transform" 17 | ) 18 | 19 | func ExampleDecodeWindows1252() { 20 | sr := strings.NewReader("Gar\xe7on !") 21 | tr := charmap.Windows1252.NewDecoder().Reader(sr) 22 | io.Copy(os.Stdout, tr) 23 | // Output: Garçon ! 24 | } 25 | 26 | func ExampleUTF8Validator() { 27 | for i := 0; i < 2; i++ { 28 | var transformer transform.Transformer 29 | transformer = unicode.UTF16(unicode.BigEndian, unicode.IgnoreBOM).NewEncoder() 30 | if i == 1 { 31 | transformer = transform.Chain(encoding.UTF8Validator, transformer) 32 | } 33 | dst := make([]byte, 256) 34 | src := []byte("abc\xffxyz") // src is invalid UTF-8. 35 | nDst, nSrc, err := transformer.Transform(dst, src, true) 36 | fmt.Printf("i=%d: produced %q, consumed %q, error %v\n", 37 | i, dst[:nDst], src[:nSrc], err) 38 | } 39 | // Output: 40 | // i=0: produced "\x00a\x00b\x00c\xff\xfd\x00x\x00y\x00z", consumed "abc\xffxyz", error 41 | // i=1: produced "\x00a\x00b\x00c", consumed "abc", error encoding: invalid UTF-8 42 | } 43 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/internal/colltab/weighter_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package colltab 6 | 7 | // testWeighter is a simple Weighter that returns weights from a user-defined map. 8 | type testWeighter map[string][]Elem 9 | 10 | func (t testWeighter) Start(int, []byte) int { return 0 } 11 | func (t testWeighter) StartString(int, string) int { return 0 } 12 | func (t testWeighter) Domain() []string { return nil } 13 | func (t testWeighter) Top() uint32 { return 0 } 14 | 15 | // maxContractBytes is the maximum length of any key in the map. 16 | const maxContractBytes = 10 17 | 18 | func (t testWeighter) AppendNext(buf []Elem, s []byte) ([]Elem, int) { 19 | n := len(s) 20 | if n > maxContractBytes { 21 | n = maxContractBytes 22 | } 23 | for i := n; i > 0; i-- { 24 | if e, ok := t[string(s[:i])]; ok { 25 | return append(buf, e...), i 26 | } 27 | } 28 | panic("incomplete testWeighter: could not find " + string(s)) 29 | } 30 | 31 | func (t testWeighter) AppendNextString(buf []Elem, s string) ([]Elem, int) { 32 | n := len(s) 33 | if n > maxContractBytes { 34 | n = maxContractBytes 35 | } 36 | for i := n; i > 0; i-- { 37 | if e, ok := t[s[:i]]; ok { 38 | return append(buf, e...), i 39 | } 40 | } 41 | panic("incomplete testWeighter: could not find " + s) 42 | } 43 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/internal/stringset/set_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package stringset 6 | 7 | import "testing" 8 | 9 | func TestStringSet(t *testing.T) { 10 | testCases := [][]string{ 11 | {""}, 12 | {"∫"}, 13 | {"a", "b", "c"}, 14 | {"", "a", "bb", "ccc"}, 15 | {" ", "aaa", "bb", "c"}, 16 | } 17 | test := func(tc int, b *Builder) { 18 | set := b.Set() 19 | if set.Len() != len(testCases[tc]) { 20 | t.Errorf("%d:Len() = %d; want %d", tc, set.Len(), len(testCases[tc])) 21 | } 22 | for i, s := range testCases[tc] { 23 | if x := b.Index(s); x != i { 24 | t.Errorf("%d:Index(%q) = %d; want %d", tc, s, x, i) 25 | } 26 | if p := Search(&set, s); p != i { 27 | t.Errorf("%d:Search(%q) = %d; want %d", tc, s, p, i) 28 | } 29 | if set.Elem(i) != s { 30 | t.Errorf("%d:Elem(%d) = %s; want %s", tc, i, set.Elem(i), s) 31 | } 32 | } 33 | if p := Search(&set, "apple"); p != -1 { 34 | t.Errorf(`%d:Search("apple") = %d; want -1`, tc, p) 35 | } 36 | } 37 | for i, tc := range testCases { 38 | b := NewBuilder() 39 | for _, s := range tc { 40 | b.Add(s) 41 | } 42 | b.Add(tc...) 43 | test(i, b) 44 | } 45 | for i, tc := range testCases { 46 | b := NewBuilder() 47 | b.Add(tc...) 48 | for _, s := range tc { 49 | b.Add(s) 50 | } 51 | test(i, b) 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/internal/tag/tag_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package tag 6 | 7 | import ( 8 | "strings" 9 | "testing" 10 | ) 11 | 12 | var strdata = []string{ 13 | "aa ", 14 | "aaa ", 15 | "aaaa", 16 | "aaab", 17 | "aab ", 18 | "ab ", 19 | "ba ", 20 | "xxxx", 21 | "\xff\xff\xff\xff", 22 | } 23 | 24 | var testCases = map[string]int{ 25 | "a": 0, 26 | "aa": 0, 27 | "aaa": 1, 28 | "aa ": 0, 29 | "aaaa": 2, 30 | "aaab": 3, 31 | "b": 6, 32 | "ba": 6, 33 | " ": -1, 34 | "aaax": -1, 35 | "bbbb": -1, 36 | "zzzz": -1, 37 | } 38 | 39 | func TestIndex(t *testing.T) { 40 | index := Index(strings.Join(strdata, "")) 41 | for k, v := range testCases { 42 | if i := index.Index([]byte(k)); i != v { 43 | t.Errorf("%s: got %d; want %d", k, i, v) 44 | } 45 | } 46 | } 47 | 48 | func TestFixCase(t *testing.T) { 49 | tests := []string{ 50 | "aaaa", "AbCD", "abcd", 51 | "Zzzz", "AbCD", "Abcd", 52 | "Zzzz", "AbC", "", 53 | "XXX", "ab ", "", 54 | "XXX", "usd", "USD", 55 | "cmn", "AB ", "", 56 | "gsw", "CMN", "cmn", 57 | } 58 | for tc := tests; len(tc) > 0; tc = tc[3:] { 59 | b := []byte(tc[1]) 60 | if !FixCase(tc[0], b) { 61 | b = nil 62 | } 63 | if string(b) != tc[2] { 64 | t.Errorf("FixCase(%q, %q) = %q; want %q", tc[0], tc[1], b, tc[2]) 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/secure/precis/class_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package precis 6 | 7 | import ( 8 | "testing" 9 | 10 | "golang.org/x/text/runes" 11 | ) 12 | 13 | // Compile-time regression test to ensure that Class is a Set 14 | var _ runes.Set = (*class)(nil) 15 | 16 | // Ensure that certain characters are (or are not) in the identifer class. 17 | func TestClassContains(t *testing.T) { 18 | tests := []struct { 19 | name string 20 | class *class 21 | allowed []rune 22 | disallowed []rune 23 | }{ 24 | { 25 | name: "Identifier", 26 | class: identifier, 27 | allowed: []rune("Aa0\u0021\u007e\u00df\u3007"), 28 | disallowed: []rune("\u2150\u2100\u2200\u3164\u2190\u2600\u303b\u1e9b"), 29 | }, 30 | { 31 | name: "Freeform", 32 | class: freeform, 33 | allowed: []rune("Aa0\u0021\u007e\u00df\u3007 \u2150\u2100\u2200\u2190\u2600\u1e9b"), 34 | disallowed: []rune("\u3164\u303b"), 35 | }, 36 | } 37 | 38 | for _, rt := range tests { 39 | for _, r := range rt.allowed { 40 | if !rt.class.Contains(r) { 41 | t.Errorf("Class %s should contain %U", rt.name, r) 42 | } 43 | } 44 | for _, r := range rt.disallowed { 45 | if rt.class.Contains(r) { 46 | t.Errorf("Class %s should not contain %U", rt.name, r) 47 | } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/internal/export/idna/gen_common.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | package main 8 | 9 | // This file contains code that is common between the generation code and the 10 | // package's test code. 11 | 12 | import ( 13 | "log" 14 | 15 | "golang.org/x/text/internal/ucd" 16 | ) 17 | 18 | func catFromEntry(p *ucd.Parser) (cat category) { 19 | r := p.Rune(0) 20 | switch s := p.String(1); s { 21 | case "valid": 22 | cat = valid 23 | case "disallowed": 24 | cat = disallowed 25 | case "disallowed_STD3_valid": 26 | cat = disallowedSTD3Valid 27 | case "disallowed_STD3_mapped": 28 | cat = disallowedSTD3Mapped 29 | case "mapped": 30 | cat = mapped 31 | case "deviation": 32 | cat = deviation 33 | case "ignored": 34 | cat = ignored 35 | default: 36 | log.Fatalf("%U: Unknown category %q", r, s) 37 | } 38 | if s := p.String(3); s != "" { 39 | if cat != valid { 40 | log.Fatalf(`%U: %s defined for %q; want "valid"`, r, s, p.String(1)) 41 | } 42 | switch s { 43 | case "NV8": 44 | cat = validNV8 45 | case "XV8": 46 | cat = validXV8 47 | default: 48 | log.Fatalf("%U: Unexpected exception %q", r, s) 49 | } 50 | } 51 | return cat 52 | } 53 | 54 | var joinType = map[string]info{ 55 | "L": joiningL, 56 | "D": joiningD, 57 | "T": joiningT, 58 | "R": joiningR, 59 | } 60 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/unicode/norm/trie.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package norm 6 | 7 | type valueRange struct { 8 | value uint16 // header: value:stride 9 | lo, hi byte // header: lo:n 10 | } 11 | 12 | type sparseBlocks struct { 13 | values []valueRange 14 | offset []uint16 15 | } 16 | 17 | var nfcSparse = sparseBlocks{ 18 | values: nfcSparseValues[:], 19 | offset: nfcSparseOffset[:], 20 | } 21 | 22 | var nfkcSparse = sparseBlocks{ 23 | values: nfkcSparseValues[:], 24 | offset: nfkcSparseOffset[:], 25 | } 26 | 27 | var ( 28 | nfcData = newNfcTrie(0) 29 | nfkcData = newNfkcTrie(0) 30 | ) 31 | 32 | // lookupValue determines the type of block n and looks up the value for b. 33 | // For n < t.cutoff, the block is a simple lookup table. Otherwise, the block 34 | // is a list of ranges with an accompanying value. Given a matching range r, 35 | // the value for b is by r.value + (b - r.lo) * stride. 36 | func (t *sparseBlocks) lookup(n uint32, b byte) uint16 { 37 | offset := t.offset[n] 38 | header := t.values[offset] 39 | lo := offset + 1 40 | hi := lo + uint16(header.lo) 41 | for lo < hi { 42 | m := lo + (hi-lo)/2 43 | r := t.values[m] 44 | if r.lo <= b && b <= r.hi { 45 | return r.value + uint16(b-r.lo)*header.value 46 | } 47 | if b < r.lo { 48 | hi = m 49 | } else { 50 | lo = m + 1 51 | } 52 | } 53 | return 0 54 | } 55 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/unicode/runenames/runenames.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:generate go run gen.go gen_bits.go 6 | 7 | // Package runenames provides rune names from the Unicode Character Database. 8 | // For example, the name for '\u0100' is "LATIN CAPITAL LETTER A WITH MACRON". 9 | // 10 | // See http://www.unicode.org/Public/UCD/latest/ucd/UnicodeData.txt 11 | package runenames 12 | 13 | import ( 14 | "sort" 15 | ) 16 | 17 | // Name returns the name for r. 18 | func Name(r rune) string { 19 | i := sort.Search(len(table0), func(j int) bool { 20 | e := table0[j] 21 | rOffset := rune(e >> shiftRuneOffset) 22 | return r < rOffset 23 | }) 24 | if i == 0 { 25 | return "" 26 | } 27 | 28 | e := table0[i-1] 29 | rOffset := rune(e >> shiftRuneOffset) 30 | rLength := rune(e>>shiftRuneLength) & maskRuneLength 31 | if r >= rOffset+rLength { 32 | return "" 33 | } 34 | 35 | if (e>>shiftDirect)&maskDirect != 0 { 36 | o := int(e>>shiftDataOffset) & maskDataOffset 37 | n := int(e>>shiftDataLength) & maskDataLength 38 | return data[o : o+n] 39 | } 40 | 41 | base := uint32(e>>shiftDataBase) & maskDataBase 42 | base <<= dataBaseUnit 43 | j := rune(e>>shiftTable1Offset) & maskTable1Offset 44 | j += r - rOffset 45 | d0 := base + uint32(table1[j-1]) // dataOffset 46 | d1 := base + uint32(table1[j-0]) // dataOffset + dataLength 47 | return data[d0:d1] 48 | } 49 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/unicode/norm/readwriter_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package norm 6 | 7 | import ( 8 | "bytes" 9 | "fmt" 10 | "testing" 11 | ) 12 | 13 | var bufSizes = []int{1, 2, 3, 4, 5, 6, 7, 8, 100, 101, 102, 103, 4000, 4001, 4002, 4003} 14 | 15 | func readFunc(size int) appendFunc { 16 | return func(f Form, out []byte, s string) []byte { 17 | out = append(out, s...) 18 | r := f.Reader(bytes.NewBuffer(out)) 19 | buf := make([]byte, size) 20 | result := []byte{} 21 | for n, err := 0, error(nil); err == nil; { 22 | n, err = r.Read(buf) 23 | result = append(result, buf[:n]...) 24 | } 25 | return result 26 | } 27 | } 28 | 29 | func TestReader(t *testing.T) { 30 | for _, s := range bufSizes { 31 | name := fmt.Sprintf("TestReader%d", s) 32 | runNormTests(t, name, readFunc(s)) 33 | } 34 | } 35 | 36 | func writeFunc(size int) appendFunc { 37 | return func(f Form, out []byte, s string) []byte { 38 | in := append(out, s...) 39 | result := new(bytes.Buffer) 40 | w := f.Writer(result) 41 | buf := make([]byte, size) 42 | for n := 0; len(in) > 0; in = in[n:] { 43 | n = copy(buf, in) 44 | _, _ = w.Write(buf[:n]) 45 | } 46 | w.Close() 47 | return result.Bytes() 48 | } 49 | } 50 | 51 | func TestWriter(t *testing.T) { 52 | for _, s := range bufSizes { 53 | name := fmt.Sprintf("TestWriter%d", s) 54 | runNormTests(t, name, writeFunc(s)) 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/cases/fold_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package cases 6 | 7 | import ( 8 | "testing" 9 | 10 | "golang.org/x/text/internal/testtext" 11 | ) 12 | 13 | var foldTestCases = []string{ 14 | "βß\u13f8", // "βssᏰ" 15 | "ab\u13fc\uab7aꭰ", // abᏴᎪᎠ 16 | "affifflast", // affifflast 17 | "Iİiı\u0345", // ii̇iıι 18 | "µµΜΜςσΣΣ", // μμμμσσσσ 19 | } 20 | 21 | func TestFold(t *testing.T) { 22 | for _, tc := range foldTestCases { 23 | testEntry := func(name string, c Caser, m func(r rune) string) { 24 | want := "" 25 | for _, r := range tc { 26 | want += m(r) 27 | } 28 | if got := c.String(tc); got != want { 29 | t.Errorf("%s(%s) = %+q; want %+q", name, tc, got, want) 30 | } 31 | dst := make([]byte, 256) // big enough to hold any result 32 | src := []byte(tc) 33 | v := testtext.AllocsPerRun(20, func() { 34 | c.Transform(dst, src, true) 35 | }) 36 | if v > 0 { 37 | t.Errorf("%s(%s): number of allocs was %f; want 0", name, tc, v) 38 | } 39 | } 40 | testEntry("FullFold", Fold(), func(r rune) string { 41 | return runeFoldData(r).full 42 | }) 43 | // TODO: 44 | // testEntry("SimpleFold", Fold(Compact), func(r rune) string { 45 | // return runeFoldData(r).simple 46 | // }) 47 | // testEntry("SpecialFold", Fold(Turkic), func(r rune) string { 48 | // return runeFoldData(r).special 49 | // }) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/quote@v1.5.2/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/sampler@v1.3.0/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/width/example_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package width_test 6 | 7 | import ( 8 | "fmt" 9 | 10 | "golang.org/x/text/width" 11 | ) 12 | 13 | func ExampleTransformer_fold() { 14 | s := "abヲ₩○¥A" 15 | f := width.Fold.String(s) 16 | fmt.Printf("%U: %s\n", []rune(s), s) 17 | fmt.Printf("%U: %s\n", []rune(f), f) 18 | 19 | // Output: 20 | // [U+0061 U+0062 U+FF66 U+FFE6 U+FFEE U+FFE5 U+FF21]: abヲ₩○¥A 21 | // [U+0061 U+0062 U+30F2 U+20A9 U+25CB U+00A5 U+0041]: abヲ₩○¥A 22 | } 23 | 24 | func ExampleTransformer_widen() { 25 | s := "ab¥ヲ₩○" 26 | w := width.Widen.String(s) 27 | fmt.Printf("%U: %s\n", []rune(s), s) 28 | fmt.Printf("%U: %s\n", []rune(w), w) 29 | 30 | // Output: 31 | // [U+0061 U+0062 U+00A5 U+FF66 U+20A9 U+FFEE]: ab¥ヲ₩○ 32 | // [U+FF41 U+FF42 U+FFE5 U+30F2 U+FFE6 U+25CB]: ab¥ヲ₩○ 33 | } 34 | 35 | func ExampleTransformer_narrow() { 36 | s := "abヲ₩○¥A" 37 | n := width.Narrow.String(s) 38 | fmt.Printf("%U: %s\n", []rune(s), s) 39 | fmt.Printf("%U: %s\n", []rune(n), n) 40 | 41 | // Ambiguous characters with a halfwidth equivalent get mapped as well. 42 | s = "←" 43 | n = width.Narrow.String(s) 44 | fmt.Printf("%U: %s\n", []rune(s), s) 45 | fmt.Printf("%U: %s\n", []rune(n), n) 46 | 47 | // Output: 48 | // [U+0061 U+0062 U+30F2 U+FFE6 U+25CB U+FFE5 U+FF21]: abヲ₩○¥A 49 | // [U+0061 U+0062 U+FF66 U+20A9 U+FFEE U+00A5 U+0041]: abヲ₩○¥A 50 | // [U+2190]: ← 51 | // [U+FFE9]: ← 52 | } 53 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/runes/example_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package runes_test 6 | 7 | import ( 8 | "fmt" 9 | "unicode" 10 | 11 | "golang.org/x/text/runes" 12 | "golang.org/x/text/transform" 13 | "golang.org/x/text/unicode/norm" 14 | "golang.org/x/text/width" 15 | ) 16 | 17 | func ExampleRemove() { 18 | t := transform.Chain(norm.NFD, runes.Remove(runes.In(unicode.Mn)), norm.NFC) 19 | s, _, _ := transform.String(t, "résumé") 20 | fmt.Println(s) 21 | 22 | // Output: 23 | // resume 24 | } 25 | 26 | func ExampleMap() { 27 | replaceHyphens := runes.Map(func(r rune) rune { 28 | if unicode.Is(unicode.Hyphen, r) { 29 | return '|' 30 | } 31 | return r 32 | }) 33 | s, _, _ := transform.String(replaceHyphens, "a-b‐c⸗d﹣e") 34 | fmt.Println(s) 35 | 36 | // Output: 37 | // a|b|c|d|e 38 | } 39 | 40 | func ExampleIn() { 41 | // Convert Latin characters to their canonical form, while keeping other 42 | // width distinctions. 43 | t := runes.If(runes.In(unicode.Latin), width.Fold, nil) 44 | s, _, _ := transform.String(t, "アルアノリウ tech / アルアノリウ tech") 45 | fmt.Println(s) 46 | 47 | // Output: 48 | // アルアノリウ tech / アルアノリウ tech 49 | } 50 | 51 | func ExampleIf() { 52 | // Widen everything but ASCII. 53 | isASCII := func(r rune) bool { return r <= unicode.MaxASCII } 54 | t := runes.If(runes.Predicate(isASCII), nil, width.Widen) 55 | s, _, _ := transform.String(t, "アルアノリウ tech / 中國 / 5₩") 56 | fmt.Println(s) 57 | 58 | // Output: 59 | // アルアノリウ tech / 中國 / 5₩ 60 | } 61 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/language/httpexample_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package language_test 6 | 7 | import ( 8 | "fmt" 9 | "net/http" 10 | "strings" 11 | 12 | "golang.org/x/text/language" 13 | ) 14 | 15 | // matcher is a language.Matcher configured for all supported languages. 16 | var matcher = language.NewMatcher([]language.Tag{ 17 | language.BritishEnglish, 18 | language.Norwegian, 19 | language.German, 20 | }) 21 | 22 | // handler is a http.HandlerFunc. 23 | func handler(w http.ResponseWriter, r *http.Request) { 24 | t, q, err := language.ParseAcceptLanguage(r.Header.Get("Accept-Language")) 25 | // We ignore the error: the default language will be selected for t == nil. 26 | tag, _, _ := matcher.Match(t...) 27 | fmt.Printf("%5v (t: %6v; q: %3v; err: %v)\n", tag, t, q, err) 28 | } 29 | 30 | func ExampleParseAcceptLanguage() { 31 | for _, al := range []string{ 32 | "nn;q=0.3, en-us;q=0.8, en,", 33 | "gsw, en;q=0.7, en-US;q=0.8", 34 | "gsw, nl, da", 35 | "invalid", 36 | } { 37 | // Create dummy request with Accept-Language set and pass it to handler. 38 | r, _ := http.NewRequest("GET", "example.com", strings.NewReader("Hello")) 39 | r.Header.Set("Accept-Language", al) 40 | handler(nil, r) 41 | } 42 | 43 | // Output: 44 | // en-GB (t: [ en en-US nn]; q: [ 1 0.8 0.3]; err: ) 45 | // en-GB (t: [ gsw en-US en]; q: [ 1 0.8 0.7]; err: ) 46 | // de (t: [ gsw nl da]; q: [ 1 1 1]; err: ) 47 | // en-GB (t: []; q: []; err: language: tag is not well-formed) 48 | } 49 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/cases/icu.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build icu 6 | 7 | package cases 8 | 9 | // Ideally these functions would be defined in a test file, but go test doesn't 10 | // allow CGO in tests. The build tag should ensure either way that these 11 | // functions will not end up in the package. 12 | 13 | // TODO: Ensure that the correct ICU version is set. 14 | 15 | /* 16 | #cgo LDFLAGS: -licui18n.57 -licuuc.57 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | */ 23 | import "C" 24 | 25 | import "unsafe" 26 | 27 | func doICU(tag, caser, input string) string { 28 | err := C.UErrorCode(0) 29 | loc := C.CString(tag) 30 | cm := C.ucasemap_open(loc, C.uint32_t(0), &err) 31 | 32 | buf := make([]byte, len(input)*4) 33 | dst := (*C.char)(unsafe.Pointer(&buf[0])) 34 | src := C.CString(input) 35 | 36 | cn := C.int32_t(0) 37 | 38 | switch caser { 39 | case "fold": 40 | cn = C.ucasemap_utf8FoldCase(cm, 41 | dst, C.int32_t(len(buf)), 42 | src, C.int32_t(len(input)), 43 | &err) 44 | case "lower": 45 | cn = C.ucasemap_utf8ToLower(cm, 46 | dst, C.int32_t(len(buf)), 47 | src, C.int32_t(len(input)), 48 | &err) 49 | case "upper": 50 | cn = C.ucasemap_utf8ToUpper(cm, 51 | dst, C.int32_t(len(buf)), 52 | src, C.int32_t(len(input)), 53 | &err) 54 | case "title": 55 | cn = C.ucasemap_utf8ToTitle(cm, 56 | dst, C.int32_t(len(buf)), 57 | src, C.int32_t(len(input)), 58 | &err) 59 | } 60 | return string(buf[:cn]) 61 | } 62 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/unicode/bidi/ranges_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. 2 | 3 | package bidi 4 | 5 | import ( 6 | "unicode" 7 | 8 | "golang.org/x/text/internal/gen" 9 | "golang.org/x/text/internal/ucd" 10 | "golang.org/x/text/unicode/rangetable" 11 | ) 12 | 13 | // These tables are hand-extracted from: 14 | // http://www.unicode.org/Public/8.0.0/ucd/extracted/DerivedBidiClass.txt 15 | func visitDefaults(fn func(r rune, c Class)) { 16 | // first write default values for ranges listed above. 17 | visitRunes(fn, AL, []rune{ 18 | 0x0600, 0x07BF, // Arabic 19 | 0x08A0, 0x08FF, // Arabic Extended-A 20 | 0xFB50, 0xFDCF, // Arabic Presentation Forms 21 | 0xFDF0, 0xFDFF, 22 | 0xFE70, 0xFEFF, 23 | 0x0001EE00, 0x0001EEFF, // Arabic Mathematical Alpha Symbols 24 | }) 25 | visitRunes(fn, R, []rune{ 26 | 0x0590, 0x05FF, // Hebrew 27 | 0x07C0, 0x089F, // Nko et al. 28 | 0xFB1D, 0xFB4F, 29 | 0x00010800, 0x00010FFF, // Cypriot Syllabary et. al. 30 | 0x0001E800, 0x0001EDFF, 31 | 0x0001EF00, 0x0001EFFF, 32 | }) 33 | visitRunes(fn, ET, []rune{ // European Terminator 34 | 0x20A0, 0x20Cf, // Currency symbols 35 | }) 36 | rangetable.Visit(unicode.Noncharacter_Code_Point, func(r rune) { 37 | fn(r, BN) // Boundary Neutral 38 | }) 39 | ucd.Parse(gen.OpenUCDFile("DerivedCoreProperties.txt"), func(p *ucd.Parser) { 40 | if p.String(1) == "Default_Ignorable_Code_Point" { 41 | fn(p.Rune(0), BN) // Boundary Neutral 42 | } 43 | }) 44 | } 45 | 46 | func visitRunes(fn func(r rune, c Class), c Class, runes []rune) { 47 | for i := 0; i < len(runes); i += 2 { 48 | lo, hi := runes[i], runes[i+1] 49 | for j := lo; j <= hi; j++ { 50 | fn(j, c) 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/internal/catmsg/varint.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package catmsg 6 | 7 | // This file implements varint encoding analogous to the one in encoding/binary. 8 | // We need a string version of this function, so we add that here and then add 9 | // the rest for consistency. 10 | 11 | import "errors" 12 | 13 | var ( 14 | errIllegalVarint = errors.New("catmsg: illegal varint") 15 | errVarintTooLarge = errors.New("catmsg: varint too large for uint64") 16 | ) 17 | 18 | const maxVarintBytes = 10 // maximum length of a varint 19 | 20 | // encodeUint encodes x as a variable-sized integer into buf and returns the 21 | // number of bytes written. buf must be at least maxVarintBytes long 22 | func encodeUint(buf []byte, x uint64) (n int) { 23 | for ; x > 127; n++ { 24 | buf[n] = 0x80 | uint8(x&0x7F) 25 | x >>= 7 26 | } 27 | buf[n] = uint8(x) 28 | n++ 29 | return n 30 | } 31 | 32 | func decodeUintString(s string) (x uint64, size int, err error) { 33 | i := 0 34 | for shift := uint(0); shift < 64; shift += 7 { 35 | if i >= len(s) { 36 | return 0, i, errIllegalVarint 37 | } 38 | b := uint64(s[i]) 39 | i++ 40 | x |= (b & 0x7F) << shift 41 | if b&0x80 == 0 { 42 | return x, i, nil 43 | } 44 | } 45 | return 0, i, errVarintTooLarge 46 | } 47 | 48 | func decodeUint(b []byte) (x uint64, size int, err error) { 49 | i := 0 50 | for shift := uint(0); shift < 64; shift += 7 { 51 | if i >= len(b) { 52 | return 0, i, errIllegalVarint 53 | } 54 | c := uint64(b[i]) 55 | i++ 56 | x |= (c & 0x7F) << shift 57 | if c&0x80 == 0 { 58 | return x, i, nil 59 | } 60 | } 61 | return 0, i, errVarintTooLarge 62 | } 63 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/width/tables_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package width 6 | 7 | import ( 8 | "testing" 9 | 10 | "golang.org/x/text/internal/testtext" 11 | ) 12 | 13 | const ( 14 | loSurrogate = 0xD800 15 | hiSurrogate = 0xDFFF 16 | ) 17 | 18 | func TestTables(t *testing.T) { 19 | testtext.SkipIfNotLong(t) 20 | 21 | runes := map[rune]Kind{} 22 | getWidthData(func(r rune, tag elem, _ rune) { 23 | runes[r] = tag.kind() 24 | }) 25 | for r := rune(0); r < 0x10FFFF; r++ { 26 | if loSurrogate <= r && r <= hiSurrogate { 27 | continue 28 | } 29 | p := LookupRune(r) 30 | if got, want := p.Kind(), runes[r]; got != want { 31 | t.Errorf("Kind of %U was %s; want %s.", r, got, want) 32 | } 33 | want, mapped := foldRune(r) 34 | if got := p.Folded(); (got == 0) == mapped || got != 0 && got != want { 35 | t.Errorf("Folded(%U) = %U; want %U", r, got, want) 36 | } 37 | want, mapped = widenRune(r) 38 | if got := p.Wide(); (got == 0) == mapped || got != 0 && got != want { 39 | t.Errorf("Wide(%U) = %U; want %U", r, got, want) 40 | } 41 | want, mapped = narrowRune(r) 42 | if got := p.Narrow(); (got == 0) == mapped || got != 0 && got != want { 43 | t.Errorf("Narrow(%U) = %U; want %U", r, got, want) 44 | } 45 | } 46 | } 47 | 48 | // TestAmbiguous verifies that that ambiguous runes with a mapping always map to 49 | // a halfwidth rune. 50 | func TestAmbiguous(t *testing.T) { 51 | for r, m := range mapRunes { 52 | if m.e != tagAmbiguous { 53 | continue 54 | } 55 | if k := mapRunes[m.r].e.kind(); k != EastAsianHalfwidth { 56 | t.Errorf("Rune %U is ambiguous and maps to a rune of type %v", r, k) 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/internal/colltab/iter_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package colltab 6 | 7 | import ( 8 | "testing" 9 | ) 10 | 11 | func TestDoNorm(t *testing.T) { 12 | const div = -1 // The insertion point of the next block. 13 | tests := []struct { 14 | in, out []int 15 | }{{ 16 | in: []int{4, div, 3}, 17 | out: []int{3, 4}, 18 | }, { 19 | in: []int{4, div, 3, 3, 3}, 20 | out: []int{3, 3, 3, 4}, 21 | }, { 22 | in: []int{0, 4, div, 3}, 23 | out: []int{0, 3, 4}, 24 | }, { 25 | in: []int{0, 0, 4, 5, div, 3, 3}, 26 | out: []int{0, 0, 3, 3, 4, 5}, 27 | }, { 28 | in: []int{0, 0, 1, 4, 5, div, 3, 3}, 29 | out: []int{0, 0, 1, 3, 3, 4, 5}, 30 | }, { 31 | in: []int{0, 0, 1, 4, 5, div, 4, 4}, 32 | out: []int{0, 0, 1, 4, 4, 4, 5}, 33 | }, 34 | } 35 | for j, tt := range tests { 36 | i := Iter{} 37 | var w, p int 38 | for k, cc := range tt.in { 39 | 40 | if cc == div { 41 | w = 100 42 | p = k 43 | continue 44 | } 45 | i.Elems = append(i.Elems, makeCE([]int{w, defaultSecondary, 2, cc})) 46 | } 47 | i.doNorm(p, i.Elems[p].CCC()) 48 | if len(i.Elems) != len(tt.out) { 49 | t.Errorf("%d: length was %d; want %d", j, len(i.Elems), len(tt.out)) 50 | } 51 | prevCCC := uint8(0) 52 | for k, ce := range i.Elems { 53 | if int(ce.CCC()) != tt.out[k] { 54 | t.Errorf("%d:%d: unexpected CCC. Was %d; want %d", j, k, ce.CCC(), tt.out[k]) 55 | } 56 | if k > 0 && ce.CCC() == prevCCC && i.Elems[k-1].Primary() > ce.Primary() { 57 | t.Errorf("%d:%d: normalization crossed across CCC boundary.", j, k) 58 | } 59 | } 60 | } 61 | 62 | // Combining rune overflow is tested in search/pattern_test.go. 63 | } 64 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/secure/precis/trieval.go: -------------------------------------------------------------------------------- 1 | // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. 2 | 3 | package precis 4 | 5 | // entry is the entry of a trie table 6 | // 7..6 property (unassigned, disallowed, maybe, valid) 7 | // 5..0 category 8 | type entry uint8 9 | 10 | const ( 11 | propShift = 6 12 | propMask = 0xc0 13 | catMask = 0x3f 14 | ) 15 | 16 | func (e entry) property() property { return property(e & propMask) } 17 | func (e entry) category() category { return category(e & catMask) } 18 | 19 | type property uint8 20 | 21 | // The order of these constants matter. A Profile may consider runes to be 22 | // allowed either from pValid or idDisOrFreePVal. 23 | const ( 24 | unassigned property = iota << propShift 25 | disallowed 26 | idDisOrFreePVal // disallowed for Identifier, pValid for FreeForm 27 | pValid 28 | ) 29 | 30 | // compute permutations of all properties and specialCategories. 31 | type category uint8 32 | 33 | const ( 34 | other category = iota 35 | 36 | // Special rune types 37 | joiningL 38 | joiningD 39 | joiningT 40 | joiningR 41 | viramaModifier 42 | viramaJoinT // Virama + JoiningT 43 | latinSmallL // U+006c 44 | greek 45 | greekJoinT // Greek + JoiningT 46 | hebrew 47 | hebrewJoinT // Hebrew + JoiningT 48 | japanese // hirigana, katakana, han 49 | 50 | // Special rune types associated with contextual rules defined in 51 | // https://tools.ietf.org/html/rfc5892#appendix-A. 52 | // ContextO 53 | zeroWidthNonJoiner // rule 1 54 | zeroWidthJoiner // rule 2 55 | // ContextJ 56 | middleDot // rule 3 57 | greekLowerNumeralSign // rule 4 58 | hebrewPreceding // rule 5 and 6 59 | katakanaMiddleDot // rule 7 60 | arabicIndicDigit // rule 8 61 | extendedArabicIndicDigit // rule 9 62 | 63 | numCategories 64 | ) 65 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/internal/testtext/codesize.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package testtext 6 | 7 | import ( 8 | "bytes" 9 | "fmt" 10 | "io/ioutil" 11 | "os" 12 | "os/exec" 13 | "path/filepath" 14 | "runtime" 15 | ) 16 | 17 | // CodeSize builds the given code sample and returns the binary size or en error 18 | // if an error occurred. The code sample typically will look like this: 19 | // package main 20 | // import "golang.org/x/text/somepackage" 21 | // func main() { 22 | // somepackage.Func() // reference Func to cause it to be linked in. 23 | // } 24 | // See dict_test.go in the display package for an example. 25 | func CodeSize(s string) (int, error) { 26 | // Write the file. 27 | tmpdir, err := ioutil.TempDir(os.TempDir(), "testtext") 28 | if err != nil { 29 | return 0, fmt.Errorf("testtext: failed to create tmpdir: %v", err) 30 | } 31 | defer os.RemoveAll(tmpdir) 32 | filename := filepath.Join(tmpdir, "main.go") 33 | if err := ioutil.WriteFile(filename, []byte(s), 0644); err != nil { 34 | return 0, fmt.Errorf("testtext: failed to write main.go: %v", err) 35 | } 36 | 37 | // Build the binary. 38 | w := &bytes.Buffer{} 39 | cmd := exec.Command(filepath.Join(runtime.GOROOT(), "bin", "go"), "build", "-o", "main") 40 | cmd.Dir = tmpdir 41 | cmd.Stderr = w 42 | cmd.Stdout = w 43 | if err := cmd.Run(); err != nil { 44 | return 0, fmt.Errorf("testtext: failed to execute command: %v\nmain.go:\n%vErrors:%s", err, s, w) 45 | } 46 | 47 | // Determine the size. 48 | fi, err := os.Stat(filepath.Join(tmpdir, "main")) 49 | if err != nil { 50 | return 0, fmt.Errorf("testtext: failed to get file info: %v", err) 51 | } 52 | return int(fi.Size()), nil 53 | } 54 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/unicode/bidi/gen_ranges.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | package main 8 | 9 | import ( 10 | "unicode" 11 | 12 | "golang.org/x/text/internal/gen" 13 | "golang.org/x/text/internal/ucd" 14 | "golang.org/x/text/unicode/rangetable" 15 | ) 16 | 17 | // These tables are hand-extracted from: 18 | // http://www.unicode.org/Public/8.0.0/ucd/extracted/DerivedBidiClass.txt 19 | func visitDefaults(fn func(r rune, c Class)) { 20 | // first write default values for ranges listed above. 21 | visitRunes(fn, AL, []rune{ 22 | 0x0600, 0x07BF, // Arabic 23 | 0x08A0, 0x08FF, // Arabic Extended-A 24 | 0xFB50, 0xFDCF, // Arabic Presentation Forms 25 | 0xFDF0, 0xFDFF, 26 | 0xFE70, 0xFEFF, 27 | 0x0001EE00, 0x0001EEFF, // Arabic Mathematical Alpha Symbols 28 | }) 29 | visitRunes(fn, R, []rune{ 30 | 0x0590, 0x05FF, // Hebrew 31 | 0x07C0, 0x089F, // Nko et al. 32 | 0xFB1D, 0xFB4F, 33 | 0x00010800, 0x00010FFF, // Cypriot Syllabary et. al. 34 | 0x0001E800, 0x0001EDFF, 35 | 0x0001EF00, 0x0001EFFF, 36 | }) 37 | visitRunes(fn, ET, []rune{ // European Terminator 38 | 0x20A0, 0x20Cf, // Currency symbols 39 | }) 40 | rangetable.Visit(unicode.Noncharacter_Code_Point, func(r rune) { 41 | fn(r, BN) // Boundary Neutral 42 | }) 43 | ucd.Parse(gen.OpenUCDFile("DerivedCoreProperties.txt"), func(p *ucd.Parser) { 44 | if p.String(1) == "Default_Ignorable_Code_Point" { 45 | fn(p.Rune(0), BN) // Boundary Neutral 46 | } 47 | }) 48 | } 49 | 50 | func visitRunes(fn func(r rune, c Class), c Class, runes []rune) { 51 | for i := 0; i < len(runes); i += 2 { 52 | lo, hi := runes[i], runes[i+1] 53 | for j := lo; j <= hi; j++ { 54 | fn(j, c) 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/currency/common.go: -------------------------------------------------------------------------------- 1 | // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. 2 | 3 | package currency 4 | 5 | import ( 6 | "time" 7 | 8 | "golang.org/x/text/language" 9 | ) 10 | 11 | // This file contains code common to gen.go and the package code. 12 | 13 | const ( 14 | cashShift = 3 15 | roundMask = 0x7 16 | 17 | nonTenderBit = 0x8000 18 | ) 19 | 20 | // currencyInfo contains information about a currency. 21 | // bits 0..2: index into roundings for standard rounding 22 | // bits 3..5: index into roundings for cash rounding 23 | type currencyInfo byte 24 | 25 | // roundingType defines the scale (number of fractional decimals) and increments 26 | // in terms of units of size 10^-scale. For example, for scale == 2 and 27 | // increment == 1, the currency is rounded to units of 0.01. 28 | type roundingType struct { 29 | scale, increment uint8 30 | } 31 | 32 | // roundings contains rounding data for currencies. This struct is 33 | // created by hand as it is very unlikely to change much. 34 | var roundings = [...]roundingType{ 35 | {2, 1}, // default 36 | {0, 1}, 37 | {1, 1}, 38 | {3, 1}, 39 | {4, 1}, 40 | {2, 5}, // cash rounding alternative 41 | } 42 | 43 | // regionToCode returns a 16-bit region code. Only two-letter codes are 44 | // supported. (Three-letter codes are not needed.) 45 | func regionToCode(r language.Region) uint16 { 46 | if s := r.String(); len(s) == 2 { 47 | return uint16(s[0])<<8 | uint16(s[1]) 48 | } 49 | return 0 50 | } 51 | 52 | func toDate(t time.Time) uint32 { 53 | y := t.Year() 54 | if y == 1 { 55 | return 0 56 | } 57 | date := uint32(y) << 4 58 | date |= uint32(t.Month()) 59 | date <<= 5 60 | date |= uint32(t.Day()) 61 | return date 62 | } 63 | 64 | func fromDate(date uint32) time.Time { 65 | return time.Date(int(date>>9), time.Month((date>>5)&0xf), int(date&0x1f), 0, 0, 0, 0, time.UTC) 66 | } 67 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/internal/triegen/example_compact_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package triegen_test 6 | 7 | import ( 8 | "fmt" 9 | "io" 10 | "io/ioutil" 11 | 12 | "golang.org/x/text/internal/triegen" 13 | ) 14 | 15 | func ExampleCompacter() { 16 | t := triegen.NewTrie("root") 17 | for r := rune(0); r < 10000; r += 64 { 18 | t.Insert(r, 0x9015BADA55^uint64(r)) 19 | } 20 | sz, _ := t.Gen(ioutil.Discard) 21 | 22 | fmt.Printf("Size normal: %5d\n", sz) 23 | 24 | var c myCompacter 25 | sz, _ = t.Gen(ioutil.Discard, triegen.Compact(&c)) 26 | 27 | fmt.Printf("Size compacted: %5d\n", sz) 28 | 29 | // Output: 30 | // Size normal: 81344 31 | // Size compacted: 3224 32 | } 33 | 34 | // A myCompacter accepts a block if only the first value is given. 35 | type myCompacter []uint64 36 | 37 | func (c *myCompacter) Size(values []uint64) (sz int, ok bool) { 38 | for _, v := range values[1:] { 39 | if v != 0 { 40 | return 0, false 41 | } 42 | } 43 | return 8, true // the size of a uint64 44 | } 45 | 46 | func (c *myCompacter) Store(v []uint64) uint32 { 47 | x := uint32(len(*c)) 48 | *c = append(*c, v[0]) 49 | return x 50 | } 51 | 52 | func (c *myCompacter) Print(w io.Writer) error { 53 | fmt.Fprintln(w, "var firstValue = []uint64{") 54 | for _, v := range *c { 55 | fmt.Fprintf(w, "\t%#x,\n", v) 56 | } 57 | fmt.Fprintln(w, "}") 58 | return nil 59 | } 60 | 61 | func (c *myCompacter) Handler() string { 62 | return "getFirstValue" 63 | 64 | // Where getFirstValue is included along with the generated code: 65 | // func getFirstValue(n uint32, b byte) uint64 { 66 | // if b == 0x80 { // the first continuation byte 67 | // return firstValue[n] 68 | // } 69 | // return 0 70 | // } 71 | } 72 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/collate/sort.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package collate 6 | 7 | import ( 8 | "bytes" 9 | "sort" 10 | ) 11 | 12 | const ( 13 | maxSortBuffer = 40960 14 | maxSortEntries = 4096 15 | ) 16 | 17 | type swapper interface { 18 | Swap(i, j int) 19 | } 20 | 21 | type sorter struct { 22 | buf *Buffer 23 | keys [][]byte 24 | src swapper 25 | } 26 | 27 | func (s *sorter) init(n int) { 28 | if s.buf == nil { 29 | s.buf = &Buffer{} 30 | s.buf.init() 31 | } 32 | if cap(s.keys) < n { 33 | s.keys = make([][]byte, n) 34 | } 35 | s.keys = s.keys[0:n] 36 | } 37 | 38 | func (s *sorter) sort(src swapper) { 39 | s.src = src 40 | sort.Sort(s) 41 | } 42 | 43 | func (s sorter) Len() int { 44 | return len(s.keys) 45 | } 46 | 47 | func (s sorter) Less(i, j int) bool { 48 | return bytes.Compare(s.keys[i], s.keys[j]) == -1 49 | } 50 | 51 | func (s sorter) Swap(i, j int) { 52 | s.keys[i], s.keys[j] = s.keys[j], s.keys[i] 53 | s.src.Swap(i, j) 54 | } 55 | 56 | // A Lister can be sorted by Collator's Sort method. 57 | type Lister interface { 58 | Len() int 59 | Swap(i, j int) 60 | // Bytes returns the bytes of the text at index i. 61 | Bytes(i int) []byte 62 | } 63 | 64 | // Sort uses sort.Sort to sort the strings represented by x using the rules of c. 65 | func (c *Collator) Sort(x Lister) { 66 | n := x.Len() 67 | c.sorter.init(n) 68 | for i := 0; i < n; i++ { 69 | c.sorter.keys[i] = c.Key(c.sorter.buf, x.Bytes(i)) 70 | } 71 | c.sorter.sort(x) 72 | } 73 | 74 | // SortStrings uses sort.Sort to sort the strings in x using the rules of c. 75 | func (c *Collator) SortStrings(x []string) { 76 | c.sorter.init(len(x)) 77 | for i, s := range x { 78 | c.sorter.keys[i] = c.KeyFromString(c.sorter.buf, s) 79 | } 80 | c.sorter.sort(sort.StringSlice(x)) 81 | } 82 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/unicode/bidi/trieval.go: -------------------------------------------------------------------------------- 1 | // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. 2 | 3 | package bidi 4 | 5 | // Class is the Unicode BiDi class. Each rune has a single class. 6 | type Class uint 7 | 8 | const ( 9 | L Class = iota // LeftToRight 10 | R // RightToLeft 11 | EN // EuropeanNumber 12 | ES // EuropeanSeparator 13 | ET // EuropeanTerminator 14 | AN // ArabicNumber 15 | CS // CommonSeparator 16 | B // ParagraphSeparator 17 | S // SegmentSeparator 18 | WS // WhiteSpace 19 | ON // OtherNeutral 20 | BN // BoundaryNeutral 21 | NSM // NonspacingMark 22 | AL // ArabicLetter 23 | Control // Control LRO - PDI 24 | 25 | numClass 26 | 27 | LRO // LeftToRightOverride 28 | RLO // RightToLeftOverride 29 | LRE // LeftToRightEmbedding 30 | RLE // RightToLeftEmbedding 31 | PDF // PopDirectionalFormat 32 | LRI // LeftToRightIsolate 33 | RLI // RightToLeftIsolate 34 | FSI // FirstStrongIsolate 35 | PDI // PopDirectionalIsolate 36 | 37 | unknownClass = ^Class(0) 38 | ) 39 | 40 | var controlToClass = map[rune]Class{ 41 | 0x202D: LRO, // LeftToRightOverride, 42 | 0x202E: RLO, // RightToLeftOverride, 43 | 0x202A: LRE, // LeftToRightEmbedding, 44 | 0x202B: RLE, // RightToLeftEmbedding, 45 | 0x202C: PDF, // PopDirectionalFormat, 46 | 0x2066: LRI, // LeftToRightIsolate, 47 | 0x2067: RLI, // RightToLeftIsolate, 48 | 0x2068: FSI, // FirstStrongIsolate, 49 | 0x2069: PDI, // PopDirectionalIsolate, 50 | } 51 | 52 | // A trie entry has the following bits: 53 | // 7..5 XOR mask for brackets 54 | // 4 1: Bracket open, 0: Bracket close 55 | // 3..0 Class type 56 | 57 | const ( 58 | openMask = 0x10 59 | xorMaskShift = 5 60 | ) 61 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/secure/precis/gen_trieval.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | package main 8 | 9 | // entry is the entry of a trie table 10 | // 7..6 property (unassigned, disallowed, maybe, valid) 11 | // 5..0 category 12 | type entry uint8 13 | 14 | const ( 15 | propShift = 6 16 | propMask = 0xc0 17 | catMask = 0x3f 18 | ) 19 | 20 | func (e entry) property() property { return property(e & propMask) } 21 | func (e entry) category() category { return category(e & catMask) } 22 | 23 | type property uint8 24 | 25 | // The order of these constants matter. A Profile may consider runes to be 26 | // allowed either from pValid or idDisOrFreePVal. 27 | const ( 28 | unassigned property = iota << propShift 29 | disallowed 30 | idDisOrFreePVal // disallowed for Identifier, pValid for FreeForm 31 | pValid 32 | ) 33 | 34 | // compute permutations of all properties and specialCategories. 35 | type category uint8 36 | 37 | const ( 38 | other category = iota 39 | 40 | // Special rune types 41 | joiningL 42 | joiningD 43 | joiningT 44 | joiningR 45 | viramaModifier 46 | viramaJoinT // Virama + JoiningT 47 | latinSmallL // U+006c 48 | greek 49 | greekJoinT // Greek + JoiningT 50 | hebrew 51 | hebrewJoinT // Hebrew + JoiningT 52 | japanese // hirigana, katakana, han 53 | 54 | // Special rune types associated with contextual rules defined in 55 | // https://tools.ietf.org/html/rfc5892#appendix-A. 56 | // ContextO 57 | zeroWidthNonJoiner // rule 1 58 | zeroWidthJoiner // rule 2 59 | // ContextJ 60 | middleDot // rule 3 61 | greekLowerNumeralSign // rule 4 62 | hebrewPreceding // rule 5 and 6 63 | katakanaMiddleDot // rule 7 64 | arabicIndicDigit // rule 8 65 | extendedArabicIndicDigit // rule 9 66 | 67 | numCategories 68 | ) 69 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/currency/gen_common.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | package main 8 | 9 | import ( 10 | "time" 11 | 12 | "golang.org/x/text/language" 13 | ) 14 | 15 | // This file contains code common to gen.go and the package code. 16 | 17 | const ( 18 | cashShift = 3 19 | roundMask = 0x7 20 | 21 | nonTenderBit = 0x8000 22 | ) 23 | 24 | // currencyInfo contains information about a currency. 25 | // bits 0..2: index into roundings for standard rounding 26 | // bits 3..5: index into roundings for cash rounding 27 | type currencyInfo byte 28 | 29 | // roundingType defines the scale (number of fractional decimals) and increments 30 | // in terms of units of size 10^-scale. For example, for scale == 2 and 31 | // increment == 1, the currency is rounded to units of 0.01. 32 | type roundingType struct { 33 | scale, increment uint8 34 | } 35 | 36 | // roundings contains rounding data for currencies. This struct is 37 | // created by hand as it is very unlikely to change much. 38 | var roundings = [...]roundingType{ 39 | {2, 1}, // default 40 | {0, 1}, 41 | {1, 1}, 42 | {3, 1}, 43 | {4, 1}, 44 | {2, 5}, // cash rounding alternative 45 | } 46 | 47 | // regionToCode returns a 16-bit region code. Only two-letter codes are 48 | // supported. (Three-letter codes are not needed.) 49 | func regionToCode(r language.Region) uint16 { 50 | if s := r.String(); len(s) == 2 { 51 | return uint16(s[0])<<8 | uint16(s[1]) 52 | } 53 | return 0 54 | } 55 | 56 | func toDate(t time.Time) uint32 { 57 | y := t.Year() 58 | if y == 1 { 59 | return 0 60 | } 61 | date := uint32(y) << 4 62 | date |= uint32(t.Month()) 63 | date <<= 5 64 | date |= uint32(t.Day()) 65 | return date 66 | } 67 | 68 | func fromDate(date uint32) time.Time { 69 | return time.Date(int(date>>9), time.Month((date>>5)&0xf), int(date&0x1f), 0, 0, 0, 0, time.UTC) 70 | } 71 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/internal/triegen/gen_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build generate 6 | 7 | package triegen_test 8 | 9 | // The code in this file generates captures and writes the tries generated in 10 | // the examples to data_test.go. To invoke it, run: 11 | // go test -tags=generate 12 | // 13 | // Making the generation code a "test" allows us to link in the necessary test 14 | // code. 15 | 16 | import ( 17 | "log" 18 | "os" 19 | "os/exec" 20 | ) 21 | 22 | func init() { 23 | const tmpfile = "tmpout" 24 | const dstfile = "data_test.go" 25 | 26 | f, err := os.Create(tmpfile) 27 | if err != nil { 28 | log.Fatalf("Could not create output file: %v", err) 29 | } 30 | defer os.Remove(tmpfile) 31 | defer f.Close() 32 | 33 | // We exit before this function returns, regardless of success or failure, 34 | // so there's no need to save (and later restore) the existing genWriter 35 | // value. 36 | genWriter = f 37 | 38 | f.Write([]byte(header)) 39 | 40 | Example_build() 41 | ExampleGen_build() 42 | 43 | if err := exec.Command("gofmt", "-w", tmpfile).Run(); err != nil { 44 | log.Fatal(err) 45 | } 46 | os.Remove(dstfile) 47 | os.Rename(tmpfile, dstfile) 48 | 49 | os.Exit(0) 50 | } 51 | 52 | const header = `// This file is generated with "go test -tags generate". DO NOT EDIT! 53 | // +build !generate 54 | 55 | package triegen_test 56 | ` 57 | 58 | // Stubs for generated tries. These are needed as we exclude data_test.go if 59 | // the generate flag is set. This will clearly make the tests fail, but that 60 | // is okay. It allows us to bootstrap. 61 | 62 | type trie struct{} 63 | 64 | func (t *trie) lookupString(string) (uint8, int) { return 0, 1 } 65 | func (t *trie) lookupStringUnsafe(string) uint64 { return 0 } 66 | 67 | func newRandTrie(i int) *trie { return &trie{} } 68 | func newMultiTrie(i int) *trie { return &trie{} } 69 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/unicode/bidi/gen_trieval.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | package main 8 | 9 | // Class is the Unicode BiDi class. Each rune has a single class. 10 | type Class uint 11 | 12 | const ( 13 | L Class = iota // LeftToRight 14 | R // RightToLeft 15 | EN // EuropeanNumber 16 | ES // EuropeanSeparator 17 | ET // EuropeanTerminator 18 | AN // ArabicNumber 19 | CS // CommonSeparator 20 | B // ParagraphSeparator 21 | S // SegmentSeparator 22 | WS // WhiteSpace 23 | ON // OtherNeutral 24 | BN // BoundaryNeutral 25 | NSM // NonspacingMark 26 | AL // ArabicLetter 27 | Control // Control LRO - PDI 28 | 29 | numClass 30 | 31 | LRO // LeftToRightOverride 32 | RLO // RightToLeftOverride 33 | LRE // LeftToRightEmbedding 34 | RLE // RightToLeftEmbedding 35 | PDF // PopDirectionalFormat 36 | LRI // LeftToRightIsolate 37 | RLI // RightToLeftIsolate 38 | FSI // FirstStrongIsolate 39 | PDI // PopDirectionalIsolate 40 | 41 | unknownClass = ^Class(0) 42 | ) 43 | 44 | var controlToClass = map[rune]Class{ 45 | 0x202D: LRO, // LeftToRightOverride, 46 | 0x202E: RLO, // RightToLeftOverride, 47 | 0x202A: LRE, // LeftToRightEmbedding, 48 | 0x202B: RLE, // RightToLeftEmbedding, 49 | 0x202C: PDF, // PopDirectionalFormat, 50 | 0x2066: LRI, // LeftToRightIsolate, 51 | 0x2067: RLI, // RightToLeftIsolate, 52 | 0x2068: FSI, // FirstStrongIsolate, 53 | 0x2069: PDI, // PopDirectionalIsolate, 54 | } 55 | 56 | // A trie entry has the following bits: 57 | // 7..5 XOR mask for brackets 58 | // 4 1: Bracket open, 0: Bracket close 59 | // 3..0 Class type 60 | 61 | const ( 62 | openMask = 0x10 63 | xorMaskShift = 5 64 | ) 65 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/secure/precis/tables_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package precis 6 | 7 | import ( 8 | "testing" 9 | "unicode" 10 | "unicode/utf8" 11 | 12 | "golang.org/x/text/runes" 13 | "golang.org/x/text/unicode/rangetable" 14 | ) 15 | 16 | type tableTest struct { 17 | rangeTable *unicode.RangeTable 18 | prop property 19 | } 20 | 21 | var exceptions = runes.Predicate(func(r rune) bool { 22 | switch uint32(r) { 23 | case 0x00DF, 0x03C2, 0x06FD, 0x06FE, 0x0F0B, 0x3007, 0x00B7, 0x0375, 0x05F3, 24 | 0x05F4, 0x30FB, 0x0660, 0x0661, 0x0662, 0x0663, 0x0664, 0x0665, 0x0666, 25 | 0x0667, 0x0668, 0x0669, 0x06F0, 0x06F1, 0x06F2, 0x06F3, 0x06F4, 0x06F5, 26 | 0x06F6, 0x06F7, 0x06F8, 0x06F9, 0x0640, 0x07FA, 0x302E, 0x302F, 0x3031, 27 | 0x3032, 0x3033, 0x3034, 0x3035, 0x303B: 28 | return true 29 | default: 30 | return false 31 | } 32 | }) 33 | 34 | // Ensure that certain properties were generated correctly. 35 | func TestTable(t *testing.T) { 36 | tests := []tableTest{ 37 | tableTest{ 38 | rangetable.Merge( 39 | unicode.Lt, unicode.Nl, unicode.No, // Other letter digits 40 | unicode.Me, // Modifiers 41 | unicode.Zs, // Spaces 42 | unicode.So, // Symbols 43 | unicode.Pi, unicode.Pf, // Punctuation 44 | ), 45 | idDisOrFreePVal, 46 | }, 47 | tableTest{ 48 | rangetable.New(0x30000, 0x30101, 0xDFFFF), 49 | unassigned, 50 | }, 51 | } 52 | 53 | assigned := rangetable.Assigned(UnicodeVersion) 54 | 55 | for _, test := range tests { 56 | rangetable.Visit(test.rangeTable, func(r rune) { 57 | if !unicode.In(r, assigned) { 58 | return 59 | } 60 | b := make([]byte, 4) 61 | n := utf8.EncodeRune(b, r) 62 | trieval, _ := dpTrie.lookup(b[:n]) 63 | p := entry(trieval).property() 64 | if p != test.prop && !exceptions.Contains(r) { 65 | t.Errorf("%U: got %+x; want %+x", r, test.prop, p) 66 | } 67 | }) 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/secure/precis/benchmark_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.7 6 | 7 | package precis 8 | 9 | import ( 10 | "testing" 11 | 12 | "golang.org/x/text/internal/testtext" 13 | ) 14 | 15 | var benchData = []struct{ name, str string }{ 16 | {"ASCII", "Malvolio"}, 17 | {"NotNormalized", "abcdefg\u0301\u031f"}, 18 | {"Arabic", "دبي"}, 19 | {"Hangul", "동일조건변경허락"}, 20 | } 21 | 22 | var benchProfiles = []struct { 23 | name string 24 | p *Profile 25 | }{ 26 | {"FreeForm", NewFreeform()}, 27 | {"Nickname", Nickname}, 28 | {"OpaqueString", OpaqueString}, 29 | {"UsernameCaseMapped", UsernameCaseMapped}, 30 | {"UsernameCasePreserved", UsernameCasePreserved}, 31 | } 32 | 33 | func doBench(b *testing.B, f func(b *testing.B, p *Profile, s string)) { 34 | for _, bp := range benchProfiles { 35 | for _, d := range benchData { 36 | testtext.Bench(b, bp.name+"/"+d.name, func(b *testing.B) { 37 | f(b, bp.p, d.str) 38 | }) 39 | } 40 | } 41 | } 42 | 43 | func BenchmarkString(b *testing.B) { 44 | doBench(b, func(b *testing.B, p *Profile, s string) { 45 | for i := 0; i < b.N; i++ { 46 | p.String(s) 47 | } 48 | }) 49 | } 50 | 51 | func BenchmarkBytes(b *testing.B) { 52 | doBench(b, func(b *testing.B, p *Profile, s string) { 53 | src := []byte(s) 54 | b.ResetTimer() 55 | for i := 0; i < b.N; i++ { 56 | p.Bytes(src) 57 | } 58 | }) 59 | } 60 | 61 | func BenchmarkAppend(b *testing.B) { 62 | doBench(b, func(b *testing.B, p *Profile, s string) { 63 | src := []byte(s) 64 | dst := make([]byte, 0, 4096) 65 | b.ResetTimer() 66 | for i := 0; i < b.N; i++ { 67 | p.Append(dst, src) 68 | } 69 | }) 70 | } 71 | 72 | func BenchmarkTransform(b *testing.B) { 73 | doBench(b, func(b *testing.B, p *Profile, s string) { 74 | src := []byte(s) 75 | dst := make([]byte, 2*len(s)) 76 | t := p.NewTransformer() 77 | b.ResetTimer() 78 | for i := 0; i < b.N; i++ { 79 | t.Transform(dst, src, true) 80 | } 81 | }) 82 | } 83 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/unicode/norm/forminfo_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build test 6 | 7 | package norm 8 | 9 | import "testing" 10 | 11 | func TestProperties(t *testing.T) { 12 | var d runeData 13 | CK := [2]string{"C", "K"} 14 | for k, r := 1, rune(0); r < 0x2ffff; r++ { 15 | if k < len(testData) && r == testData[k].r { 16 | d = testData[k] 17 | k++ 18 | } 19 | s := string(r) 20 | for j, p := range []Properties{NFC.PropertiesString(s), NFKC.PropertiesString(s)} { 21 | f := d.f[j] 22 | if p.CCC() != d.ccc { 23 | t.Errorf("%U: ccc(%s): was %d; want %d %X", r, CK[j], p.CCC(), d.ccc, p.index) 24 | } 25 | if p.isYesC() != (f.qc == Yes) { 26 | t.Errorf("%U: YesC(%s): was %v; want %v", r, CK[j], p.isYesC(), f.qc == Yes) 27 | } 28 | if p.combinesBackward() != (f.qc == Maybe) { 29 | t.Errorf("%U: combines backwards(%s): was %v; want %v", r, CK[j], p.combinesBackward(), f.qc == Maybe) 30 | } 31 | if p.nLeadingNonStarters() != d.nLead { 32 | t.Errorf("%U: nLead(%s): was %d; want %d %#v %#v", r, CK[j], p.nLeadingNonStarters(), d.nLead, p, d) 33 | } 34 | if p.nTrailingNonStarters() != d.nTrail { 35 | t.Errorf("%U: nTrail(%s): was %d; want %d %#v %#v", r, CK[j], p.nTrailingNonStarters(), d.nTrail, p, d) 36 | } 37 | if p.combinesForward() != f.combinesForward { 38 | t.Errorf("%U: combines forward(%s): was %v; want %v %#v", r, CK[j], p.combinesForward(), f.combinesForward, p) 39 | } 40 | // Skip Hangul as it is algorithmically computed. 41 | if r >= hangulBase && r < hangulEnd { 42 | continue 43 | } 44 | if p.hasDecomposition() { 45 | if has := f.decomposition != ""; !has { 46 | t.Errorf("%U: hasDecomposition(%s): was %v; want %v", r, CK[j], p.hasDecomposition(), has) 47 | } 48 | if string(p.Decomposition()) != f.decomposition { 49 | t.Errorf("%U: decomp(%s): was %+q; want %+q", r, CK[j], p.Decomposition(), f.decomposition) 50 | } 51 | } 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/unicode/bidi/tables_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package bidi 6 | 7 | import ( 8 | "testing" 9 | 10 | "golang.org/x/text/internal/gen" 11 | "golang.org/x/text/internal/testtext" 12 | "golang.org/x/text/internal/ucd" 13 | ) 14 | 15 | var labels = []string{ 16 | AL: "AL", 17 | AN: "AN", 18 | B: "B", 19 | BN: "BN", 20 | CS: "CS", 21 | EN: "EN", 22 | ES: "ES", 23 | ET: "ET", 24 | L: "L", 25 | NSM: "NSM", 26 | ON: "ON", 27 | R: "R", 28 | S: "S", 29 | WS: "WS", 30 | 31 | LRO: "LRO", 32 | RLO: "RLO", 33 | LRE: "LRE", 34 | RLE: "RLE", 35 | PDF: "PDF", 36 | LRI: "LRI", 37 | RLI: "RLI", 38 | FSI: "FSI", 39 | PDI: "PDI", 40 | } 41 | 42 | func TestTables(t *testing.T) { 43 | testtext.SkipIfNotLong(t) 44 | 45 | ucd.Parse(gen.OpenUCDFile("BidiBrackets.txt"), func(p *ucd.Parser) { 46 | r1 := p.Rune(0) 47 | want := p.Rune(1) 48 | 49 | e, _ := LookupRune(r1) 50 | if got := e.reverseBracket(r1); got != want { 51 | t.Errorf("Reverse(%U) = %U; want %U", r1, got, want) 52 | } 53 | }) 54 | 55 | done := map[rune]bool{} 56 | test := func(name string, r rune, want string) { 57 | str := string(r) 58 | e, _ := LookupString(str) 59 | if got := labels[e.Class()]; got != want { 60 | t.Errorf("%s:%U: got %s; want %s", name, r, got, want) 61 | } 62 | if e2, sz := LookupRune(r); e != e2 || sz != len(str) { 63 | t.Errorf("LookupRune(%U) = %v, %d; want %v, %d", r, e2, e, sz, len(str)) 64 | } 65 | if e2, sz := Lookup([]byte(str)); e != e2 || sz != len(str) { 66 | t.Errorf("Lookup(%U) = %v, %d; want %v, %d", r, e2, e, sz, len(str)) 67 | } 68 | done[r] = true 69 | } 70 | 71 | // Insert the derived BiDi properties. 72 | ucd.Parse(gen.OpenUCDFile("extracted/DerivedBidiClass.txt"), func(p *ucd.Parser) { 73 | r := p.Rune(0) 74 | test("derived", r, p.String(1)) 75 | }) 76 | visitDefaults(func(r rune, c Class) { 77 | if !done[r] { 78 | test("default", r, labels[c]) 79 | } 80 | }) 81 | 82 | } 83 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/internal/export/idna/trie.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package idna 6 | 7 | // appendMapping appends the mapping for the respective rune. isMapped must be 8 | // true. A mapping is a categorization of a rune as defined in UTS #46. 9 | func (c info) appendMapping(b []byte, s string) []byte { 10 | index := int(c >> indexShift) 11 | if c&xorBit == 0 { 12 | s := mappings[index:] 13 | return append(b, s[1:s[0]+1]...) 14 | } 15 | b = append(b, s...) 16 | if c&inlineXOR == inlineXOR { 17 | // TODO: support and handle two-byte inline masks 18 | b[len(b)-1] ^= byte(index) 19 | } else { 20 | for p := len(b) - int(xorData[index]); p < len(b); p++ { 21 | index++ 22 | b[p] ^= xorData[index] 23 | } 24 | } 25 | return b 26 | } 27 | 28 | // Sparse block handling code. 29 | 30 | type valueRange struct { 31 | value uint16 // header: value:stride 32 | lo, hi byte // header: lo:n 33 | } 34 | 35 | type sparseBlocks struct { 36 | values []valueRange 37 | offset []uint16 38 | } 39 | 40 | var idnaSparse = sparseBlocks{ 41 | values: idnaSparseValues[:], 42 | offset: idnaSparseOffset[:], 43 | } 44 | 45 | // Don't use newIdnaTrie to avoid unconditional linking in of the table. 46 | var trie = &idnaTrie{} 47 | 48 | // lookup determines the type of block n and looks up the value for b. 49 | // For n < t.cutoff, the block is a simple lookup table. Otherwise, the block 50 | // is a list of ranges with an accompanying value. Given a matching range r, 51 | // the value for b is by r.value + (b - r.lo) * stride. 52 | func (t *sparseBlocks) lookup(n uint32, b byte) uint16 { 53 | offset := t.offset[n] 54 | header := t.values[offset] 55 | lo := offset + 1 56 | hi := lo + uint16(header.lo) 57 | for lo < hi { 58 | m := lo + (hi-lo)/2 59 | r := t.values[m] 60 | if r.lo <= b && b <= r.hi { 61 | return r.value + uint16(b-r.lo)*header.value 62 | } 63 | if b < r.lo { 64 | hi = m 65 | } else { 66 | lo = m + 1 67 | } 68 | } 69 | return 0 70 | } 71 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/secure/precis/profiles.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package precis 6 | 7 | import ( 8 | "unicode" 9 | 10 | "golang.org/x/text/runes" 11 | "golang.org/x/text/transform" 12 | "golang.org/x/text/unicode/norm" 13 | ) 14 | 15 | var ( 16 | // Implements the Nickname profile specified in RFC 7700. 17 | // The nickname profile is not idempotent and may need to be applied multiple 18 | // times before being used for comparisons. 19 | Nickname *Profile = nickname 20 | 21 | // Implements the UsernameCaseMapped profile specified in RFC 7613. 22 | UsernameCaseMapped *Profile = usernameCaseMap 23 | 24 | // Implements the UsernameCasePreserved profile specified in RFC 7613. 25 | UsernameCasePreserved *Profile = usernameNoCaseMap 26 | 27 | // Implements the OpaqueString profile defined in RFC 7613 for passwords and other secure labels. 28 | OpaqueString *Profile = opaquestring 29 | ) 30 | 31 | var ( 32 | nickname = &Profile{ 33 | options: getOpts( 34 | AdditionalMapping(func() transform.Transformer { 35 | return &nickAdditionalMapping{} 36 | }), 37 | IgnoreCase, 38 | Norm(norm.NFKC), 39 | DisallowEmpty, 40 | ), 41 | class: freeform, 42 | } 43 | usernameCaseMap = &Profile{ 44 | options: getOpts( 45 | FoldWidth, 46 | LowerCase(), 47 | Norm(norm.NFC), 48 | BidiRule, 49 | ), 50 | class: identifier, 51 | } 52 | usernameNoCaseMap = &Profile{ 53 | options: getOpts( 54 | FoldWidth, 55 | Norm(norm.NFC), 56 | BidiRule, 57 | ), 58 | class: identifier, 59 | } 60 | opaquestring = &Profile{ 61 | options: getOpts( 62 | AdditionalMapping(func() transform.Transformer { 63 | return mapSpaces 64 | }), 65 | Norm(norm.NFC), 66 | DisallowEmpty, 67 | ), 68 | class: freeform, 69 | } 70 | ) 71 | 72 | // mapSpaces is a shared value of a runes.Map transformer. 73 | var mapSpaces transform.Transformer = runes.Map(func(r rune) rune { 74 | if unicode.Is(unicode.Zs, r) { 75 | return ' ' 76 | } 77 | return r 78 | }) 79 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/unicode/rangetable/rangetable.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package rangetable provides utilities for creating and inspecting 6 | // unicode.RangeTables. 7 | package rangetable 8 | 9 | import ( 10 | "sort" 11 | "unicode" 12 | ) 13 | 14 | // New creates a RangeTable from the given runes, which may contain duplicates. 15 | func New(r ...rune) *unicode.RangeTable { 16 | if len(r) == 0 { 17 | return &unicode.RangeTable{} 18 | } 19 | 20 | sort.Sort(byRune(r)) 21 | 22 | // Remove duplicates. 23 | k := 1 24 | for i := 1; i < len(r); i++ { 25 | if r[k-1] != r[i] { 26 | r[k] = r[i] 27 | k++ 28 | } 29 | } 30 | 31 | var rt unicode.RangeTable 32 | for _, r := range r[:k] { 33 | if r <= 0xFFFF { 34 | rt.R16 = append(rt.R16, unicode.Range16{Lo: uint16(r), Hi: uint16(r), Stride: 1}) 35 | } else { 36 | rt.R32 = append(rt.R32, unicode.Range32{Lo: uint32(r), Hi: uint32(r), Stride: 1}) 37 | } 38 | } 39 | 40 | // Optimize RangeTable. 41 | return Merge(&rt) 42 | } 43 | 44 | type byRune []rune 45 | 46 | func (r byRune) Len() int { return len(r) } 47 | func (r byRune) Swap(i, j int) { r[i], r[j] = r[j], r[i] } 48 | func (r byRune) Less(i, j int) bool { return r[i] < r[j] } 49 | 50 | // Visit visits all runes in the given RangeTable in order, calling fn for each. 51 | func Visit(rt *unicode.RangeTable, fn func(rune)) { 52 | for _, r16 := range rt.R16 { 53 | for r := rune(r16.Lo); r <= rune(r16.Hi); r += rune(r16.Stride) { 54 | fn(r) 55 | } 56 | } 57 | for _, r32 := range rt.R32 { 58 | for r := rune(r32.Lo); r <= rune(r32.Hi); r += rune(r32.Stride) { 59 | fn(r) 60 | } 61 | } 62 | } 63 | 64 | // Assigned returns a RangeTable with all assigned code points for a given 65 | // Unicode version. This includes graphic, format, control, and private-use 66 | // characters. It returns nil if the data for the given version is not 67 | // available. 68 | func Assigned(version string) *unicode.RangeTable { 69 | return assigned[version] 70 | } 71 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/internal/match_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package internal 6 | 7 | import ( 8 | "strings" 9 | "testing" 10 | 11 | "golang.org/x/text/language" 12 | ) 13 | 14 | func TestInheritanceMatcher(t *testing.T) { 15 | for i, tt := range []struct { 16 | haveTags string 17 | wantTags string 18 | match string 19 | conf language.Confidence 20 | }{ 21 | {"und,en,en-US", "en-US", "en-US", language.Exact}, // most specific match 22 | {"zh-Hant,zh", "zh-TW", "zh-Hant", language.High}, // zh-TW implies Hant. 23 | {"und,zh", "zh-TW", "und", language.High}, // zh-TW does not match zh. 24 | {"zh", "zh-TW", "und", language.No}, // zh-TW does not match zh. 25 | {"iw,en,nl", "he", "he", language.Exact}, // matches after canonicalization 26 | {"he,en,nl", "iw", "he", language.Exact}, // matches after canonicalization 27 | // Prefer first match over more specific match for various reasons: 28 | // a) consistency of user interface is more important than an exact match, 29 | // b) _if_ und is specified, it should be considered a correct and useful match, 30 | // Note that a call to this Match will almost always be with a single tag. 31 | {"und,en,en-US", "he,en-US", "und", language.High}, 32 | } { 33 | have := parseTags(tt.haveTags) 34 | m := NewInheritanceMatcher(have) 35 | tag, index, conf := m.Match(parseTags(tt.wantTags)...) 36 | want := language.Raw.Make(tt.match) 37 | if tag != want { 38 | t.Errorf("%d:tag: got %q; want %q", i, tag, want) 39 | } 40 | if conf != language.No { 41 | if got, _ := language.All.Canonicalize(have[index]); got != want { 42 | t.Errorf("%d:index: got %q; want %q ", i, got, want) 43 | } 44 | } 45 | if conf != tt.conf { 46 | t.Errorf("%d:conf: got %v; want %v", i, conf, tt.conf) 47 | } 48 | } 49 | } 50 | 51 | func parseTags(list string) (out []language.Tag) { 52 | for _, s := range strings.Split(list, ",") { 53 | out = append(out, language.Raw.Make(strings.TrimSpace(s))) 54 | } 55 | return out 56 | } 57 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/internal/match.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package internal 6 | 7 | // This file contains matchers that implement CLDR inheritance. 8 | // 9 | // See http://unicode.org/reports/tr35/#Locale_Inheritance. 10 | // 11 | // Some of the inheritance described in this document is already handled by 12 | // the cldr package. 13 | 14 | import ( 15 | "golang.org/x/text/language" 16 | ) 17 | 18 | // TODO: consider if (some of the) matching algorithm needs to be public after 19 | // getting some feel about what is generic and what is specific. 20 | 21 | // NewInheritanceMatcher returns a matcher that matches based on the inheritance 22 | // chain. 23 | // 24 | // The matcher uses canonicalization and the parent relationship to find a 25 | // match. The resulting match will always be either Und or a language with the 26 | // same language and script as the requested language. It will not match 27 | // languages for which there is understood to be mutual or one-directional 28 | // intelligibility. 29 | // 30 | // A Match will indicate an Exact match if the language matches after 31 | // canonicalization and High if the matched tag is a parent. 32 | func NewInheritanceMatcher(t []language.Tag) *InheritanceMatcher { 33 | tags := &InheritanceMatcher{make(map[language.Tag]int)} 34 | for i, tag := range t { 35 | ct, err := language.All.Canonicalize(tag) 36 | if err != nil { 37 | ct = tag 38 | } 39 | tags.index[ct] = i 40 | } 41 | return tags 42 | } 43 | 44 | type InheritanceMatcher struct { 45 | index map[language.Tag]int 46 | } 47 | 48 | func (m InheritanceMatcher) Match(want ...language.Tag) (language.Tag, int, language.Confidence) { 49 | for _, t := range want { 50 | ct, err := language.All.Canonicalize(t) 51 | if err != nil { 52 | ct = t 53 | } 54 | conf := language.Exact 55 | for { 56 | if index, ok := m.index[ct]; ok { 57 | return ct, index, conf 58 | } 59 | if ct == language.Und { 60 | break 61 | } 62 | ct = ct.Parent() 63 | conf = language.High 64 | } 65 | } 66 | return language.Und, 0, language.No 67 | } 68 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/currency/format_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package currency 6 | 7 | import ( 8 | "testing" 9 | 10 | "golang.org/x/text/language" 11 | "golang.org/x/text/message" 12 | ) 13 | 14 | var ( 15 | en = language.English 16 | fr = language.French 17 | en_US = language.AmericanEnglish 18 | en_GB = language.BritishEnglish 19 | en_AU = language.MustParse("en-AU") 20 | und = language.Und 21 | ) 22 | 23 | func TestFormatting(t *testing.T) { 24 | testCases := []struct { 25 | tag language.Tag 26 | value interface{} 27 | format Formatter 28 | want string 29 | }{ 30 | 0: {en, USD.Amount(0.1), nil, "USD 0.10"}, 31 | 1: {en, XPT.Amount(1.0), Symbol, "XPT 1.00"}, 32 | 33 | 2: {en, USD.Amount(2.0), ISO, "USD 2.00"}, 34 | 3: {und, USD.Amount(3.0), Symbol, "US$ 3.00"}, 35 | 4: {en, USD.Amount(4.0), Symbol, "$ 4.00"}, 36 | 37 | 5: {en, USD.Amount(5.20), NarrowSymbol, "$ 5.20"}, 38 | 6: {en, AUD.Amount(6.20), Symbol, "A$ 6.20"}, 39 | 40 | 7: {en_AU, AUD.Amount(7.20), Symbol, "$ 7.20"}, 41 | 8: {en_GB, USD.Amount(8.20), Symbol, "US$ 8.20"}, 42 | 43 | 9: {en, 9.0, Symbol.Default(EUR), "€ 9.00"}, 44 | 10: {en, 10.123, Symbol.Default(KRW), "₩ 10"}, 45 | 11: {fr, 11.52, Symbol.Default(TWD), "TWD 11.52"}, 46 | 12: {en, 12.123, Symbol.Default(czk), "CZK 12.12"}, 47 | 13: {en, 13.123, Symbol.Default(czk).Kind(Cash), "CZK 13"}, 48 | 14: {en, 14.12345, ISO.Default(MustParseISO("CLF")), "CLF 14.1235"}, 49 | 15: {en, USD.Amount(15.00), ISO.Default(TWD), "USD 15.00"}, 50 | 16: {en, KRW.Amount(16.00), ISO.Kind(Cash), "KRW 16"}, 51 | 52 | // TODO: support integers as well. 53 | 54 | 17: {en, USD, nil, "USD"}, 55 | 18: {en, USD, ISO, "USD"}, 56 | 19: {en, USD, Symbol, "$"}, 57 | 20: {en_GB, USD, Symbol, "US$"}, 58 | 21: {en_AU, USD, NarrowSymbol, "$"}, 59 | } 60 | for i, tc := range testCases { 61 | p := message.NewPrinter(tc.tag) 62 | v := tc.value 63 | if tc.format != nil { 64 | v = tc.format(v) 65 | } 66 | if got := p.Sprint(v); got != tc.want { 67 | t.Errorf("%d: got %q; want %q", i, got, tc.want) 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/secure/precis/nickname.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package precis 6 | 7 | import ( 8 | "unicode" 9 | "unicode/utf8" 10 | 11 | "golang.org/x/text/transform" 12 | ) 13 | 14 | type nickAdditionalMapping struct { 15 | // TODO: This transformer needs to be stateless somehow… 16 | notStart bool 17 | prevSpace bool 18 | } 19 | 20 | func (t *nickAdditionalMapping) Reset() { 21 | t.prevSpace = false 22 | t.notStart = false 23 | } 24 | 25 | func (t *nickAdditionalMapping) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) { 26 | // RFC 7700 §2.1. Rules 27 | // 28 | // 2. Additional Mapping Rule: The additional mapping rule consists of 29 | // the following sub-rules. 30 | // 31 | // 1. Any instances of non-ASCII space MUST be mapped to ASCII 32 | // space (U+0020); a non-ASCII space is any Unicode code point 33 | // having a general category of "Zs", naturally with the 34 | // exception of U+0020. 35 | // 36 | // 2. Any instances of the ASCII space character at the beginning 37 | // or end of a nickname MUST be removed (e.g., "stpeter " is 38 | // mapped to "stpeter"). 39 | // 40 | // 3. Interior sequences of more than one ASCII space character 41 | // MUST be mapped to a single ASCII space character (e.g., 42 | // "St Peter" is mapped to "St Peter"). 43 | 44 | for nSrc < len(src) { 45 | r, size := utf8.DecodeRune(src[nSrc:]) 46 | if size == 0 { // Incomplete UTF-8 encoding 47 | if !atEOF { 48 | return nDst, nSrc, transform.ErrShortSrc 49 | } 50 | size = 1 51 | } 52 | if unicode.Is(unicode.Zs, r) { 53 | t.prevSpace = true 54 | } else { 55 | if t.prevSpace && t.notStart { 56 | dst[nDst] = ' ' 57 | nDst += 1 58 | } 59 | if size != copy(dst[nDst:], src[nSrc:nSrc+size]) { 60 | nDst += size 61 | return nDst, nSrc, transform.ErrShortDst 62 | } 63 | nDst += size 64 | t.prevSpace = false 65 | t.notStart = true 66 | } 67 | nSrc += size 68 | } 69 | return nDst, nSrc, nil 70 | } 71 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/feature/plural/common.go: -------------------------------------------------------------------------------- 1 | // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. 2 | 3 | package plural 4 | 5 | // Form defines a plural form. 6 | // 7 | // Not all languages support all forms. Also, the meaning of each form varies 8 | // per language. It is important to note that the name of a form does not 9 | // necessarily correspond one-to-one with the set of numbers. For instance, 10 | // for Croation, One matches not only 1, but also 11, 21, etc. 11 | // 12 | // Each language must at least support the form "other". 13 | type Form byte 14 | 15 | const ( 16 | Other Form = iota 17 | Zero 18 | One 19 | Two 20 | Few 21 | Many 22 | ) 23 | 24 | var countMap = map[string]Form{ 25 | "other": Other, 26 | "zero": Zero, 27 | "one": One, 28 | "two": Two, 29 | "few": Few, 30 | "many": Many, 31 | } 32 | 33 | type pluralCheck struct { 34 | // category: 35 | // 3..7: opID 36 | // 0..2: category 37 | cat byte 38 | setID byte 39 | } 40 | 41 | // opID identifies the type of operand in the plural rule, being i, n or f. 42 | // (v, w, and t are treated as filters in our implementation.) 43 | type opID byte 44 | 45 | const ( 46 | opMod opID = 0x1 // is '%' used? 47 | opNotEqual opID = 0x2 // using "!=" to compare 48 | opI opID = 0 << 2 // integers after taking the absolute value 49 | opN opID = 1 << 2 // full number (must be integer) 50 | opF opID = 2 << 2 // fraction 51 | opV opID = 3 << 2 // number of visible digits 52 | opW opID = 4 << 2 // number of visible digits without trailing zeros 53 | opBretonM opID = 5 << 2 // hard-wired rule for Breton 54 | opItalian800 opID = 6 << 2 // hard-wired rule for Italian 55 | opAzerbaijan00s opID = 7 << 2 // hard-wired rule for Azerbaijan 56 | ) 57 | const ( 58 | // Use this plural form to indicate the next rule needs to match as well. 59 | // The last condition in the list will have the correct plural form. 60 | andNext = 0x7 61 | formMask = 0x7 62 | 63 | opShift = 3 64 | 65 | // numN indicates the maximum integer, or maximum mod value, for which we 66 | // have inclusion masks. 67 | numN = 100 68 | // The common denominator of the modulo that is taken. 69 | maxMod = 100 70 | ) 71 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/unicode/norm/example_iter_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package norm_test 6 | 7 | import ( 8 | "bytes" 9 | "fmt" 10 | "unicode/utf8" 11 | 12 | "golang.org/x/text/unicode/norm" 13 | ) 14 | 15 | // EqualSimple uses a norm.Iter to compare two non-normalized 16 | // strings for equivalence. 17 | func EqualSimple(a, b string) bool { 18 | var ia, ib norm.Iter 19 | ia.InitString(norm.NFKD, a) 20 | ib.InitString(norm.NFKD, b) 21 | for !ia.Done() && !ib.Done() { 22 | if !bytes.Equal(ia.Next(), ib.Next()) { 23 | return false 24 | } 25 | } 26 | return ia.Done() && ib.Done() 27 | } 28 | 29 | // FindPrefix finds the longest common prefix of ASCII characters 30 | // of a and b. 31 | func FindPrefix(a, b string) int { 32 | i := 0 33 | for ; i < len(a) && i < len(b) && a[i] < utf8.RuneSelf && a[i] == b[i]; i++ { 34 | } 35 | return i 36 | } 37 | 38 | // EqualOpt is like EqualSimple, but optimizes the special 39 | // case for ASCII characters. 40 | func EqualOpt(a, b string) bool { 41 | n := FindPrefix(a, b) 42 | a, b = a[n:], b[n:] 43 | var ia, ib norm.Iter 44 | ia.InitString(norm.NFKD, a) 45 | ib.InitString(norm.NFKD, b) 46 | for !ia.Done() && !ib.Done() { 47 | if !bytes.Equal(ia.Next(), ib.Next()) { 48 | return false 49 | } 50 | if n := int64(FindPrefix(a[ia.Pos():], b[ib.Pos():])); n != 0 { 51 | ia.Seek(n, 1) 52 | ib.Seek(n, 1) 53 | } 54 | } 55 | return ia.Done() && ib.Done() 56 | } 57 | 58 | var compareTests = []struct{ a, b string }{ 59 | {"aaa", "aaa"}, 60 | {"aaa", "aab"}, 61 | {"a\u0300a", "\u00E0a"}, 62 | {"a\u0300\u0320b", "a\u0320\u0300b"}, 63 | {"\u1E0A\u0323", "\x44\u0323\u0307"}, 64 | // A character that decomposes into multiple segments 65 | // spans several iterations. 66 | {"\u3304", "\u30A4\u30CB\u30F3\u30AF\u3099"}, 67 | } 68 | 69 | func ExampleIter() { 70 | for i, t := range compareTests { 71 | r0 := EqualSimple(t.a, t.b) 72 | r1 := EqualOpt(t.a, t.b) 73 | fmt.Printf("%d: %v %v\n", i, r0, r1) 74 | } 75 | // Output: 76 | // 0: true true 77 | // 1: false false 78 | // 2: true true 79 | // 3: true true 80 | // 4: true true 81 | // 5: true true 82 | } 83 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/internal/export/idna/example_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package idna_test 6 | 7 | import ( 8 | "fmt" 9 | 10 | "golang.org/x/text/internal/export/idna" 11 | ) 12 | 13 | func ExampleProfile() { 14 | // Raw Punycode has no restrictions and does no mappings. 15 | fmt.Println(idna.ToASCII("")) 16 | fmt.Println(idna.ToASCII("*.faß.com")) 17 | fmt.Println(idna.Punycode.ToASCII("*.faß.com")) 18 | 19 | // Rewrite IDN for lookup. This (currently) uses transitional mappings to 20 | // find a balance between IDNA2003 and IDNA2008 compatibility. 21 | fmt.Println(idna.Lookup.ToASCII("")) 22 | fmt.Println(idna.Lookup.ToASCII("www.faß.com")) 23 | 24 | // Convert an IDN to ASCII for registration purposes. This changes the 25 | // encoding, but reports an error if the input was illformed. 26 | fmt.Println(idna.Registration.ToASCII("")) 27 | fmt.Println(idna.Registration.ToASCII("www.faß.com")) 28 | 29 | // Output: 30 | // 31 | // *.xn--fa-hia.com 32 | // *.xn--fa-hia.com 33 | // 34 | // www.fass.com 35 | // idna: invalid label "" 36 | // www.xn--fa-hia.com 37 | } 38 | 39 | func ExampleNew() { 40 | var p *idna.Profile 41 | 42 | // Raw Punycode has no restrictions and does no mappings. 43 | p = idna.New() 44 | fmt.Println(p.ToASCII("*.faß.com")) 45 | 46 | // Do mappings. Note that star is not allowed in a DNS lookup. 47 | p = idna.New( 48 | idna.MapForLookup(), 49 | idna.Transitional(true)) // Map ß -> ss 50 | fmt.Println(p.ToASCII("*.faß.com")) 51 | 52 | // Lookup for registration. Also does not allow '*'. 53 | p = idna.New(idna.ValidateForRegistration()) 54 | fmt.Println(p.ToUnicode("*.faß.com")) 55 | 56 | // Set up a profile maps for lookup, but allows wild cards. 57 | p = idna.New( 58 | idna.MapForLookup(), 59 | idna.Transitional(true), // Map ß -> ss 60 | idna.StrictDomainName(false)) // Set more permissive ASCII rules. 61 | fmt.Println(p.ToASCII("*.faß.com")) 62 | 63 | // Output: 64 | // *.xn--fa-hia.com 65 | // *.fass.com idna: disallowed rune U+002A 66 | // *.faß.com idna: disallowed rune U+002A 67 | // *.fass.com 68 | } 69 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/internal/triegen/compact.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package triegen 6 | 7 | // This file defines Compacter and its implementations. 8 | 9 | import "io" 10 | 11 | // A Compacter generates an alternative, more space-efficient way to store a 12 | // trie value block. A trie value block holds all possible values for the last 13 | // byte of a UTF-8 encoded rune. Excluding ASCII characters, a trie value block 14 | // always has 64 values, as a UTF-8 encoding ends with a byte in [0x80, 0xC0). 15 | type Compacter interface { 16 | // Size returns whether the Compacter could encode the given block as well 17 | // as its size in case it can. len(v) is always 64. 18 | Size(v []uint64) (sz int, ok bool) 19 | 20 | // Store stores the block using the Compacter's compression method. 21 | // It returns a handle with which the block can be retrieved. 22 | // len(v) is always 64. 23 | Store(v []uint64) uint32 24 | 25 | // Print writes the data structures associated to the given store to w. 26 | Print(w io.Writer) error 27 | 28 | // Handler returns the name of a function that gets called during trie 29 | // lookup for blocks generated by the Compacter. The function should be of 30 | // the form func (n uint32, b byte) uint64, where n is the index returned by 31 | // the Compacter's Store method and b is the last byte of the UTF-8 32 | // encoding, where 0x80 <= b < 0xC0, for which to do the lookup in the 33 | // block. 34 | Handler() string 35 | } 36 | 37 | // simpleCompacter is the default Compacter used by builder. It implements a 38 | // normal trie block. 39 | type simpleCompacter builder 40 | 41 | func (b *simpleCompacter) Size([]uint64) (sz int, ok bool) { 42 | return blockSize * b.ValueSize, true 43 | } 44 | 45 | func (b *simpleCompacter) Store(v []uint64) uint32 { 46 | h := uint32(len(b.ValueBlocks) - blockOffset) 47 | b.ValueBlocks = append(b.ValueBlocks, v) 48 | return h 49 | } 50 | 51 | func (b *simpleCompacter) Print(io.Writer) error { 52 | // Structures are printed in print.go. 53 | return nil 54 | } 55 | 56 | func (b *simpleCompacter) Handler() string { 57 | panic("Handler should be special-cased for this Compacter") 58 | } 59 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/internal/export/idna/gen_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package idna 6 | 7 | import ( 8 | "testing" 9 | "unicode" 10 | 11 | "golang.org/x/text/internal/gen" 12 | "golang.org/x/text/internal/testtext" 13 | "golang.org/x/text/internal/ucd" 14 | ) 15 | 16 | func TestTables(t *testing.T) { 17 | testtext.SkipIfNotLong(t) 18 | 19 | lookup := func(r rune) info { 20 | v, _ := trie.lookupString(string(r)) 21 | return info(v) 22 | } 23 | 24 | ucd.Parse(gen.OpenUnicodeFile("idna", "", "IdnaMappingTable.txt"), func(p *ucd.Parser) { 25 | r := p.Rune(0) 26 | x := lookup(r) 27 | if got, want := x.category(), catFromEntry(p); got != want { 28 | t.Errorf("%U:category: got %x; want %x", r, got, want) 29 | } 30 | 31 | mapped := false 32 | switch p.String(1) { 33 | case "mapped", "disallowed_STD3_mapped", "deviation": 34 | mapped = true 35 | } 36 | if x.isMapped() != mapped { 37 | t.Errorf("%U:isMapped: got %v; want %v", r, x.isMapped(), mapped) 38 | } 39 | if !mapped { 40 | return 41 | } 42 | want := string(p.Runes(2)) 43 | got := string(x.appendMapping(nil, string(r))) 44 | if got != want { 45 | t.Errorf("%U:mapping: got %+q; want %+q", r, got, want) 46 | } 47 | 48 | if x.isMapped() { 49 | return 50 | } 51 | wantMark := unicode.In(r, unicode.Mark) 52 | gotMark := x.isModifier() 53 | if gotMark != wantMark { 54 | t.Errorf("IsMark(%U) = %v; want %v", r, gotMark, wantMark) 55 | } 56 | }) 57 | 58 | ucd.Parse(gen.OpenUCDFile("UnicodeData.txt"), func(p *ucd.Parser) { 59 | r := p.Rune(0) 60 | x := lookup(r) 61 | got := x.isViramaModifier() 62 | 63 | const cccVirama = 9 64 | want := p.Int(ucd.CanonicalCombiningClass) == cccVirama 65 | if got != want { 66 | t.Errorf("IsVirama(%U) = %v; want %v", r, got, want) 67 | } 68 | }) 69 | 70 | ucd.Parse(gen.OpenUCDFile("extracted/DerivedJoiningType.txt"), func(p *ucd.Parser) { 71 | r := p.Rune(0) 72 | x := lookup(r) 73 | if x.isMapped() { 74 | return 75 | } 76 | got := x.joinType() 77 | want := joinType[p.String(1)] 78 | if got != want { 79 | t.Errorf("JoinType(%U) = %x; want %x", r, got, want) 80 | } 81 | }) 82 | } 83 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/collate/build/table.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package build 6 | 7 | import ( 8 | "fmt" 9 | "io" 10 | "reflect" 11 | 12 | "golang.org/x/text/internal/colltab" 13 | ) 14 | 15 | // table is an intermediate structure that roughly resembles the table in collate. 16 | type table struct { 17 | colltab.Table 18 | trie trie 19 | root *trieHandle 20 | } 21 | 22 | // print writes the table as Go compilable code to w. It prefixes the 23 | // variable names with name. It returns the number of bytes written 24 | // and the size of the resulting table. 25 | func (t *table) fprint(w io.Writer, name string) (n, size int, err error) { 26 | update := func(nn, sz int, e error) { 27 | n += nn 28 | if err == nil { 29 | err = e 30 | } 31 | size += sz 32 | } 33 | // Write arrays needed for the structure. 34 | update(printColElems(w, t.ExpandElem, name+"ExpandElem")) 35 | update(printColElems(w, t.ContractElem, name+"ContractElem")) 36 | update(t.trie.printArrays(w, name)) 37 | update(printArray(t.ContractTries, w, name)) 38 | 39 | nn, e := fmt.Fprintf(w, "// Total size of %sTable is %d bytes\n", name, size) 40 | update(nn, 0, e) 41 | return 42 | } 43 | 44 | func (t *table) fprintIndex(w io.Writer, h *trieHandle, id string) (n int, err error) { 45 | p := func(f string, a ...interface{}) { 46 | nn, e := fmt.Fprintf(w, f, a...) 47 | n += nn 48 | if err == nil { 49 | err = e 50 | } 51 | } 52 | p("\t{ // %s\n", id) 53 | p("\t\tlookupOffset: 0x%x,\n", h.lookupStart) 54 | p("\t\tvaluesOffset: 0x%x,\n", h.valueStart) 55 | p("\t},\n") 56 | return 57 | } 58 | 59 | func printColElems(w io.Writer, a []uint32, name string) (n, sz int, err error) { 60 | p := func(f string, a ...interface{}) { 61 | nn, e := fmt.Fprintf(w, f, a...) 62 | n += nn 63 | if err == nil { 64 | err = e 65 | } 66 | } 67 | sz = len(a) * int(reflect.TypeOf(uint32(0)).Size()) 68 | p("// %s: %d entries, %d bytes\n", name, len(a), sz) 69 | p("var %s = [%d]uint32 {", name, len(a)) 70 | for i, c := range a { 71 | switch { 72 | case i%64 == 0: 73 | p("\n\t// Block %d, offset 0x%x\n", i/64, i) 74 | case (i%64)%6 == 0: 75 | p("\n\t") 76 | } 77 | p("0x%.8X, ", c) 78 | } 79 | p("\n}\n\n") 80 | return 81 | } 82 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/feature/plural/gen_common.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | package main 8 | 9 | // Form defines a plural form. 10 | // 11 | // Not all languages support all forms. Also, the meaning of each form varies 12 | // per language. It is important to note that the name of a form does not 13 | // necessarily correspond one-to-one with the set of numbers. For instance, 14 | // for Croation, One matches not only 1, but also 11, 21, etc. 15 | // 16 | // Each language must at least support the form "other". 17 | type Form byte 18 | 19 | const ( 20 | Other Form = iota 21 | Zero 22 | One 23 | Two 24 | Few 25 | Many 26 | ) 27 | 28 | var countMap = map[string]Form{ 29 | "other": Other, 30 | "zero": Zero, 31 | "one": One, 32 | "two": Two, 33 | "few": Few, 34 | "many": Many, 35 | } 36 | 37 | type pluralCheck struct { 38 | // category: 39 | // 3..7: opID 40 | // 0..2: category 41 | cat byte 42 | setID byte 43 | } 44 | 45 | // opID identifies the type of operand in the plural rule, being i, n or f. 46 | // (v, w, and t are treated as filters in our implementation.) 47 | type opID byte 48 | 49 | const ( 50 | opMod opID = 0x1 // is '%' used? 51 | opNotEqual opID = 0x2 // using "!=" to compare 52 | opI opID = 0 << 2 // integers after taking the absolute value 53 | opN opID = 1 << 2 // full number (must be integer) 54 | opF opID = 2 << 2 // fraction 55 | opV opID = 3 << 2 // number of visible digits 56 | opW opID = 4 << 2 // number of visible digits without trailing zeros 57 | opBretonM opID = 5 << 2 // hard-wired rule for Breton 58 | opItalian800 opID = 6 << 2 // hard-wired rule for Italian 59 | opAzerbaijan00s opID = 7 << 2 // hard-wired rule for Azerbaijan 60 | ) 61 | const ( 62 | // Use this plural form to indicate the next rule needs to match as well. 63 | // The last condition in the list will have the correct plural form. 64 | andNext = 0x7 65 | formMask = 0x7 66 | 67 | opShift = 3 68 | 69 | // numN indicates the maximum integer, or maximum mod value, for which we 70 | // have inclusion masks. 71 | numN = 100 72 | // The common denominator of the modulo that is taken. 73 | maxMod = 100 74 | ) 75 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/sampler@v1.3.0/sampler.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package sampler shows simple texts. 6 | package sampler // import "rsc.io/sampler" 7 | 8 | import ( 9 | "os" 10 | "strings" 11 | 12 | "golang.org/x/text/language" 13 | ) 14 | 15 | // DefaultUserPrefs returns the default user language preferences. 16 | // It consults the $LC_ALL, $LC_MESSAGES, and $LANG environment 17 | // variables, in that order. 18 | func DefaultUserPrefs() []language.Tag { 19 | var prefs []language.Tag 20 | for _, k := range []string{"LC_ALL", "LC_MESSAGES", "LANG"} { 21 | if env := os.Getenv(k); env != "" { 22 | prefs = append(prefs, language.Make(env)) 23 | } 24 | } 25 | return prefs 26 | } 27 | 28 | // Hello returns a localized greeting. 29 | // If no prefs are given, Hello uses DefaultUserPrefs. 30 | func Hello(prefs ...language.Tag) string { 31 | if len(prefs) == 0 { 32 | prefs = DefaultUserPrefs() 33 | } 34 | return hello.find(prefs) 35 | } 36 | 37 | // Glass returns a localized silly phrase. 38 | // If no prefs are given, Glass uses DefaultUserPrefs. 39 | func Glass(prefs ...language.Tag) string { 40 | if len(prefs) == 0 { 41 | prefs = DefaultUserPrefs() 42 | } 43 | return glass.find(prefs) 44 | } 45 | 46 | // A text is a localized text. 47 | type text struct { 48 | byTag map[string]string 49 | matcher language.Matcher 50 | } 51 | 52 | // newText creates a new localized text, given a list of translations. 53 | func newText(s string) *text { 54 | t := &text{ 55 | byTag: make(map[string]string), 56 | } 57 | var tags []language.Tag 58 | for _, line := range strings.Split(s, "\n") { 59 | line = strings.TrimSpace(line) 60 | if line == "" { 61 | continue 62 | } 63 | f := strings.Split(line, ": ") 64 | if len(f) != 3 { 65 | continue 66 | } 67 | tag := language.Make(f[1]) 68 | tags = append(tags, tag) 69 | t.byTag[tag.String()] = f[2] 70 | } 71 | t.matcher = language.NewMatcher(tags) 72 | return t 73 | } 74 | 75 | // find finds the text to use for the given language tag preferences. 76 | func (t *text) find(prefs []language.Tag) string { 77 | tag, _, _ := t.matcher.Match(prefs...) 78 | s := t.byTag[tag.String()] 79 | if strings.HasPrefix(s, "RTL ") { 80 | s = "\u200F" + strings.TrimPrefix(s, "RTL ") + "\u200E" 81 | } 82 | return s 83 | } 84 | -------------------------------------------------------------------------------- /debuggerFunctionCalls/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "math/cmplx" 6 | "runtime" 7 | ) 8 | 9 | // to check function calls in debugger, debug the main function (breakpoints are set programmatically) 10 | func main() { 11 | t := T{"ok"} 12 | _ = FuncOneResult() 13 | _ = t.MethodOneResult() 14 | _, _, _ = t.MethodManyUnnamedResults() 15 | _, _, _ = t.MethodManyNamedResults() 16 | t.MethodNoResults() 17 | Panic(false) 18 | _ = Factorial(10, false) 19 | runtime.Breakpoint() 20 | // evaluate the following expressions in debugger: 21 | // FuncOneResult(), t.MethodOneResult() - the result of function or method is shown 22 | // t.MethodManyUnnamedResults() - ~r0, ~r1, ... are used as return value names 23 | // t.MethodManyNamedResults() - return value names specified in function signature are used 24 | // t.MethodNoResults() - result is undefined since function returns nothing 25 | // Panic(false) - the argument to the panic() call is shown as a result 26 | // Factorial(10, true) - evaluation doesn't stop at breakpoints inside the evaluated function 27 | // UnusedFunc(), t.UnusedMethod() - evaluation fails, the error explains that unused function/method are not included into executable 28 | println("ok") 29 | } 30 | 31 | type T struct { 32 | f string 33 | } 34 | 35 | func (t T) MethodNoResults() { 36 | println("foo") 37 | } 38 | 39 | func (t T) MethodOneResult() string { 40 | return "ok" //position MethodOneResult 41 | } 42 | 43 | func (t T) MethodManyUnnamedResults() (string, int, bool) { 44 | return "ok", 42, false 45 | } 46 | 47 | func (t T) MethodManyNamedResults() (one string, two int, three bool) { 48 | return "ok", 42, false 49 | } 50 | 51 | func (t T) UnusedMethod() int { 52 | return 0 53 | } 54 | 55 | func UnusedFunc() int { 56 | return 0 57 | } 58 | 59 | func FuncOneResult() string { 60 | return "ok" 61 | } 62 | 63 | func toPowerPlusTwo() int { 64 | var ( 65 | ToBe bool = false 66 | MaxInt uint64 = 1<<64 - 1 67 | z complex128 = cmplx.Sqrt(-5 + 12i) 68 | n int = 2 69 | ) 70 | 71 | fmt.Printf("Type: %T Value: %v\n", ToBe, ToBe) 72 | fmt.Printf("Type: %T Value: %v\n", MaxInt, MaxInt) 73 | fmt.Printf("Type: %T Value: %v\n", z, z) 74 | return n 75 | } 76 | 77 | func Factorial(n int, withBreak bool) int { 78 | if withBreak { 79 | } 80 | if n == 0 { 81 | return 1 82 | } else { 83 | return n * Factorial(n-1, withBreak) 84 | } 85 | } 86 | 87 | func Panic(b bool) { 88 | if b { 89 | panic("panic value") 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/message/catalog/dict.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package catalog 6 | 7 | import ( 8 | "sync" 9 | 10 | "golang.org/x/text/internal" 11 | "golang.org/x/text/internal/catmsg" 12 | "golang.org/x/text/language" 13 | ) 14 | 15 | // TODO: 16 | // Dictionary returns a Dictionary that returns the first Message, using the 17 | // given language tag, that matches: 18 | // 1. the last one registered by one of the Set methods 19 | // 2. returned by one of the Loaders 20 | // 3. repeat from 1. using the parent language 21 | // This approach allows messages to be underspecified. 22 | // func (c *Catalog) Dictionary(tag language.Tag) (Dictionary, error) { 23 | // // TODO: verify dictionary exists. 24 | // return &dict{&c.index, tag}, nil 25 | // } 26 | 27 | type dict struct { 28 | s *store 29 | tag language.Tag // TODO: make compact tag. 30 | } 31 | 32 | func (d *dict) Lookup(key string) (data string, ok bool) { 33 | return d.s.lookup(d.tag, key) 34 | } 35 | 36 | func (c *Catalog) set(tag language.Tag, key string, s *store, msg ...Message) error { 37 | data, err := catmsg.Compile(tag, &dict{&c.macros, tag}, firstInSequence(msg)) 38 | 39 | s.mutex.Lock() 40 | defer s.mutex.Unlock() 41 | 42 | m := s.index[tag] 43 | if m == nil { 44 | m = msgMap{} 45 | if s.index == nil { 46 | s.index = map[language.Tag]msgMap{} 47 | } 48 | s.index[tag] = m 49 | } 50 | 51 | m[key] = data 52 | return err 53 | } 54 | 55 | type store struct { 56 | mutex sync.RWMutex 57 | index map[language.Tag]msgMap 58 | } 59 | 60 | type msgMap map[string]string 61 | 62 | func (s *store) lookup(tag language.Tag, key string) (data string, ok bool) { 63 | s.mutex.RLock() 64 | defer s.mutex.RUnlock() 65 | 66 | for ; ; tag = tag.Parent() { 67 | if msgs, ok := s.index[tag]; ok { 68 | if msg, ok := msgs[key]; ok { 69 | return msg, true 70 | } 71 | } 72 | if tag == language.Und { 73 | break 74 | } 75 | } 76 | return "", false 77 | } 78 | 79 | // Languages returns all languages for which the store contains variants. 80 | func (s *store) languages() []language.Tag { 81 | s.mutex.RLock() 82 | defer s.mutex.RUnlock() 83 | 84 | tags := make([]language.Tag, 0, len(s.index)) 85 | for t := range s.index { 86 | tags = append(tags, t) 87 | } 88 | internal.SortTags(tags) 89 | return tags 90 | } 91 | -------------------------------------------------------------------------------- /vendoringMode/vendor/rsc.io/text@v0.0.0-20170915032832-14c0d48ead0c/internal/stringset/set.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package stringset provides a way to represent a collection of strings 6 | // compactly. 7 | package stringset 8 | 9 | import "sort" 10 | 11 | // A Set holds a collection of strings that can be looked up by an index number. 12 | type Set struct { 13 | // These fields are exported to allow for code generation. 14 | 15 | Data string 16 | Index []uint16 17 | } 18 | 19 | // Elem returns the string with index i. It panics if i is out of range. 20 | func (s *Set) Elem(i int) string { 21 | return s.Data[s.Index[i]:s.Index[i+1]] 22 | } 23 | 24 | // Len returns the number of strings in the set. 25 | func (s *Set) Len() int { 26 | return len(s.Index) - 1 27 | } 28 | 29 | // Search returns the index of the given string or -1 if it is not in the set. 30 | // The Set must have been created with strings in sorted order. 31 | func Search(s *Set, str string) int { 32 | // TODO: optimize this if it gets used a lot. 33 | n := len(s.Index) - 1 34 | p := sort.Search(n, func(i int) bool { 35 | return s.Elem(i) >= str 36 | }) 37 | if p == n || str != s.Elem(p) { 38 | return -1 39 | } 40 | return p 41 | } 42 | 43 | // A Builder constructs Sets. 44 | type Builder struct { 45 | set Set 46 | index map[string]int 47 | } 48 | 49 | // NewBuilder returns a new and initialized Builder. 50 | func NewBuilder() *Builder { 51 | return &Builder{ 52 | set: Set{ 53 | Index: []uint16{0}, 54 | }, 55 | index: map[string]int{}, 56 | } 57 | } 58 | 59 | // Set creates the set created so far. 60 | func (b *Builder) Set() Set { 61 | return b.set 62 | } 63 | 64 | // Index returns the index for the given string, which must have been added 65 | // before. 66 | func (b *Builder) Index(s string) int { 67 | return b.index[s] 68 | } 69 | 70 | // Add adds a string to the index. Strings that are added by a single Add will 71 | // be stored together, unless they match an existing string. 72 | func (b *Builder) Add(ss ...string) { 73 | // First check if the string already exists. 74 | for _, s := range ss { 75 | if _, ok := b.index[s]; ok { 76 | continue 77 | } 78 | b.index[s] = len(b.set.Index) - 1 79 | b.set.Data += s 80 | x := len(b.set.Data) 81 | if x > 0xFFFF { 82 | panic("Index too > 0xFFFF") 83 | } 84 | b.set.Index = append(b.set.Index, uint16(x)) 85 | } 86 | } 87 | --------------------------------------------------------------------------------