repo_id
stringclasses
927 values
file_path
stringlengths
99
214
content
stringlengths
2
4.15M
script
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/script/mod_patterns.txt
env GO111MODULE=on cd m # 'go list all' should list all of the packages used (directly or indirectly) by # the packages in the main module, but no other packages from the standard # library or active modules. # # 'go list ...' should list packages in all active modules and the standard library. # But not cmd/* - see golang.org/issue/26924. # # 'go list example.com/m/...' should list packages in all modules that begin with 'example.com/m/'. # # 'go list ./...' should list only packages in the current module, not other active modules. # # Warnings about unmatched patterns should only be printed once. # # And the go command should be able to keep track of all this! go list -f '{{.ImportPath}}: {{.Match}}' all ... example.com/m/... ./... ./xyz... stdout 'example.com/m/useunicode: \[all \.\.\. example.com/m/... ./...\]' stdout 'example.com/m/useunsafe: \[all \.\.\. example.com/m/... ./...\]' [cgo] stdout 'example.com/m/useC: \[all \.\.\. example.com/m/... ./...\]' [!cgo] ! stdout example.com/m/useC stdout 'example.com/unused/useerrors: \[\.\.\.\]' # but not "all" stdout 'example.com/m/nested/useencoding: \[\.\.\. example.com/m/...\]' # but NOT "all" or "./..." stdout '^unicode: \[all \.\.\.\]' stdout '^unsafe: \[all \.\.\.\]' stdout 'index/suffixarray: \[\.\.\.\]' ! stdout cmd/pprof # golang.org/issue/26924 stderr -count=1 '^go: warning: "./xyz..." matched no packages$' env CGO_ENABLED=0 go list -f '{{.ImportPath}}: {{.Match}}' all ... example.com/m/... ./... ./xyz... ! stdout example.com/m/useC -- m/go.mod -- module example.com/m require example.com/unused v0.0.0 // indirect replace example.com/unused => ../unused require example.com/m/nested v0.0.0 // indirect replace example.com/m/nested => ../nested -- m/useC/useC.go -- package useC import _ "C" // "C" is a pseudo-package, not an actual one -- m/useunicode/useunicode.go -- package useunicode import _ "unicode" -- m/useunsafe/useunsafe.go -- package useunsafe import _ "unsafe" -- unused/go.mod -- module example.com/unused -- unused/useerrors/useerrors.go -- package useerrors import _ "errors" -- nested/go.mod -- module example.com/m/nested -- nested/useencoding/useencoding.go -- package useencoding import _ "encoding"
script
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/script/mod_init_dep.txt
env GO111MODULE=on # modconv uses git directly to examine what old 'go get' would [!net] skip [!exec:git] skip # go build should populate go.mod from Gopkg.lock cp go.mod1 go.mod go build stderr 'copying requirements from Gopkg.lock' go list -m all ! stderr 'copying requirements from Gopkg.lock' stdout 'rsc.io/sampler v1.0.0' # go list should populate go.mod from Gopkg.lock cp go.mod1 go.mod go list stderr 'copying requirements from Gopkg.lock' go list ! stderr 'copying requirements from Gopkg.lock' go list -m all stdout 'rsc.io/sampler v1.0.0' -- go.mod1 -- module x -- x.go -- package x -- Gopkg.lock -- [[projects]] name = "rsc.io/sampler" version = "v1.0.0"
script
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/script/mod_verify.txt
env GO111MODULE=on # With good go.sum, verify succeeds by avoiding download. cp go.sum.good go.sum go mod verify ! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.1.0.zip # With bad go.sum, verify succeeds by avoiding download. cp go.sum.bad go.sum go mod verify ! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.1.0.zip # With bad go.sum, sync (which must download) fails. # Even if the bad sum is in the old legacy go.modverify file. rm go.sum cp go.sum.bad go.modverify ! go mod tidy stderr 'checksum mismatch' ! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.1.0.zip # With good go.sum, sync works (and moves go.modverify to go.sum). rm go.sum cp go.sum.good go.modverify go mod tidy exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.1.0.zip exists $GOPATH/pkg/mod/rsc.io/quote@v1.1.0/quote.go ! exists go.modverify # go.sum should have the new checksum for go.mod grep '^rsc.io/quote v1.1.0/go.mod ' go.sum # verify should work go mod verify # basic loading of module graph should detect incorrect go.mod files. go mod graph cp go.sum.bad2 go.sum ! go mod graph stderr 'go.mod: checksum mismatch' # go.sum should be created and updated automatically. rm go.sum go mod graph exists go.sum grep '^rsc.io/quote v1.1.0/go.mod ' go.sum ! grep '^rsc.io/quote v1.1.0 ' go.sum go mod tidy grep '^rsc.io/quote v1.1.0/go.mod ' go.sum grep '^rsc.io/quote v1.1.0 ' go.sum # sync should ignore missing ziphash; verify should not rm $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.1.0.ziphash go mod tidy ! go mod verify # Packages below module root should not be mentioned in go.sum. rm go.sum go mod edit -droprequire rsc.io/quote go list rsc.io/quote/buggy # re-resolves import path and updates go.mod grep '^rsc.io/quote v1.5.2/go.mod ' go.sum ! grep buggy go.sum # non-existent packages below module root should not be mentioned in go.sum go mod edit -droprequire rsc.io/quote ! go list rsc.io/quote/morebuggy grep '^rsc.io/quote v1.5.2/go.mod ' go.sum ! grep buggy go.sum -- go.mod -- module x require rsc.io/quote v1.1.0 -- x.go -- package x import _ "rsc.io/quote" -- go.sum.good -- rsc.io/quote v1.1.0 h1:a3YaZoizPtXyv6ZsJ74oo2L4/bwOSTKMY7MAyo4O/0c= -- go.sum.bad -- rsc.io/quote v1.1.0 h1:a3YaZoizPtXyv6ZsJ74oo2L4/bwOSTKMY7MAyo4O/1c= -- go.sum.bad2 -- rsc.io/quote v1.1.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl1=
script
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/script/mod_replace.txt
env GO111MODULE=on go build -o a1.exe . exec ./a1.exe stdout 'Don''t communicate by sharing memory' # Modules can be replaced by local packages. go mod edit -replace=rsc.io/quote/v3=./local/rsc.io/quote/v3 go build -o a2.exe . exec ./a2.exe stdout 'Concurrency is not parallelism.' # The module path of the replacement doesn't need to match. # (For example, it could be a long-running fork with its own import path.) go mod edit -replace=rsc.io/quote/v3=./local/not-rsc.io/quote/v3 go build -o a3.exe . exec ./a3.exe stdout 'Clear is better than clever.' # However, the same module can't be used as two different paths. go mod edit -dropreplace=rsc.io/quote/v3 -replace=not-rsc.io/quote/v3@v3.0.0=rsc.io/quote/v3@v3.0.0 -require=not-rsc.io/quote/v3@v3.0.0 ! go build -o a4.exe . stderr 'rsc.io/quote/v3@v3.0.0 used for two different module paths \(not-rsc.io/quote/v3 and rsc.io/quote/v3\)' -- go.mod -- module quoter require rsc.io/quote/v3 v3.0.0 -- main.go -- package main import ( "fmt" "rsc.io/quote/v3" ) func main() { fmt.Println(quote.GoV3()) } -- local/rsc.io/quote/v3/go.mod -- module rsc.io/quote/v3 require rsc.io/sampler v1.3.0 -- local/rsc.io/quote/v3/quote.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package quote collects pithy sayings. package quote import "rsc.io/sampler" // Hello returns a greeting. func HelloV3() string { return sampler.Hello() } // Glass returns a useful phrase for world travelers. func GlassV3() string { // See http://www.oocities.org/nodotus/hbglass.html. return "I can eat glass and it doesn't hurt me." } // Go returns a REPLACED Go proverb. func GoV3() string { return "Concurrency is not parallelism." } // Opt returns a optimization truth. func OptV3() string { // Wisdom from ken. return "If a program is too slow, it must have a loop." } -- local/not-rsc.io/quote/v3/go.mod -- module not-rsc.io/quote/v3 -- local/not-rsc.io/quote/v3/quote.go -- package quote func GoV3() string { return "Clear is better than clever." }
script
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/script/mod_enabled.txt
# GO111MODULE=auto should only trigger outside GOPATH/src env GO111MODULE=auto cd $GOPATH/src/x/y/z go env GOMOD ! stdout . # no non-empty lines ! go list -m -f {{.GoMod}} stderr 'not using modules' cd $GOPATH/src/x/y/z/w go env GOMOD ! stdout . cd $GOPATH/src/x/y go env GOMOD ! stdout . cd $GOPATH/foo go env GOMOD stdout foo[/\\]go.mod go list -m -f {{.GoMod}} stdout foo[/\\]go.mod cd $GOPATH/foo/bar/baz go env GOMOD stdout foo[/\\]go.mod # GO111MODULE=on should trigger everywhere env GO111MODULE=on cd $GOPATH/src/x/y/z go env GOMOD stdout z[/\\]go.mod cd $GOPATH/src/x/y/z/w go env GOMOD stdout z[/\\]go.mod cd $GOPATH/src/x/y go env GOMOD ! stdout . ! go list -m stderr 'cannot find main module' cd $GOPATH/foo go env GOMOD stdout foo[/\\]go.mod cd $GOPATH/foo/bar/baz go env GOMOD stdout foo[/\\]go.mod # GO111MODULE=off should trigger nowhere env GO111MODULE=off cd $GOPATH/src/x/y/z go env GOMOD ! stdout .+ cd $GOPATH/foo go env GOMOD ! stdout .+ cd $GOPATH/foo/bar/baz go env GOMOD ! stdout .+ # GO111MODULE=auto should ignore and warn about /tmp/go.mod env GO111MODULE=auto cp $GOPATH/src/x/y/z/go.mod $WORK/tmp/go.mod mkdir $WORK/tmp/mydir cd $WORK/tmp/mydir go env GOMOD ! stdout .+ stderr '^go: warning: ignoring go.mod in system temp root ' -- $GOPATH/src/x/y/z/go.mod -- module x/y/z -- $GOPATH/src/x/y/z/w/w.txt -- -- $GOPATH/foo/go.mod -- module example.com/mod -- $GOPATH/foo/bar/baz/quux.txt --
script
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/script/mod_bad_filenames.txt
env GO111MODULE=on ! go get rsc.io/badfile1 rsc.io/badfile2 rsc.io/badfile3 rsc.io/badfile4 rsc.io/badfile5 ! stderr 'unzip.*badfile1' stderr 'unzip.*badfile2[\\/]@v[\\/]v1.0.0.zip:.*malformed file path "☺.go": invalid char ''☺''' stderr 'unzip.*badfile3[\\/]@v[\\/]v1.0.0.zip: malformed file path "x\?y.go": invalid char ''\?''' stderr 'unzip.*badfile4[\\/]@v[\\/]v1.0.0.zip: case-insensitive file name collision: "x/Y.go" and "x/y.go"' stderr 'unzip.*badfile5[\\/]@v[\\/]v1.0.0.zip: case-insensitive file name collision: "x/y" and "x/Y"' -- go.mod -- module x
script
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/script/mod_query.txt
env GO111MODULE=on go list -m -versions rsc.io/quote stdout '^rsc.io/quote v1.0.0 v1.1.0 v1.2.0 v1.2.1 v1.3.0 v1.4.0 v1.5.0 v1.5.1 v1.5.2 v1.5.3-pre1$' # latest rsc.io/quote should be v1.5.2 not v1.5.3-pre1 go list -m rsc.io/quote@latest stdout 'rsc.io/quote v1.5.2$' go list -m rsc.io/quote@>v1.5.2 stdout 'rsc.io/quote v1.5.3-pre1$' go list -m rsc.io/quote@<v1.5.4 stdout 'rsc.io/quote v1.5.2$' ! go list -m rsc.io/quote@>v1.5.3 stderr 'go list -m rsc.io/quote: no matching versions for query ">v1.5.3"' go list -m -e -f '{{.Error.Err}}' rsc.io/quote@>v1.5.3 stdout 'no matching versions for query ">v1.5.3"' -- go.mod -- module x require rsc.io/quote v1.0.0
script
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/script/mod_import.txt
env GO111MODULE=on # latest rsc.io/quote should be v1.5.2 not v1.5.3-pre1 go list go list -m all stdout 'rsc.io/quote v1.5.2' # but v1.5.3-pre1 should be a known version go list -m -versions rsc.io/quote stdout '^rsc.io/quote v1.0.0 v1.1.0 v1.2.0 v1.2.1 v1.3.0 v1.4.0 v1.5.0 v1.5.1 v1.5.2 v1.5.3-pre1$' -- go.mod -- module x -- x.go -- package x import _ "rsc.io/quote"
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/example.com_join_v1.1.0.txt
Written by hand. Test case for package moved into a parent module. -- .mod -- module example.com/join -- .info -- {"Version": "v1.1.0"} -- subpkg/x.go -- package subpkg
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_quote_v3_v3.0.0.txt
rsc.io/quote/v3@v3.0.0 -- .mod -- module rsc.io/quote/v3 require rsc.io/sampler v1.3.0 -- .info -- {"Version":"v3.0.0","Name":"d88915d7e77ed0fd35d0a022a2f244e2202fd8c8","Short":"d88915d7e77e","Time":"2018-07-09T15:34:46Z"} -- go.mod -- module rsc.io/quote/v3 require rsc.io/sampler v1.3.0 -- quote.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package quote collects pithy sayings. package quote // import "rsc.io/quote" import "rsc.io/sampler" // Hello returns a greeting. func HelloV3() string { return sampler.Hello() } // Glass returns a useful phrase for world travelers. func GlassV3() string { // See http://www.oocities.org/nodotus/hbglass.html. return "I can eat glass and it doesn't hurt me." } // Go returns a Go proverb. func GoV3() string { return "Don't communicate by sharing memory, share memory by communicating." } // Opt returns an optimization truth. func OptV3() string { // Wisdom from ken. return "If a program is too slow, it must have a loop." }
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/golang.org_notx_useinternal_v0.1.0.txt
written by hand — attempts to use a prohibited internal package (https://golang.org/s/go14internal) -- .mod -- module golang.org/notx/useinternal -- .info -- {"Version":"v0.1.0","Name":"","Short":"","Time":"2018-07-25T17:24:00Z"} -- go.mod -- module golang.org/notx/useinternal -- useinternal.go -- package useinternal import _ "golang.org/x/internal/subtle"
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/golang.org_x_text_v0.0.0-20170915032832-14c0d48ead0c.txt
written by hand - just enough to compile rsc.io/sampler, rsc.io/quote -- .mod -- module golang.org/x/text -- .info -- {"Version":"v0.0.0-20170915032832-14c0d48ead0c","Name":"v0.0.0-20170915032832-14c0d48ead0c","Short":"14c0d48ead0c","Time":"2017-09-15T03:28:32Z"} -- go.mod -- module golang.org/x/text -- unused/unused.go -- package unused -- language/lang.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // This is a tiny version of golang.org/x/text. package language import "strings" type Tag string func Make(s string) Tag { return Tag(s) } func (t Tag) String() string { return string(t) } func NewMatcher(tags []Tag) Matcher { return &matcher{tags} } type Matcher interface { Match(...Tag) (Tag, int, int) } type matcher struct { tags []Tag } func (m *matcher) Match(prefs ...Tag) (Tag, int, int) { for _, pref := range prefs { for _, tag := range m.tags { if tag == pref || strings.HasPrefix(string(pref), string(tag+"-")) || strings.HasPrefix(string(tag), string(pref+"-")) { return tag, 0, 0 } } } return m.tags[0], 0, 0 }
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_quote_v1.5.0.txt
rsc.io/quote@v1.5.0 -- .mod -- module "rsc.io/quote" require "rsc.io/sampler" v1.3.0 -- .info -- {"Version":"v1.5.0","Name":"3ba1e30dc83bd52c990132b9dfb1688a9d22de13","Short":"3ba1e30dc83b","Time":"2018-02-14T00:58:15Z"} -- go.mod -- module "rsc.io/quote" require "rsc.io/sampler" v1.3.0 -- quote.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package quote collects pithy sayings. package quote // import "rsc.io/quote" import "rsc.io/sampler" // Hello returns a greeting. func Hello() string { return sampler.Hello() } // Glass returns a useful phrase for world travelers. func Glass() string { // See http://www.oocities.org/nodotus/hbglass.html. return "I can eat glass and it doesn't hurt me." } // Go returns a Go proverb. func Go() string { return "Don't communicate by sharing memory, share memory by communicating." } // Opt returns an optimization truth. func Opt() string { // Wisdom from ken. return "If a program is too slow, it must have a loop." } -- quote_test.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package quote import "testing" func TestHello(t *testing.T) { hello := "Hello, world." if out := Hello(); out != hello { t.Errorf("Hello() = %q, want %q", out, hello) } } func TestGlass(t *testing.T) { glass := "I can eat glass and it doesn't hurt me." if out := Glass(); out != glass { t.Errorf("Glass() = %q, want %q", out, glass) } } func TestGo(t *testing.T) { go1 := "Don't communicate by sharing memory, share memory by communicating." if out := Go(); out != go1 { t.Errorf("Go() = %q, want %q", out, go1) } } func TestOpt(t *testing.T) { opt := "If a program is too slow, it must have a loop." if out := Opt(); out != opt { t.Errorf("Opt() = %q, want %q", out, opt) } }
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/example.com_split_v1.0.0.txt
Written by hand. Test case for getting a package that has been moved to a different module. -- .mod -- module example.com/split -- .info -- {"Version": "v1.0.0"} -- subpkg/x.go -- package subpkg
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_breaker_v2.0.0.txt
rsc.io/breaker v2.0.0+incompatible written by hand -- .mod -- module rsc.io/breaker -- .info -- {"Version":"v2.0.0+incompatible", "Name": "7307b307f4f0dde421900f8e5126fadac1e13aed", "Short": "7307b307f4f0"} -- breaker.go -- package breaker const XX = 2
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_sampler_v1.99.99.txt
rsc.io/sampler@v1.99.99 -- .mod -- module "rsc.io/sampler" require "golang.org/x/text" v0.0.0-20170915032832-14c0d48ead0c -- .info -- {"Version":"v1.99.99","Name":"732a3c400797d8835f2af34a9561f155bef85435","Short":"732a3c400797","Time":"2018-02-13T22:20:19Z"} -- go.mod -- module "rsc.io/sampler" require "golang.org/x/text" v0.0.0-20170915032832-14c0d48ead0c -- hello.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Translations by Google Translate. package sampler var hello = newText(` English: en: 99 bottles of beer on the wall, 99 bottles of beer, ... `) -- hello_test.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package sampler import ( "testing" "golang.org/x/text/language" ) var helloTests = []struct { prefs []language.Tag text string }{ { []language.Tag{language.Make("en-US"), language.Make("fr")}, "Hello, world.", }, { []language.Tag{language.Make("fr"), language.Make("en-US")}, "Bonjour le monde.", }, } func TestHello(t *testing.T) { for _, tt := range helloTests { text := Hello(tt.prefs...) if text != tt.text { t.Errorf("Hello(%v) = %q, want %q", tt.prefs, text, tt.text) } } } -- sampler.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package sampler shows simple texts. package sampler // import "rsc.io/sampler" import ( "os" "strings" "golang.org/x/text/language" ) // DefaultUserPrefs returns the default user language preferences. // It consults the $LC_ALL, $LC_MESSAGES, and $LANG environment // variables, in that order. func DefaultUserPrefs() []language.Tag { var prefs []language.Tag for _, k := range []string{"LC_ALL", "LC_MESSAGES", "LANG"} { if env := os.Getenv(k); env != "" { prefs = append(prefs, language.Make(env)) } } return prefs } // Hello returns a localized greeting. // If no prefs are given, Hello uses DefaultUserPrefs. func Hello(prefs ...language.Tag) string { if len(prefs) == 0 { prefs = DefaultUserPrefs() } return hello.find(prefs) } func Glass() string { return "I can eat glass and it doesn't hurt me." } // A text is a localized text. type text struct { byTag map[string]string matcher language.Matcher } // newText creates a new localized text, given a list of translations. func newText(s string) *text { t := &text{ byTag: make(map[string]string), } var tags []language.Tag for _, line := range strings.Split(s, "\n") { line = strings.TrimSpace(line) if line == "" { continue } f := strings.Split(line, ": ") if len(f) != 3 { continue } tag := language.Make(f[1]) tags = append(tags, tag) t.byTag[tag.String()] = f[2] } t.matcher = language.NewMatcher(tags) return t } // find finds the text to use for the given language tag preferences. func (t *text) find(prefs []language.Tag) string { tag, _, _ := t.matcher.Match(prefs...) s := t.byTag[tag.String()] if strings.HasPrefix(s, "RTL ") { s = "\u200F" + strings.TrimPrefix(s, "RTL ") + "\u200E" } return s }
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/research.swtch.com_vgo-tour_v1.0.0.txt
research.swtch.com/vgo-tour@v1.0.0 -- .mod -- module "research.swtch.com/vgo-tour" -- .info -- {"Version":"v1.0.0","Name":"84de74b35823c1e49634f2262f1a58cfc951ebae","Short":"84de74b35823","Time":"2018-02-20T00:04:00Z"} -- go.mod -- module "research.swtch.com/vgo-tour" -- hello.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import ( "fmt" "rsc.io/quote" ) func main() { fmt.Println(quote.Hello()) }
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_badfile2_v1.0.0.txt
rsc.io/badfile1 v1.0.0 written by hand -- .mod -- module rsc.io/badfile2 -- .info -- {"Version":"v1.0.0"} -- go.mod -- module rsc.io/badfile2 -- ☺.go -- package smiley
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_!c!g!o_v1.0.0.txt
rsc.io/CGO v1.0.0 -- .mod -- module rsc.io/CGO -- .info -- {"Version":"v1.0.0","Name":"","Short":"","Time":"2018-08-01T18:23:45Z"} -- go.mod -- module rsc.io/CGO -- cgo.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package CGO // #cgo CFLAGS: -I${SRCDIR} import "C" var V = 0
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_quote_v1.5.2.txt
rsc.io/quote@v1.5.2 -- .mod -- module "rsc.io/quote" require "rsc.io/sampler" v1.3.0 -- .info -- {"Version":"v1.5.2","Name":"c4d4236f92427c64bfbcf1cc3f8142ab18f30b22","Short":"c4d4236f9242","Time":"2018-02-14T15:44:20Z"} -- buggy/buggy_test.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package buggy import "testing" func Test(t *testing.T) { t.Fatal("buggy!") } -- go.mod -- module "rsc.io/quote" require "rsc.io/sampler" v1.3.0 -- quote.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package quote collects pithy sayings. package quote // import "rsc.io/quote" import "rsc.io/sampler" // Hello returns a greeting. func Hello() string { return sampler.Hello() } // Glass returns a useful phrase for world travelers. func Glass() string { // See http://www.oocities.org/nodotus/hbglass.html. return "I can eat glass and it doesn't hurt me." } // Go returns a Go proverb. func Go() string { return "Don't communicate by sharing memory, share memory by communicating." } // Opt returns an optimization truth. func Opt() string { // Wisdom from ken. return "If a program is too slow, it must have a loop." } -- quote_test.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package quote import ( "os" "testing" ) func init() { os.Setenv("LC_ALL", "en") } func TestHello(t *testing.T) { hello := "Hello, world." if out := Hello(); out != hello { t.Errorf("Hello() = %q, want %q", out, hello) } } func TestGlass(t *testing.T) { glass := "I can eat glass and it doesn't hurt me." if out := Glass(); out != glass { t.Errorf("Glass() = %q, want %q", out, glass) } } func TestGo(t *testing.T) { go1 := "Don't communicate by sharing memory, share memory by communicating." if out := Go(); out != go1 { t.Errorf("Go() = %q, want %q", out, go1) } } func TestOpt(t *testing.T) { opt := "If a program is too slow, it must have a loop." if out := Opt(); out != opt { t.Errorf("Opt() = %q, want %q", out, opt) } }
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_quote_v1.0.0.txt
rsc.io/quote@v1.0.0 -- .mod -- module "rsc.io/quote" -- .info -- {"Version":"v1.0.0","Name":"f488df80bcdbd3e5bafdc24ad7d1e79e83edd7e6","Short":"f488df80bcdb","Time":"2018-02-14T00:45:20Z"} -- go.mod -- module "rsc.io/quote" -- quote.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package quote collects pithy sayings. package quote // import "rsc.io/quote" // Hello returns a greeting. func Hello() string { return "Hello, world." } -- quote_test.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package quote import "testing" func TestHello(t *testing.T) { hello := "Hello, world." if out := Hello(); out != hello { t.Errorf("Hello() = %q, want %q", out, hello) } }
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_breaker_v1.0.0.txt
rsc.io/breaker v1.0.0 written by hand -- .mod -- module rsc.io/breaker -- .info -- {"Version":"v1.0.0"} -- breaker.go -- package breaker const X = 1
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_sampler_v1.3.0.txt
rsc.io/sampler@v1.3.0 -- .mod -- module "rsc.io/sampler" require "golang.org/x/text" v0.0.0-20170915032832-14c0d48ead0c -- .info -- {"Version":"v1.3.0","Name":"0cc034b51e57ed7832d4c67d526f75a900996e5c","Short":"0cc034b51e57","Time":"2018-02-13T19:05:03Z"} -- glass.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Translations from Frank da Cruz, Ethan Mollick, and many others. // See http://kermitproject.org/utf8.html. // http://www.oocities.org/nodotus/hbglass.html // https://en.wikipedia.org/wiki/I_Can_Eat_Glass package sampler var glass = newText(` English: en: I can eat glass and it doesn't hurt me. French: fr: Je peux manger du verre, ça ne me fait pas mal. Spanish: es: Puedo comer vidrio, no me hace daño. `) -- glass_test.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package sampler import ( "testing" "golang.org/x/text/language" _ "rsc.io/testonly" ) var glassTests = []struct { prefs []language.Tag text string }{ { []language.Tag{language.Make("en-US"), language.Make("fr")}, "I can eat glass and it doesn't hurt me.", }, { []language.Tag{language.Make("fr"), language.Make("en-US")}, "Je peux manger du verre, ça ne me fait pas mal.", }, } func TestGlass(t *testing.T) { for _, tt := range glassTests { text := Glass(tt.prefs...) if text != tt.text { t.Errorf("Glass(%v) = %q, want %q", tt.prefs, text, tt.text) } } } -- go.mod -- module "rsc.io/sampler" require "golang.org/x/text" v0.0.0-20170915032832-14c0d48ead0c -- hello.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Translations by Google Translate. package sampler var hello = newText(` English: en: Hello, world. French: fr: Bonjour le monde. Spanish: es: Hola Mundo. `) -- hello_test.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package sampler import ( "testing" "golang.org/x/text/language" ) var helloTests = []struct { prefs []language.Tag text string }{ { []language.Tag{language.Make("en-US"), language.Make("fr")}, "Hello, world.", }, { []language.Tag{language.Make("fr"), language.Make("en-US")}, "Bonjour le monde.", }, } func TestHello(t *testing.T) { for _, tt := range helloTests { text := Hello(tt.prefs...) if text != tt.text { t.Errorf("Hello(%v) = %q, want %q", tt.prefs, text, tt.text) } } } -- sampler.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package sampler shows simple texts. package sampler // import "rsc.io/sampler" import ( "os" "strings" "golang.org/x/text/language" ) // DefaultUserPrefs returns the default user language preferences. // It consults the $LC_ALL, $LC_MESSAGES, and $LANG environment // variables, in that order. func DefaultUserPrefs() []language.Tag { var prefs []language.Tag for _, k := range []string{"LC_ALL", "LC_MESSAGES", "LANG"} { if env := os.Getenv(k); env != "" { prefs = append(prefs, language.Make(env)) } } return prefs } // Hello returns a localized greeting. // If no prefs are given, Hello uses DefaultUserPrefs. func Hello(prefs ...language.Tag) string { if len(prefs) == 0 { prefs = DefaultUserPrefs() } return hello.find(prefs) } // Glass returns a localized silly phrase. // If no prefs are given, Glass uses DefaultUserPrefs. func Glass(prefs ...language.Tag) string { if len(prefs) == 0 { prefs = DefaultUserPrefs() } return glass.find(prefs) } // A text is a localized text. type text struct { byTag map[string]string matcher language.Matcher } // newText creates a new localized text, given a list of translations. func newText(s string) *text { t := &text{ byTag: make(map[string]string), } var tags []language.Tag for _, line := range strings.Split(s, "\n") { line = strings.TrimSpace(line) if line == "" { continue } f := strings.Split(line, ": ") if len(f) != 3 { continue } tag := language.Make(f[1]) tags = append(tags, tag) t.byTag[tag.String()] = f[2] } t.matcher = language.NewMatcher(tags) return t } // find finds the text to use for the given language tag preferences. func (t *text) find(prefs []language.Tag) string { tag, _, _ := t.matcher.Match(prefs...) s := t.byTag[tag.String()] if strings.HasPrefix(s, "RTL ") { s = "\u200F" + strings.TrimPrefix(s, "RTL ") + "\u200E" } return s }
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/example.com_split_v1.1.0.txt
Written by hand. Test case for getting a package that has been moved to a different module. -- .mod -- module example.com/split require example.com/split/subpkg v1.1.0 -- .info -- {"Version": "v1.1.0"}
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_breaker_v2.0.0+incompatible.txt
rsc.io/breaker v2.0.0+incompatible written by hand -- .mod -- module rsc.io/breaker -- .info -- {"Version":"v2.0.0+incompatible", "Name": "7307b307f4f0dde421900f8e5126fadac1e13aed", "Short": "7307b307f4f0"} -- breaker.go -- package breaker const XX = 2
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/example.com_join_v1.0.0.txt
Written by hand. Test case for package moved into a parent module. -- .mod -- module example.com/join -- .info -- {"Version": "v1.0.0"}
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_quote_v0.0.0-20180710144737-5d9f230bcfba.txt
rsc.io/quote@v0.0.0-20180710144737-5d9f230bcfba -- .mod -- module rsc.io/quote require ( rsc.io/quote/v3 v3.0.0 rsc.io/sampler v1.3.0 ) -- .info -- {"Version":"v0.0.0-20180710144737-5d9f230bcfba","Name":"5d9f230bcfbae514bb6c2215694c2ce7273fc604","Short":"5d9f230bcfba","Time":"2018-07-10T14:47:37Z"} -- buggy/buggy_test.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package buggy import "testing" func Test(t *testing.T) { t.Fatal("buggy!") } -- go.mod -- module rsc.io/quote require ( rsc.io/quote/v3 v3.0.0 rsc.io/sampler v1.3.0 ) -- quote.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package quote collects pithy sayings. package quote // import "rsc.io/quote" import "rsc.io/quote/v3" // Hello returns a greeting. func Hello() string { return quote.HelloV3() } // Glass returns a useful phrase for world travelers. func Glass() string { // See http://www.oocities.org/nodotus/hbglass.html. return quote.GlassV3() } // Go returns a Go proverb. func Go() string { return quote.GoV3() } // Opt returns an optimization truth. func Opt() string { // Wisdom from ken. return quote.OptV3() } -- quote_test.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package quote import ( "os" "testing" ) func init() { os.Setenv("LC_ALL", "en") } func TestHello(t *testing.T) { hello := "Hello, world." if out := Hello(); out != hello { t.Errorf("Hello() = %q, want %q", out, hello) } } func TestGlass(t *testing.T) { glass := "I can eat glass and it doesn't hurt me." if out := Glass(); out != glass { t.Errorf("Glass() = %q, want %q", out, glass) } } func TestGo(t *testing.T) { go1 := "Don't communicate by sharing memory, share memory by communicating." if out := Go(); out != go1 { t.Errorf("Go() = %q, want %q", out, go1) } } func TestOpt(t *testing.T) { opt := "If a program is too slow, it must have a loop." if out := Opt(); out != opt { t.Errorf("Opt() = %q, want %q", out, opt) } }
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/gopkg.in_dummy.v2-unstable_v2.0.0.txt
gopkg.in/dummy.v2-unstable v2.0.0 written by hand -- .mod -- module gopkg.in/dummy.v2-unstable -- .info -- {"Version":"v2.0.0"} -- dummy.go -- package dummy
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/example.com_split_subpkg_v1.1.0.txt
Written by hand. Test case for getting a package that has been moved to a different module. -- .mod -- module example.com/split/subpkg require example.com/split v1.1.0 -- .info -- {"Version": "v1.1.0"} -- x.go -- package subpkg
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_quote_v0.0.0-20180214005840-23179ee8a569.txt
rsc.io/quote@v0.0.0-20180214005840-23179ee8a569 -- .mod -- module "rsc.io/quote" require "rsc.io/sampler" v1.3.0 -- .info -- {"Version":"v0.0.0-20180214005840-23179ee8a569","Name":"23179ee8a569bb05d896ae05c6503ec69a19f99f","Short":"23179ee8a569","Time":"2018-02-14T00:58:40Z"} -- go.mod -- module "rsc.io/quote" require "rsc.io/sampler" v1.3.0 -- quote.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package quote collects pithy sayings. package quote // import "rsc.io/quote" import "rsc.io/sampler" // Hello returns a greeting. func Hello() string { return sampler.Hello() } // Glass returns a useful phrase for world travelers. func Glass() string { // See http://www.oocities.org/nodotus/hbglass.html. return "I can eat glass and it doesn't hurt me." } // Go returns a Go proverb. func Go() string { return "Don't communicate by sharing memory, share memory by communicating." } // Opt returns an optimization truth. func Opt() string { // Wisdom from ken. return "If a program is too slow, it must have a loop." } -- quote_test.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package quote import ( "os" "testing" ) func init() { os.Setenv("LC_ALL", "en") } func TestHello(t *testing.T) { hello := "Hello, world." if out := Hello(); out != hello { t.Errorf("Hello() = %q, want %q", out, hello) } } func TestGlass(t *testing.T) { glass := "I can eat glass and it doesn't hurt me." if out := Glass(); out != glass { t.Errorf("Glass() = %q, want %q", out, glass) } } func TestGo(t *testing.T) { go1 := "Don't communicate by sharing memory, share memory by communicating." if out := Go(); out != go1 { t.Errorf("Go() = %q, want %q", out, go1) } } func TestOpt(t *testing.T) { opt := "If a program is too slow, it must have a loop." if out := Opt(); out != opt { t.Errorf("Opt() = %q, want %q", out, opt) } }
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_quote_v0.0.0-20180709162918-a91498bed0a7.txt
rsc.io/quote@v0.0.0-20180709162918-a91498bed0a7 -- .mod -- module rsc.io/quote require rsc.io/sampler v1.3.0 -- .info -- {"Version":"v0.0.0-20180709162918-a91498bed0a7","Name":"a91498bed0a73d4bb9c1fb2597925f7883bc40a7","Short":"a91498bed0a7","Time":"2018-07-09T16:29:18Z"} -- buggy/buggy_test.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package buggy import "testing" func Test(t *testing.T) { t.Fatal("buggy!") } -- go.mod -- module rsc.io/quote require rsc.io/sampler v1.3.0 -- quote.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package quote collects pithy sayings. package quote // import "rsc.io/quote" import "rsc.io/quote/v3" // Hello returns a greeting. func Hello() string { return quote.HelloV3() } // Glass returns a useful phrase for world travelers. func Glass() string { // See http://www.oocities.org/nodotus/hbglass.html. return quote.GlassV3() } // Go returns a Go proverb. func Go() string { return quote.GoV3() } // Opt returns an optimization truth. func Opt() string { // Wisdom from ken. return quote.OptV3() } -- quote_test.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package quote import ( "os" "testing" ) func init() { os.Setenv("LC_ALL", "en") } func TestHello(t *testing.T) { hello := "Hello, world." if out := Hello(); out != hello { t.Errorf("Hello() = %q, want %q", out, hello) } } func TestGlass(t *testing.T) { glass := "I can eat glass and it doesn't hurt me." if out := Glass(); out != glass { t.Errorf("Glass() = %q, want %q", out, glass) } } func TestGo(t *testing.T) { go1 := "Don't communicate by sharing memory, share memory by communicating." if out := Go(); out != go1 { t.Errorf("Go() = %q, want %q", out, go1) } } func TestOpt(t *testing.T) { opt := "If a program is too slow, it must have a loop." if out := Opt(); out != opt { t.Errorf("Opt() = %q, want %q", out, opt) } }
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_sampler_v1.2.0.txt
rsc.io/sampler@v1.2.0 -- .mod -- module "rsc.io/sampler" require "golang.org/x/text" v0.0.0-20170915032832-14c0d48ead0c -- .info -- {"Version":"v1.2.0","Name":"25f24110b153246056eccc14a3a4cd81afaff586","Short":"25f24110b153","Time":"2018-02-13T18:13:45Z"} -- go.mod -- module "rsc.io/sampler" require "golang.org/x/text" v0.0.0-20170915032832-14c0d48ead0c -- hello.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Translations by Google Translate. package sampler var hello = newText(` English: en: Hello, world. French: fr: Bonjour le monde. Spanish: es: Hola Mundo. `) -- hello_test.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package sampler import ( "testing" "golang.org/x/text/language" ) var helloTests = []struct { prefs []language.Tag text string }{ { []language.Tag{language.Make("en-US"), language.Make("fr")}, "Hello, world.", }, { []language.Tag{language.Make("fr"), language.Make("en-US")}, "Bonjour la monde.", }, } func TestHello(t *testing.T) { for _, tt := range helloTests { text := Hello(tt.prefs...) if text != tt.text { t.Errorf("Hello(%v) = %q, want %q", tt.prefs, text, tt.text) } } } -- sampler.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package sampler shows simple texts. package sampler // import "rsc.io/sampler" import ( "os" "strings" "golang.org/x/text/language" ) // DefaultUserPrefs returns the default user language preferences. // It consults the $LC_ALL, $LC_MESSAGES, and $LANG environment // variables, in that order. func DefaultUserPrefs() []language.Tag { var prefs []language.Tag for _, k := range []string{"LC_ALL", "LC_MESSAGES", "LANG"} { if env := os.Getenv(k); env != "" { prefs = append(prefs, language.Make(env)) } } return prefs } // Hello returns a localized greeting. // If no prefs are given, Hello uses DefaultUserPrefs. func Hello(prefs ...language.Tag) string { if len(prefs) == 0 { prefs = DefaultUserPrefs() } return hello.find(prefs) } // A text is a localized text. type text struct { byTag map[string]string matcher language.Matcher } // newText creates a new localized text, given a list of translations. func newText(s string) *text { t := &text{ byTag: make(map[string]string), } var tags []language.Tag for _, line := range strings.Split(s, "\n") { line = strings.TrimSpace(line) if line == "" { continue } f := strings.Split(line, ": ") if len(f) != 3 { continue } tag := language.Make(f[1]) tags = append(tags, tag) t.byTag[tag.String()] = f[2] } t.matcher = language.NewMatcher(tags) return t } // find finds the text to use for the given language tag preferences. func (t *text) find(prefs []language.Tag) string { tag, _, _ := t.matcher.Match(prefs...) s := t.byTag[tag.String()] if strings.HasPrefix(s, "RTL ") { s = "\u200F" + strings.TrimPrefix(s, "RTL ") + "\u200E" } return s }
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_quote_v2.0.0.txt
rsc.io/quote@v2.0.0 -- .mod -- module "rsc.io/quote" require "rsc.io/sampler" v1.3.0 -- .info -- {"Version":"v0.0.0-20180709153244-fd906ed3b100","Name":"fd906ed3b100e47181ffa9ec36d82294525c9109","Short":"fd906ed3b100","Time":"2018-07-09T15:32:44Z"} -- go.mod -- module "rsc.io/quote" require "rsc.io/sampler" v1.3.0 -- quote.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package quote collects pithy sayings. package quote // import "rsc.io/quote" import "rsc.io/sampler" // Hello returns a greeting. func HelloV2() string { return sampler.Hello() } // Glass returns a useful phrase for world travelers. func GlassV2() string { // See http://www.oocities.org/nodotus/hbglass.html. return "I can eat glass and it doesn't hurt me." } // Go returns a Go proverb. func GoV2() string { return "Don't communicate by sharing memory, share memory by communicating." } // Opt returns an optimization truth. func OptV2() string { // Wisdom from ken. return "If a program is too slow, it must have a loop." } -- quote_test.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package quote import ( "os" "testing" ) func init() { os.Setenv("LC_ALL", "en") } func TestHello(t *testing.T) { hello := "Hello, world." if out := Hello(); out != hello { t.Errorf("Hello() = %q, want %q", out, hello) } } func TestGlass(t *testing.T) { glass := "I can eat glass and it doesn't hurt me." if out := Glass(); out != glass { t.Errorf("Glass() = %q, want %q", out, glass) } } func TestGo(t *testing.T) { go1 := "Don't communicate by sharing memory, share memory by communicating." if out := Go(); out != go1 { t.Errorf("Go() = %q, want %q", out, go1) } } func TestOpt(t *testing.T) { opt := "If a program is too slow, it must have a loop." if out := Opt(); out != opt { t.Errorf("Opt() = %q, want %q", out, opt) } }
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_quote_v0.0.0-20180214005133-e7a685a342c0.txt
rsc.io/quote@e7a685a342 -- .mod -- module "rsc.io/quote" -- .info -- {"Version":"v0.0.0-20180214005133-e7a685a342c0","Name":"e7a685a342c001acc3eb7f5eafa82980480042c7","Short":"e7a685a342c0","Time":"2018-02-14T00:51:33Z"} -- go.mod -- module "rsc.io/quote" -- quote.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package quote collects pithy sayings. package quote // import "rsc.io/quote" // Hello returns a greeting. func Hello() string { return "Hello, world." } // Glass returns a useful phrase for world travelers. func Glass() string { // See http://www.oocities.org/nodotus/hbglass.html. return "I can eat glass and it doesn't hurt me." } // Go returns a Go proverb. func Go() string { return "Don't communicate by sharing memory, share memory by communicating." } -- quote_test.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package quote import "testing" func TestHello(t *testing.T) { hello := "Hello, world." if out := Hello(); out != hello { t.Errorf("Hello() = %q, want %q", out, hello) } } func TestGlass(t *testing.T) { glass := "I can eat glass and it doesn't hurt me." if out := Glass(); out != glass { t.Errorf("Glass() = %q, want %q", out, glass) } } func TestGo(t *testing.T) { go1 := "Don't communicate by sharing memory. Share memory by communicating." if out := Go(); out != go1 { t.Errorf("Go() = %q, want %q", out, go1) } }
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_badfile4_v1.0.0.txt
rsc.io/badfile4 v1.0.0 written by hand -- .mod -- module rsc.io/badfile4 -- .info -- {"Version":"v1.0.0"} -- go.mod -- module rsc.io/badfile4 -- x/Y.go -- package x -- x/y.go -- package x
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_badmod_v1.0.0.txt
rsc.io/badmod v1.0.0 written by hand -- .mod -- module rsc.io/badmod hello world -- .info -- {"Version":"v1.0.0"} -- x.go -- package x
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_quote_v1.1.0.txt
rsc.io/quote@v1.1.0 -- .mod -- module "rsc.io/quote" -- .info -- {"Version":"v1.1.0","Name":"cfd7145f43f92a8d56b4a3dd603795a3291381a9","Short":"cfd7145f43f9","Time":"2018-02-14T00:46:44Z"} -- go.mod -- module "rsc.io/quote" -- quote.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package quote collects pithy sayings. package quote // import "rsc.io/quote" // Hello returns a greeting. func Hello() string { return "Hello, world." } // Glass returns a useful phrase for world travelers. func Glass() string { // See http://www.oocities.org/nodotus/hbglass.html. return "I can eat glass and it doesn't hurt me." } -- quote_test.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package quote import "testing" func TestHello(t *testing.T) { hello := "Hello, world." if out := Hello(); out != hello { t.Errorf("Hello() = %q, want %q", out, hello) } } func TestGlass(t *testing.T) { glass := "I can eat glass and it doesn't hurt me." if out := Glass(); out != glass { t.Errorf("Glass() = %q, want %q", out, glass) } }
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/example.com_join_subpkg_v1.1.0.txt
Written by hand. Test case for package moved into a parent module. -- .mod -- module example.com/join/subpkg require example.com/join v1.1.0 -- .info -- {"Version": "v1.1.0"}
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_quote_v0.0.0-20180709153244-fd906ed3b100.txt
rsc.io/quote@v2.0.0 -- .mod -- module "rsc.io/quote" require "rsc.io/sampler" v1.3.0 -- .info -- {"Version":"v0.0.0-20180709153244-fd906ed3b100","Name":"fd906ed3b100e47181ffa9ec36d82294525c9109","Short":"fd906ed3b100","Time":"2018-07-09T15:32:44Z"} -- go.mod -- module "rsc.io/quote" require "rsc.io/sampler" v1.3.0 -- quote.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package quote collects pithy sayings. package quote // import "rsc.io/quote" import "rsc.io/sampler" // Hello returns a greeting. func HelloV2() string { return sampler.Hello() } // Glass returns a useful phrase for world travelers. func GlassV2() string { // See http://www.oocities.org/nodotus/hbglass.html. return "I can eat glass and it doesn't hurt me." } // Go returns a Go proverb. func GoV2() string { return "Don't communicate by sharing memory, share memory by communicating." } // Opt returns an optimization truth. func OptV2() string { // Wisdom from ken. return "If a program is too slow, it must have a loop." } -- quote_test.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package quote import ( "os" "testing" ) func init() { os.Setenv("LC_ALL", "en") } func TestHello(t *testing.T) { hello := "Hello, world." if out := Hello(); out != hello { t.Errorf("Hello() = %q, want %q", out, hello) } } func TestGlass(t *testing.T) { glass := "I can eat glass and it doesn't hurt me." if out := Glass(); out != glass { t.Errorf("Glass() = %q, want %q", out, glass) } } func TestGo(t *testing.T) { go1 := "Don't communicate by sharing memory, share memory by communicating." if out := Go(); out != go1 { t.Errorf("Go() = %q, want %q", out, go1) } } func TestOpt(t *testing.T) { opt := "If a program is too slow, it must have a loop." if out := Opt(); out != opt { t.Errorf("Opt() = %q, want %q", out, opt) } }
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_badfile3_v1.0.0.txt
rsc.io/badfile3 v1.0.0 written by hand -- .mod -- module rsc.io/badfile3 -- .info -- {"Version":"v1.0.0"} -- go.mod -- module rsc.io/badfile3 -- x?y.go -- package x
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_quote_v1.3.0.txt
rsc.io/quote@v1.3.0 -- .mod -- module "rsc.io/quote" -- .info -- {"Version":"v1.3.0","Name":"84de74b35823c1e49634f2262f1a58cfc951ebae","Short":"84de74b35823","Time":"2018-02-14T00:54:53Z"} -- go.mod -- module "rsc.io/quote" -- quote.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package quote collects pithy sayings. package quote // import "rsc.io/quote" // Hello returns a greeting. func Hello() string { return "Hello, world." } // Glass returns a useful phrase for world travelers. func Glass() string { // See http://www.oocities.org/nodotus/hbglass.html. return "I can eat glass and it doesn't hurt me." } // Go returns a Go proverb. func Go() string { return "Don't communicate by sharing memory, share memory by communicating." } // Opt returns an optimization truth. func Opt() string { // Wisdom from ken. return "If a program is too slow, it must have a loop." } -- quote_test.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package quote import "testing" func TestHello(t *testing.T) { hello := "Hello, world." if out := Hello(); out != hello { t.Errorf("Hello() = %q, want %q", out, hello) } } func TestGlass(t *testing.T) { glass := "I can eat glass and it doesn't hurt me." if out := Glass(); out != glass { t.Errorf("Glass() = %q, want %q", out, glass) } } func TestGo(t *testing.T) { go1 := "Don't communicate by sharing memory, share memory by communicating." if out := Go(); out != go1 { t.Errorf("Go() = %q, want %q", out, go1) } } func TestOpt(t *testing.T) { opt := "If a program is too slow, it must have a loop." if out := Opt(); out != opt { t.Errorf("Opt() = %q, want %q", out, opt) } }
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_fortune_v2_v2.0.0.txt
rsc.io/fortune v2.0.0 written by hand -- .mod -- module rsc.io/fortune/v2 -- .info -- {"Version":"v2.0.0"} -- fortune.go -- package main import "rsc.io/quote" func main() { println(quote.Hello()) }
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/README
This directory holds Go modules served by a Go module proxy that runs on localhost during tests, both to make tests avoid requiring specific network servers and also to make them significantly faster. A small go get'able test module can be added here by running cd cmd/go/testdata go run addmod.go path@vers where path and vers are the module path and version to add here. For interactive experimentation using this set of modules, run: cd cmd/go go test -proxy=localhost:1234 & export GOPROXY=http://localhost:1234/mod and then run go commands as usual. Modules saved to this directory should be small: a few kilobytes at most. It is acceptable to edit the archives created by addmod.go to remove or shorten files. It is also acceptable to write module archives by hand: they need not be backed by some public git repo. Each module archive is named path_vers.txt, where slashes in path have been replaced with underscores. The archive must contain two files ".info" and ".mod", to be served as the info and mod files in the proxy protocol (see https://research.swtch.com/vgo-module). The remaining files are served as the content of the module zip file. The path@vers prefix required of files in the zip file is added automatically by the proxy: the files in the archive have names without the prefix, like plain "go.mod", "x.go", and so on. See ../addmod.go and ../savedir.go for tools to generate txtar files, although again it is also fine to write them by hand.
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_!q!u!o!t!e_v1.5.3-!p!r!e.txt
rsc.io/QUOTE v1.5.3-PRE (sigh) -- .mod -- module rsc.io/QUOTE require rsc.io/quote v1.5.2 -- .info -- {"Version":"v1.5.3-PRE","Name":"","Short":"","Time":"2018-07-15T16:25:34Z"} -- go.mod -- module rsc.io/QUOTE require rsc.io/quote v1.5.2 -- QUOTE/quote.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // PACKAGE QUOTE COLLECTS LOUD SAYINGS. package QUOTE import ( "strings" "rsc.io/quote" ) // HELLO RETURNS A GREETING. func HELLO() string { return strings.ToUpper(quote.Hello()) } // GLASS RETURNS A USEFUL PHRASE FOR WORLD TRAVELERS. func GLASS() string { return strings.ToUpper(quote.GLASS()) } // GO RETURNS A GO PROVERB. func GO() string { return strings.ToUpper(quote.GO()) } // OPT RETURNS AN OPTIMIZATION TRUTH. func OPT() string { return strings.ToUpper(quote.OPT()) } -- QUOTE/quote_test.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package QUOTE import ( "os" "testing" ) func init() { os.Setenv("LC_ALL", "en") } func TestHELLO(t *testing.T) { hello := "HELLO, WORLD" if out := HELLO(); out != hello { t.Errorf("HELLO() = %q, want %q", out, hello) } } func TestGLASS(t *testing.T) { glass := "I CAN EAT GLASS AND IT DOESN'T HURT ME." if out := GLASS(); out != glass { t.Errorf("GLASS() = %q, want %q", out, glass) } } func TestGO(t *testing.T) { go1 := "DON'T COMMUNICATE BY SHARING MEMORY, SHARE MEMORY BY COMMUNICATING." if out := GO(); out != go1 { t.Errorf("GO() = %q, want %q", out, go1) } } func TestOPT(t *testing.T) { opt := "IF A PROGRAM IS TOO SLOW, IT MUST HAVE A LOOP." if out := OPT(); out != opt { t.Errorf("OPT() = %q, want %q", out, opt) } }
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_testonly_v1.0.0.txt
rsc.io/testonly v1.0.0 written by hand -- .mod -- module rsc.io/testonly -- .info -- {"Version":"v1.0.0"} -- testonly.go -- package testonly
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_fortune_v1.0.0.txt
rsc.io/fortune v1.0.0 written by hand -- .mod -- module rsc.io/fortune -- .info -- {"Version":"v1.0.0"} -- fortune.go -- package main import "rsc.io/quote" func main() { println(quote.Hello()) }
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_quote_v1.4.0.txt
rsc.io/quote@v1.4.0 -- .mod -- module "rsc.io/quote" require "rsc.io/sampler" v1.0.0 -- .info -- {"Version":"v1.4.0","Name":"19e8b977bd2f437798c2cc2dcfe8a1c0f169481b","Short":"19e8b977bd2f","Time":"2018-02-14T00:56:05Z"} -- go.mod -- module "rsc.io/quote" require "rsc.io/sampler" v1.0.0 -- quote.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package quote collects pithy sayings. package quote // import "rsc.io/quote" import "rsc.io/sampler" // Hello returns a greeting. func Hello() string { return sampler.Hello() } // Glass returns a useful phrase for world travelers. func Glass() string { // See http://www.oocities.org/nodotus/hbglass.html. return "I can eat glass and it doesn't hurt me." } // Go returns a Go proverb. func Go() string { return "Don't communicate by sharing memory, share memory by communicating." } // Opt returns an optimization truth. func Opt() string { // Wisdom from ken. return "If a program is too slow, it must have a loop." } -- quote_test.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package quote import "testing" func TestHello(t *testing.T) { hello := "Hello, world." if out := Hello(); out != hello { t.Errorf("Hello() = %q, want %q", out, hello) } } func TestGlass(t *testing.T) { glass := "I can eat glass and it doesn't hurt me." if out := Glass(); out != glass { t.Errorf("Glass() = %q, want %q", out, glass) } } func TestGo(t *testing.T) { go1 := "Don't communicate by sharing memory, share memory by communicating." if out := Go(); out != go1 { t.Errorf("Go() = %q, want %q", out, go1) } } func TestOpt(t *testing.T) { opt := "If a program is too slow, it must have a loop." if out := Opt(); out != opt { t.Errorf("Opt() = %q, want %q", out, opt) } }
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/example.com_join_subpkg_v1.0.0.txt
Written by hand. Test case for package moved into a parent module. -- .mod -- module example.com/join/subpkg -- .info -- {"Version": "v1.0.0"} -- x.go -- package subpkg
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_quote_v1.2.1.txt
rsc.io/quote@v1.2.1 -- .mod -- module "rsc.io/quote" -- .info -- {"Version":"v1.2.1","Name":"5c1f03b64ab7aa958798a569a31924655dc41e76","Short":"5c1f03b64ab7","Time":"2018-02-14T00:54:20Z"} -- go.mod -- module "rsc.io/quote" -- quote.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package quote collects pithy sayings. package quote // import "rsc.io/quote" // Hello returns a greeting. func Hello() string { return "Hello, world." } // Glass returns a useful phrase for world travelers. func Glass() string { // See http://www.oocities.org/nodotus/hbglass.html. return "I can eat glass and it doesn't hurt me." } // Go returns a Go proverb. func Go() string { return "Don't communicate by sharing memory, share memory by communicating." } -- quote_test.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package quote import "testing" func TestHello(t *testing.T) { hello := "Hello, world." if out := Hello(); out != hello { t.Errorf("Hello() = %q, want %q", out, hello) } } func TestGlass(t *testing.T) { glass := "I can eat glass and it doesn't hurt me." if out := Glass(); out != glass { t.Errorf("Glass() = %q, want %q", out, glass) } } func TestGo(t *testing.T) { go1 := "Don't communicate by sharing memory, share memory by communicating." if out := Go(); out != go1 { t.Errorf("Go() = %q, want %q", out, go1) } }
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_quote_v2_v2.0.1.txt
rsc.io/quote/v2@v2.0.1 -- .mod -- module rsc.io/quote/v2 require rsc.io/sampler v1.3.0 -- .info -- {"Version":"v2.0.1","Name":"754f68430672776c84704e2d10209a6ec700cd64","Short":"754f68430672","Time":"2018-07-09T16:25:34Z"} -- go.mod -- module rsc.io/quote/v2 require rsc.io/sampler v1.3.0 -- quote.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package quote collects pithy sayings. package quote // import "rsc.io/quote" import "rsc.io/sampler" // Hello returns a greeting. func HelloV2() string { return sampler.Hello() } // Glass returns a useful phrase for world travelers. func GlassV2() string { // See http://www.oocities.org/nodotus/hbglass.html. return "I can eat glass and it doesn't hurt me." } // Go returns a Go proverb. func GoV2() string { return "Don't communicate by sharing memory, share memory by communicating." } // Opt returns an optimization truth. func OptV2() string { // Wisdom from ken. return "If a program is too slow, it must have a loop." } -- quote_test.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package quote import ( "os" "testing" ) func init() { os.Setenv("LC_ALL", "en") } func TestHello(t *testing.T) { hello := "Hello, world." if out := Hello(); out != hello { t.Errorf("Hello() = %q, want %q", out, hello) } } func TestGlass(t *testing.T) { glass := "I can eat glass and it doesn't hurt me." if out := Glass(); out != glass { t.Errorf("Glass() = %q, want %q", out, glass) } } func TestGo(t *testing.T) { go1 := "Don't communicate by sharing memory, share memory by communicating." if out := Go(); out != go1 { t.Errorf("Go() = %q, want %q", out, go1) } } func TestOpt(t *testing.T) { opt := "If a program is too slow, it must have a loop." if out := Opt(); out != opt { t.Errorf("Opt() = %q, want %q", out, opt) } }
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_badfile5_v1.0.0.txt
rsc.io/badfile5 v1.0.0 written by hand -- .mod -- module rsc.io/badfile5 -- .info -- {"Version":"v1.0.0"} -- go.mod -- module rsc.io/badfile5 -- x/y/z/w.go -- package z -- x/Y/zz/ww.go -- package zz
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_sampler_v1.3.1.txt
rsc.io/sampler@v1.3.1 -- .mod -- module "rsc.io/sampler" require "golang.org/x/text" v0.0.0-20170915032832-14c0d48ead0c -- .info -- {"Version":"v1.3.1","Name":"f545d0289d06e2add4556ea6a15fc4938014bf87","Short":"f545d0289d06","Time":"2018-02-14T16:34:12Z"} -- glass.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Translations from Frank da Cruz, Ethan Mollick, and many others. // See http://kermitproject.org/utf8.html. // http://www.oocities.org/nodotus/hbglass.html // https://en.wikipedia.org/wiki/I_Can_Eat_Glass package sampler var glass = newText(` English: en: I can eat glass and it doesn't hurt me. French: fr: Je peux manger du verre, ça ne me fait pas mal. Spanish: es: Puedo comer vidrio, no me hace daño. `) -- glass_test.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package sampler import ( "testing" "golang.org/x/text/language" ) var glassTests = []struct { prefs []language.Tag text string }{ { []language.Tag{language.Make("en-US"), language.Make("fr")}, "I can eat glass and it doesn't hurt me.", }, { []language.Tag{language.Make("fr"), language.Make("en-US")}, "Je peux manger du verre, ça ne me fait pas mal.", }, } func TestGlass(t *testing.T) { for _, tt := range glassTests { text := Glass(tt.prefs...) if text != tt.text { t.Errorf("Glass(%v) = %q, want %q", tt.prefs, text, tt.text) } } } -- go.mod -- module "rsc.io/sampler" require "golang.org/x/text" v0.0.0-20170915032832-14c0d48ead0c -- hello.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Translations by Google Translate. package sampler var hello = newText(` English: en: Hello, world. French: fr: Bonjour le monde. Spanish: es: Hola Mundo. `) -- hello_test.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package sampler import ( "testing" "golang.org/x/text/language" ) var helloTests = []struct { prefs []language.Tag text string }{ { []language.Tag{language.Make("en-US"), language.Make("fr")}, "Hello, world.", }, { []language.Tag{language.Make("fr"), language.Make("en-US")}, "Bonjour le monde.", }, } func TestHello(t *testing.T) { for _, tt := range helloTests { text := Hello(tt.prefs...) if text != tt.text { t.Errorf("Hello(%v) = %q, want %q", tt.prefs, text, tt.text) } } } -- sampler.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package sampler shows simple texts in a variety of languages. package sampler // import "rsc.io/sampler" import ( "os" "strings" "golang.org/x/text/language" ) // DefaultUserPrefs returns the default user language preferences. // It consults the $LC_ALL, $LC_MESSAGES, and $LANG environment // variables, in that order. func DefaultUserPrefs() []language.Tag { var prefs []language.Tag for _, k := range []string{"LC_ALL", "LC_MESSAGES", "LANG"} { if env := os.Getenv(k); env != "" { prefs = append(prefs, language.Make(env)) } } return prefs } // Hello returns a localized greeting. // If no prefs are given, Hello uses DefaultUserPrefs. func Hello(prefs ...language.Tag) string { if len(prefs) == 0 { prefs = DefaultUserPrefs() } return hello.find(prefs) } // Glass returns a localized silly phrase. // If no prefs are given, Glass uses DefaultUserPrefs. func Glass(prefs ...language.Tag) string { if len(prefs) == 0 { prefs = DefaultUserPrefs() } return glass.find(prefs) } // A text is a localized text. type text struct { byTag map[string]string matcher language.Matcher } // newText creates a new localized text, given a list of translations. func newText(s string) *text { t := &text{ byTag: make(map[string]string), } var tags []language.Tag for _, line := range strings.Split(s, "\n") { line = strings.TrimSpace(line) if line == "" { continue } f := strings.Split(line, ": ") if len(f) != 3 { continue } tag := language.Make(f[1]) tags = append(tags, tag) t.byTag[tag.String()] = f[2] } t.matcher = language.NewMatcher(tags) return t } // find finds the text to use for the given language tag preferences. func (t *text) find(prefs []language.Tag) string { tag, _, _ := t.matcher.Match(prefs...) s := t.byTag[tag.String()] if strings.HasPrefix(s, "RTL ") { s = "\u200F" + strings.TrimPrefix(s, "RTL ") + "\u200E" } return s }
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_quote_v0.0.0-20180628003336-dd9747d19b04.txt
rsc.io/quote@dd9747d -- .mod -- module "rsc.io/quote" require "rsc.io/sampler" v1.3.0 -- .info -- {"Version":"v0.0.0-20180628003336-dd9747d19b04","Name":"dd9747d19b041365fbddf0399ddba6bff5eb1b3e","Short":"dd9747d19b04","Time":"2018-06-28T00:33:36Z"} -- buggy/buggy_test.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package buggy import "testing" func Test(t *testing.T) { t.Fatal("buggy!") } -- go.mod -- module "rsc.io/quote" require "rsc.io/sampler" v1.3.0 -- quote.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package quote collects pithy sayings. package quote // import "rsc.io/quote" import "rsc.io/sampler" AN EVEN WORSE CHANGE! // Hello returns a greeting. func Hello() string { return sampler.Hello() } // Glass returns a useful phrase for world travelers. func Glass() string { // See http://www.oocities.org/nodotus/hbglass.html. return "I can eat glass and it doesn't hurt me." } // Go returns a Go proverb. func Go() string { return "Don't communicate by sharing memory, share memory by communicating." } // Opt returns an optimization truth. func Opt() string { // Wisdom from ken. return "If a program is too slow, it must have a loop." } -- quote_test.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package quote import ( "os" "testing" ) func init() { os.Setenv("LC_ALL", "en") } func TestHello(t *testing.T) { hello := "Hello, world." if out := Hello(); out != hello { t.Errorf("Hello() = %q, want %q", out, hello) } } func TestGlass(t *testing.T) { glass := "I can eat glass and it doesn't hurt me." if out := Glass(); out != glass { t.Errorf("Glass() = %q, want %q", out, glass) } } func TestGo(t *testing.T) { go1 := "Don't communicate by sharing memory, share memory by communicating." if out := Go(); out != go1 { t.Errorf("Go() = %q, want %q", out, go1) } } func TestOpt(t *testing.T) { opt := "If a program is too slow, it must have a loop." if out := Opt(); out != opt { t.Errorf("Opt() = %q, want %q", out, opt) } }
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/golang.org_x_internal_v0.1.0.txt
written by hand — loosely derived from golang.org/x/crypto/internal/subtle, but splitting the internal package across a module boundary -- .mod -- module golang.org/x/internal -- .info -- {"Version":"v0.1.0","Name":"","Short":"","Time":"2018-07-25T17:24:00Z"} -- go.mod -- module golang.org/x/internal -- subtle/aliasing.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build !appengine // This is a tiny version of golang.org/x/crypto/internal/subtle. package subtle import "unsafe" func AnyOverlap(x, y []byte) bool { return len(x) > 0 && len(y) > 0 && uintptr(unsafe.Pointer(&x[0])) <= uintptr(unsafe.Pointer(&y[len(y)-1])) && uintptr(unsafe.Pointer(&y[0])) <= uintptr(unsafe.Pointer(&x[len(x)-1])) } -- subtle/aliasing_appengine.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build appengine package subtle import "reflect" func AnyOverlap(x, y []byte) bool { return len(x) > 0 && len(y) > 0 && reflect.ValueOf(&x[0]).Pointer() <= reflect.ValueOf(&y[len(y)-1]).Pointer() && reflect.ValueOf(&y[0]).Pointer() <= reflect.ValueOf(&x[len(x)-1]).Pointer() }
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_quote_v0.0.0-20180709162816-fe488b867524.txt
rsc.io/quote@v0.0.0-20180709162816-fe488b867524 -- .mod -- module rsc.io/quote require ( rsc.io/quote/v2 v2.0.1 rsc.io/sampler v1.3.0 ) -- .info -- {"Version":"v0.0.0-20180709162816-fe488b867524","Name":"fe488b867524806e861c3f4f43ae6946a42ca3f1","Short":"fe488b867524","Time":"2018-07-09T16:28:16Z"} -- buggy/buggy_test.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package buggy import "testing" func Test(t *testing.T) { t.Fatal("buggy!") } -- go.mod -- module rsc.io/quote require ( rsc.io/quote/v2 v2.0.1 rsc.io/sampler v1.3.0 ) -- quote.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package quote collects pithy sayings. package quote // import "rsc.io/quote" import "rsc.io/quote/v2" // Hello returns a greeting. func Hello() string { return quote.HelloV2() } // Glass returns a useful phrase for world travelers. func Glass() string { // See http://www.oocities.org/nodotus/hbglass.html. return quote.GlassV2() } // Go returns a Go proverb. func Go() string { return quote.GoV2() } // Opt returns an optimization truth. func Opt() string { // Wisdom from ken. return quote.OptV2() } -- quote_test.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package quote import ( "os" "testing" ) func init() { os.Setenv("LC_ALL", "en") } func TestHello(t *testing.T) { hello := "Hello, world." if out := Hello(); out != hello { t.Errorf("Hello() = %q, want %q", out, hello) } } func TestGlass(t *testing.T) { glass := "I can eat glass and it doesn't hurt me." if out := Glass(); out != glass { t.Errorf("Glass() = %q, want %q", out, glass) } } func TestGo(t *testing.T) { go1 := "Don't communicate by sharing memory, share memory by communicating." if out := Go(); out != go1 { t.Errorf("Go() = %q, want %q", out, go1) } } func TestOpt(t *testing.T) { opt := "If a program is too slow, it must have a loop." if out := Opt(); out != opt { t.Errorf("Opt() = %q, want %q", out, opt) } }
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_sampler_v1.0.0.txt
rsc.io/sampler@v1.0.0 -- .mod -- module "rsc.io/sampler" -- .info -- {"Version":"v1.0.0","Name":"60bef405c52117ad21d2adb10872b95cf17f8fca","Short":"60bef405c521","Time":"2018-02-13T18:05:54Z"} -- go.mod -- module "rsc.io/sampler" -- sampler.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package sampler shows simple texts. package sampler // import "rsc.io/sampler" // Hello returns a greeting. func Hello() string { return "Hello, world." }
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_badfile1_v1.0.0.txt
rsc.io/badfile1 v1.0.0 written by hand this is part of the badfile test but is a valid zip file. -- .mod -- module rsc.io/badfile1 -- .info -- {"Version":"v1.0.0"} -- go.mod -- module rsc.io/badfile1 -- α.go -- package α -- .gitignore -- -- x/y/z/.gitignore --
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/golang.org_x_useinternal_v0.1.0.txt
written by hand — uses an internal package from another module (https://golang.org/s/go14internal) -- .mod -- module golang.org/x/useinternal -- .info -- {"Version":"v0.1.0","Name":"","Short":"","Time":"2018-07-25T17:24:00Z"} -- go.mod -- module golang.org/x/useinternal -- useinternal.go -- package useinternal import _ "golang.org/x/internal/subtle"
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_quote_v1.5.3-pre1.txt
rsc.io/quote@v1.5.3-pre1 -- .mod -- module "rsc.io/quote" require "rsc.io/sampler" v1.3.0 -- .info -- {"Version":"v1.5.3-pre1","Name":"2473dfd877c95382420e47686aa9076bf58c79e0","Short":"2473dfd877c9","Time":"2018-06-28T00:32:53Z"} -- buggy/buggy_test.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package buggy import "testing" func Test(t *testing.T) { t.Fatal("buggy!") } -- go.mod -- module "rsc.io/quote" require "rsc.io/sampler" v1.3.0 -- quote.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package quote collects pithy sayings. package quote // import "rsc.io/quote" import "rsc.io/sampler" // A CHANGE! // Hello returns a greeting. func Hello() string { return sampler.Hello() } // Glass returns a useful phrase for world travelers. func Glass() string { // See http://www.oocities.org/nodotus/hbglass.html. return "I can eat glass and it doesn't hurt me." } // Go returns a Go proverb. func Go() string { return "Don't communicate by sharing memory, share memory by communicating." } // Opt returns an optimization truth. func Opt() string { // Wisdom from ken. return "If a program is too slow, it must have a loop." } -- quote_test.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package quote import ( "os" "testing" ) func init() { os.Setenv("LC_ALL", "en") } func TestHello(t *testing.T) { hello := "Hello, world." if out := Hello(); out != hello { t.Errorf("Hello() = %q, want %q", out, hello) } } func TestGlass(t *testing.T) { glass := "I can eat glass and it doesn't hurt me." if out := Glass(); out != glass { t.Errorf("Glass() = %q, want %q", out, glass) } } func TestGo(t *testing.T) { go1 := "Don't communicate by sharing memory, share memory by communicating." if out := Go(); out != go1 { t.Errorf("Go() = %q, want %q", out, go1) } } func TestOpt(t *testing.T) { opt := "If a program is too slow, it must have a loop." if out := Opt(); out != opt { t.Errorf("Opt() = %q, want %q", out, opt) } }
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_!q!u!o!t!e_v1.5.2.txt
rsc.io/QUOTE v1.5.2 -- .mod -- module rsc.io/QUOTE require rsc.io/quote v1.5.2 -- .info -- {"Version":"v1.5.2","Name":"","Short":"","Time":"2018-07-15T16:25:34Z"} -- go.mod -- module rsc.io/QUOTE require rsc.io/quote v1.5.2 -- QUOTE/quote.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // PACKAGE QUOTE COLLECTS LOUD SAYINGS. package QUOTE import ( "strings" "rsc.io/quote" ) // HELLO RETURNS A GREETING. func HELLO() string { return strings.ToUpper(quote.Hello()) } // GLASS RETURNS A USEFUL PHRASE FOR WORLD TRAVELERS. func GLASS() string { return strings.ToUpper(quote.GLASS()) } // GO RETURNS A GO PROVERB. func GO() string { return strings.ToUpper(quote.GO()) } // OPT RETURNS AN OPTIMIZATION TRUTH. func OPT() string { return strings.ToUpper(quote.OPT()) } -- QUOTE/quote_test.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package QUOTE import ( "os" "testing" ) func init() { os.Setenv("LC_ALL", "en") } func TestHELLO(t *testing.T) { hello := "HELLO, WORLD" if out := HELLO(); out != hello { t.Errorf("HELLO() = %q, want %q", out, hello) } } func TestGLASS(t *testing.T) { glass := "I CAN EAT GLASS AND IT DOESN'T HURT ME." if out := GLASS(); out != glass { t.Errorf("GLASS() = %q, want %q", out, glass) } } func TestGO(t *testing.T) { go1 := "DON'T COMMUNICATE BY SHARING MEMORY, SHARE MEMORY BY COMMUNICATING." if out := GO(); out != go1 { t.Errorf("GO() = %q, want %q", out, go1) } } func TestOPT(t *testing.T) { opt := "IF A PROGRAM IS TOO SLOW, IT MUST HAVE A LOOP." if out := OPT(); out != opt { t.Errorf("OPT() = %q, want %q", out, opt) } }
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_quote_v0.0.0-20180709160352-0d003b9c4bfa.txt
rsc.io/quote@v0.0.0-20180709160352-0d003b9c4bfa -- .mod -- module rsc.io/quote require rsc.io/sampler v1.3.0 -- .info -- {"Version":"v0.0.0-20180709160352-0d003b9c4bfa","Name":"0d003b9c4bfac881641be8eb1598b782a467a97f","Short":"0d003b9c4bfa","Time":"2018-07-09T16:03:52Z"} -- buggy/buggy_test.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package buggy import "testing" func Test(t *testing.T) { t.Fatal("buggy!") } -- go.mod -- module rsc.io/quote require rsc.io/sampler v1.3.0 -- quote.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package quote collects pithy sayings. package quote // import "rsc.io/quote" import "rsc.io/quote/v2" // Hello returns a greeting. func Hello() string { return quote.HelloV2() } // Glass returns a useful phrase for world travelers. func Glass() string { // See http://www.oocities.org/nodotus/hbglass.html. return quote.GlassV2() } // Go returns a Go proverb. func Go() string { return quote.GoV2() } // Opt returns an optimization truth. func Opt() string { // Wisdom from ken. return quote.OptV2() } -- quote_test.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package quote import ( "os" "testing" ) func init() { os.Setenv("LC_ALL", "en") } func TestHello(t *testing.T) { hello := "Hello, world." if out := Hello(); out != hello { t.Errorf("Hello() = %q, want %q", out, hello) } } func TestGlass(t *testing.T) { glass := "I can eat glass and it doesn't hurt me." if out := Glass(); out != glass { t.Errorf("Glass() = %q, want %q", out, glass) } } func TestGo(t *testing.T) { go1 := "Don't communicate by sharing memory, share memory by communicating." if out := Go(); out != go1 { t.Errorf("Go() = %q, want %q", out, go1) } } func TestOpt(t *testing.T) { opt := "If a program is too slow, it must have a loop." if out := Opt(); out != opt { t.Errorf("Opt() = %q, want %q", out, opt) } }
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_quote_v0.0.0-20180709162749-b44a0b17b2d1.txt
rsc.io/quote@v0.0.0-20180709162749-b44a0b17b2d1 -- .mod -- module rsc.io/quote require ( rsc.io/quote/v2 v2.0.1 rsc.io/sampler v1.3.0 ) -- .info -- {"Version":"v0.0.0-20180709162749-b44a0b17b2d1","Name":"b44a0b17b2d1fe4c98a8d0e7a68c9bf9e762799a","Short":"b44a0b17b2d1","Time":"2018-07-09T16:27:49Z"} -- buggy/buggy_test.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package buggy import "testing" func Test(t *testing.T) { t.Fatal("buggy!") } -- go.mod -- module rsc.io/quote require ( rsc.io/quote/v2 v2.0.1 rsc.io/sampler v1.3.0 ) -- quote.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package quote collects pithy sayings. package quote // import "rsc.io/quote" import "rsc.io/quote/v2" // Hello returns a greeting. func Hello() string { return quote.HelloV2() } // Glass returns a useful phrase for world travelers. func Glass() string { // See http://www.oocities.org/nodotus/hbglass.html. return quote.GlassV2() } // Go returns a Go proverb. func Go() string { return quote.GoV2() } // Opt returns an optimization truth. func Opt() string { // Wisdom from ken. return quote.OptV2() } -- quote_test.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package quote import ( "os" "testing" ) func init() { os.Setenv("LC_ALL", "en") } func TestHello(t *testing.T) { hello := "Hello, world." if out := Hello(); out != hello { t.Errorf("Hello() = %q, want %q", out, hello) } } func TestGlass(t *testing.T) { glass := "I can eat glass and it doesn't hurt me." if out := Glass(); out != glass { t.Errorf("Glass() = %q, want %q", out, glass) } } func TestGo(t *testing.T) { go1 := "Don't communicate by sharing memory, share memory by communicating." if out := Go(); out != go1 { t.Errorf("Go() = %q, want %q", out, go1) } } func TestOpt(t *testing.T) { opt := "If a program is too slow, it must have a loop." if out := Opt(); out != opt { t.Errorf("Opt() = %q, want %q", out, opt) } }
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/example.com_v1.0.0.txt
Written by hand. Test case for module at root of domain. -- .mod -- module example.com -- .info -- {"Version": "v1.0.0"} -- x.go -- package x
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/golang.org_x_text_v0.3.0.txt
written by hand - just enough to compile rsc.io/sampler, rsc.io/quote -- .mod -- module golang.org/x/text -- .info -- {"Version":"v0.3.0","Name":"","Short":"","Time":"2017-09-16T03:28:32Z"} -- go.mod -- module golang.org/x/text -- unused/unused.go -- package unused -- language/lang.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // This is a tiny version of golang.org/x/text. package language import "strings" type Tag string func Make(s string) Tag { return Tag(s) } func (t Tag) String() string { return string(t) } func NewMatcher(tags []Tag) Matcher { return &matcher{tags} } type Matcher interface { Match(...Tag) (Tag, int, int) } type matcher struct { tags []Tag } func (m *matcher) Match(prefs ...Tag) (Tag, int, int) { for _, pref := range prefs { for _, tag := range m.tags { if tag == pref || strings.HasPrefix(string(pref), string(tag+"-")) || strings.HasPrefix(string(tag), string(pref+"-")) { return tag, 0, 0 } } } return m.tags[0], 0, 0 }
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_sampler_v1.2.1.txt
generated by ./addmod.bash rsc.io/sampler@v1.2.1 -- .mod -- module "rsc.io/sampler" require "golang.org/x/text" v0.0.0-20170915032832-14c0d48ead0c -- .info -- {"Version":"v1.2.1","Name":"cac3af4f8a0ab40054fa6f8d423108a63a1255bb","Short":"cac3af4f8a0a","Time":"2018-02-13T18:16:22Z"}EOF -- hello.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Translations by Google Translate. package sampler var hello = newText(` English: en: Hello, world. French: fr: Bonjour le monde. Spanish: es: Hola Mundo. `) -- hello_test.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package sampler import ( "testing" "golang.org/x/text/language" ) var helloTests = []struct { prefs []language.Tag text string }{ { []language.Tag{language.Make("en-US"), language.Make("fr")}, "Hello, world.", }, { []language.Tag{language.Make("fr"), language.Make("en-US")}, "Bonjour le monde.", }, } func TestHello(t *testing.T) { for _, tt := range helloTests { text := Hello(tt.prefs...) if text != tt.text { t.Errorf("Hello(%v) = %q, want %q", tt.prefs, text, tt.text) } } } -- sampler.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package sampler shows simple texts. package sampler // import "rsc.io/sampler" import ( "os" "strings" "golang.org/x/text/language" ) // DefaultUserPrefs returns the default user language preferences. // It consults the $LC_ALL, $LC_MESSAGES, and $LANG environment // variables, in that order. func DefaultUserPrefs() []language.Tag { var prefs []language.Tag for _, k := range []string{"LC_ALL", "LC_MESSAGES", "LANG"} { if env := os.Getenv(k); env != "" { prefs = append(prefs, language.Make(env)) } } return prefs } // Hello returns a localized greeting. // If no prefs are given, Hello uses DefaultUserPrefs. func Hello(prefs ...language.Tag) string { if len(prefs) == 0 { prefs = DefaultUserPrefs() } return hello.find(prefs) } // A text is a localized text. type text struct { byTag map[string]string matcher language.Matcher } // newText creates a new localized text, given a list of translations. func newText(s string) *text { t := &text{ byTag: make(map[string]string), } var tags []language.Tag for _, line := range strings.Split(s, "\n") { line = strings.TrimSpace(line) if line == "" { continue } f := strings.Split(line, ": ") if len(f) != 3 { continue } tag := language.Make(f[1]) tags = append(tags, tag) t.byTag[tag.String()] = f[2] } t.matcher = language.NewMatcher(tags) return t } // find finds the text to use for the given language tag preferences. func (t *text) find(prefs []language.Tag) string { tag, _, _ := t.matcher.Match(prefs...) s := t.byTag[tag.String()] if strings.HasPrefix(s, "RTL ") { s = "\u200F" + strings.TrimPrefix(s, "RTL ") + "\u200E" } return s }
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_quote_v1.5.1.txt
rsc.io/quote@23179ee8a569 -- .mod -- module "rsc.io/quote" require "rsc.io/sampler" v1.3.0 -- .info -- {"Version":"v1.5.1","Name":"23179ee8a569bb05d896ae05c6503ec69a19f99f","Short":"23179ee8a569","Time":"2018-02-14T00:58:40Z"} -- go.mod -- module "rsc.io/quote" require "rsc.io/sampler" v1.3.0 -- quote.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package quote collects pithy sayings. package quote // import "rsc.io/quote" import "rsc.io/sampler" // Hello returns a greeting. func Hello() string { return sampler.Hello() } // Glass returns a useful phrase for world travelers. func Glass() string { // See http://www.oocities.org/nodotus/hbglass.html. return "I can eat glass and it doesn't hurt me." } // Go returns a Go proverb. func Go() string { return "Don't communicate by sharing memory, share memory by communicating." } // Opt returns an optimization truth. func Opt() string { // Wisdom from ken. return "If a program is too slow, it must have a loop." } -- quote_test.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package quote import ( "os" "testing" ) func init() { os.Setenv("LC_ALL", "en") } func TestHello(t *testing.T) { hello := "Hello, world." if out := Hello(); out != hello { t.Errorf("Hello() = %q, want %q", out, hello) } } func TestGlass(t *testing.T) { glass := "I can eat glass and it doesn't hurt me." if out := Glass(); out != glass { t.Errorf("Glass() = %q, want %q", out, glass) } } func TestGo(t *testing.T) { go1 := "Don't communicate by sharing memory, share memory by communicating." if out := Go(); out != go1 { t.Errorf("Go() = %q, want %q", out, go1) } } func TestOpt(t *testing.T) { opt := "If a program is too slow, it must have a loop." if out := Opt(); out != opt { t.Errorf("Opt() = %q, want %q", out, opt) } }
mod
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/mod/rsc.io_quote_v1.2.0.txt
rsc.io/quote@v1.2.0 -- .mod -- module "rsc.io/quote" -- .info -- {"Version":"v1.2.0","Name":"d8a3de91045c932a1c71e545308fe97571d6d65c","Short":"d8a3de91045c","Time":"2018-02-14T00:47:51Z"} -- go.mod -- module "rsc.io/quote" -- quote.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package quote collects pithy sayings. package quote // import "rsc.io/quote" // Hello returns a greeting. func Hello() string { return "Hello, world." } // Glass returns a useful phrase for world travelers. func Glass() string { // See http://www.oocities.org/nodotus/hbglass.html. return "I can eat glass and it doesn't hurt me." } // Go returns a Go proverb. func Go() string { return "Don't communicate by sharing memory, share memory by communicating." } -- quote_test.go -- // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package quote import "testing" func TestHello(t *testing.T) { hello := "Hello, world." if out := Hello(); out != hello { t.Errorf("Hello() = %q, want %q", out, hello) } } func TestGlass(t *testing.T) { glass := "I can eat glass and it doesn't hurt me." if out := Glass(); out != glass { t.Errorf("Glass() = %q, want %q", out, glass) } } // Go returns a Go proverb. func TestGo(t *testing.T) { go1 := "Don't communicate by sharing memory. Share memory by communicating." if out := Go(); out != go1 { t.Errorf("Go() = %q, want %q", out, go1) } }
testinternal
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/testinternal/p.go
package p import _ "net/http/internal"
local
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/local/hard.go
package main import "./sub" func main() { sub.Hello() }
local
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/local/easy.go
package main import "./easysub" func main() { easysub.Hello() }
sub
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/local/sub/sub.go
package sub import ( "fmt" subsub "./sub" ) func Hello() { fmt.Println("sub.Hello") subsub.Hello() }
sub
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/local/sub/sub/subsub.go
package subsub import "fmt" func Hello() { fmt.Println("subsub.Hello") }
easysub
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/local/easysub/easysub.go
package easysub import "fmt" func Hello() { fmt.Println("easysub.Hello") }
easysub
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/local/easysub/main.go
// +build ignore package main import "." func main() { easysub.Hello() }
testterminal18153
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/testterminal18153/terminal_test.go
// Copyright 2016 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build linux // This test is run by src/cmd/dist/test.go (cmd_go_test_terminal), // and not by cmd/go's tests. This is because this test requires that // that it be called with its stdout and stderr being a terminal. // dist doesn't run `cmd/go test` against this test directory if // dist's stdout/stderr aren't terminals. // // See issue 18153. package p import ( "syscall" "testing" "unsafe" ) const ioctlReadTermios = syscall.TCGETS // isTerminal reports whether fd is a terminal. func isTerminal(fd uintptr) bool { var termios syscall.Termios _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) return err == 0 } func TestIsTerminal(t *testing.T) { if !isTerminal(1) { t.Errorf("stdout is not a terminal") } if !isTerminal(2) { t.Errorf("stderr is not a terminal") } }
failssh
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/failssh/ssh
#!/bin/sh exit 1
x
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/testvendor2/vendor/x/x.go
package x
p
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/testvendor2/src/p/p.go
package p import "x"
norunexample
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/norunexample/example_test.go
package pkg_test import "os" func init() { os.Stdout.Write([]byte("File with non-runnable example was built.\n")) } func Example_test() { // This test will not be run, it has no "Output:" comment. }
norunexample
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/norunexample/test_test.go
package pkg import ( "os" "testing" ) func TestBuilt(t *testing.T) { os.Stdout.Write([]byte("A normal test was executed.\n")) }
testonly2
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/testdata/testonly2/t.go
// This package is not a test-only package, // but it still matches the pattern ./testdata/testonly... when in cmd/go. package main func main() {}
vet
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/internal/vet/vet.go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package vet implements the ``go vet'' command. package vet import ( "cmd/go/internal/base" "cmd/go/internal/load" "cmd/go/internal/modload" "cmd/go/internal/work" "path/filepath" ) var CmdVet = &base.Command{ Run: runVet, CustomFlags: true, UsageLine: "go vet [-n] [-x] [build flags] [vet flags] [packages]", Short: "report likely mistakes in packages", Long: ` Vet runs the Go vet command on the packages named by the import paths. For more about vet and its flags, see 'go doc cmd/vet'. For more about specifying packages, see 'go help packages'. The -n flag prints commands that would be executed. The -x flag prints commands as they are executed. The build flags supported by go vet are those that control package resolution and execution, such as -n, -x, -v, -tags, and -toolexec. For more about these flags, see 'go help build'. See also: go fmt, go fix. `, } func runVet(cmd *base.Command, args []string) { modload.LoadTests = true vetFlags, pkgArgs := vetFlags(args) work.BuildInit() work.VetFlags = vetFlags if vetTool != "" { var err error work.VetTool, err = filepath.Abs(vetTool) if err != nil { base.Fatalf("%v", err) } } pkgs := load.PackagesForBuild(pkgArgs) if len(pkgs) == 0 { base.Fatalf("no packages to vet") } var b work.Builder b.Init() root := &work.Action{Mode: "go vet"} for _, p := range pkgs { _, ptest, pxtest, err := load.TestPackagesFor(p, nil) if err != nil { base.Errorf("%v", err) continue } if len(ptest.GoFiles) == 0 && len(ptest.CgoFiles) == 0 && pxtest == nil { base.Errorf("go vet %s: no Go files in %s", p.ImportPath, p.Dir) continue } if len(ptest.GoFiles) > 0 || len(ptest.CgoFiles) > 0 { root.Deps = append(root.Deps, b.VetAction(work.ModeBuild, work.ModeBuild, ptest)) } if pxtest != nil { root.Deps = append(root.Deps, b.VetAction(work.ModeBuild, work.ModeBuild, pxtest)) } } b.Do(root) }
vet
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/internal/vet/vetflag.go
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package vet import ( "flag" "fmt" "os" "strings" "cmd/go/internal/base" "cmd/go/internal/cmdflag" "cmd/go/internal/str" "cmd/go/internal/work" ) const cmd = "vet" // vetFlagDefn is the set of flags we process. var vetFlagDefn = []*cmdflag.Defn{ // Note: Some flags, in particular -tags and -v, are known to // vet but also defined as build flags. This works fine, so we // don't define them here but use AddBuildFlags to init them. // However some, like -x, are known to the build but not // to vet. We handle them in vetFlags. // local. {Name: "all", BoolVar: new(bool), PassToTest: true}, {Name: "asmdecl", BoolVar: new(bool), PassToTest: true}, {Name: "assign", BoolVar: new(bool), PassToTest: true}, {Name: "atomic", BoolVar: new(bool), PassToTest: true}, {Name: "bool", BoolVar: new(bool), PassToTest: true}, {Name: "buildtags", BoolVar: new(bool), PassToTest: true}, {Name: "cgocall", BoolVar: new(bool), PassToTest: true}, {Name: "composites", BoolVar: new(bool), PassToTest: true}, {Name: "copylocks", BoolVar: new(bool), PassToTest: true}, {Name: "httpresponse", BoolVar: new(bool), PassToTest: true}, {Name: "lostcancel", BoolVar: new(bool), PassToTest: true}, {Name: "methods", BoolVar: new(bool), PassToTest: true}, {Name: "nilfunc", BoolVar: new(bool), PassToTest: true}, {Name: "printf", BoolVar: new(bool), PassToTest: true}, {Name: "printfuncs", PassToTest: true}, {Name: "rangeloops", BoolVar: new(bool), PassToTest: true}, {Name: "shadow", BoolVar: new(bool), PassToTest: true}, {Name: "shadowstrict", BoolVar: new(bool), PassToTest: true}, {Name: "shift", BoolVar: new(bool), PassToTest: true}, {Name: "source", BoolVar: new(bool), PassToTest: true}, {Name: "structtags", BoolVar: new(bool), PassToTest: true}, {Name: "tests", BoolVar: new(bool), PassToTest: true}, {Name: "unreachable", BoolVar: new(bool), PassToTest: true}, {Name: "unsafeptr", BoolVar: new(bool), PassToTest: true}, {Name: "unusedfuncs", PassToTest: true}, {Name: "unusedresult", BoolVar: new(bool), PassToTest: true}, {Name: "unusedstringmethods", PassToTest: true}, } var vetTool string // add build flags to vetFlagDefn. func init() { cmdflag.AddKnownFlags("vet", vetFlagDefn) var cmd base.Command work.AddBuildFlags(&cmd) cmd.Flag.StringVar(&vetTool, "vettool", "", "path to vet tool binary") // for cmd/vet tests; undocumented for now cmd.Flag.VisitAll(func(f *flag.Flag) { vetFlagDefn = append(vetFlagDefn, &cmdflag.Defn{ Name: f.Name, Value: f.Value, }) }) } // vetFlags processes the command line, splitting it at the first non-flag // into the list of flags and list of packages. func vetFlags(args []string) (passToVet, packageNames []string) { args = str.StringList(cmdflag.FindGOFLAGS(vetFlagDefn), args) for i := 0; i < len(args); i++ { if !strings.HasPrefix(args[i], "-") { return args[:i], args[i:] } f, value, extraWord := cmdflag.Parse(cmd, vetFlagDefn, args, i) if f == nil { fmt.Fprintf(os.Stderr, "vet: flag %q not defined\n", args[i]) fmt.Fprintf(os.Stderr, "Run \"go help vet\" for more information\n") os.Exit(2) } if f.Value != nil { if err := f.Value.Set(value); err != nil { base.Fatalf("invalid flag argument for -%s: %v", f.Name, err) } keep := f.PassToTest if !keep { // A build flag, probably one we don't want to pass to vet. // Can whitelist. switch f.Name { case "tags", "v": keep = true } } if !keep { // Flags known to the build but not to vet, so must be dropped. if extraWord { args = append(args[:i], args[i+2:]...) extraWord = false } else { args = append(args[:i], args[i+1:]...) } i-- } } if extraWord { i++ } } return args, nil }
par
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/internal/par/work_test.go
// Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package par import ( "sync/atomic" "testing" "time" ) func TestWork(t *testing.T) { var w Work const N = 10000 n := int32(0) w.Add(N) w.Do(100, func(x interface{}) { atomic.AddInt32(&n, 1) i := x.(int) if i >= 2 { w.Add(i - 1) w.Add(i - 2) } w.Add(i >> 1) w.Add((i >> 1) ^ 1) }) if n != N+1 { t.Fatalf("ran %d items, expected %d", n, N+1) } } func TestWorkParallel(t *testing.T) { for tries := 0; tries < 10; tries++ { var w Work const N = 100 for i := 0; i < N; i++ { w.Add(i) } start := time.Now() var n int32 w.Do(N, func(x interface{}) { time.Sleep(1 * time.Millisecond) atomic.AddInt32(&n, +1) }) if n != N { t.Fatalf("par.Work.Do did not do all the work") } if time.Since(start) < N/2*time.Millisecond { return } } t.Fatalf("par.Work.Do does not seem to be parallel") } func TestCache(t *testing.T) { var cache Cache n := 1 v := cache.Do(1, func() interface{} { n++; return n }) if v != 2 { t.Fatalf("cache.Do(1) did not run f") } v = cache.Do(1, func() interface{} { n++; return n }) if v != 2 { t.Fatalf("cache.Do(1) ran f again!") } v = cache.Do(2, func() interface{} { n++; return n }) if v != 3 { t.Fatalf("cache.Do(2) did not run f") } v = cache.Do(1, func() interface{} { n++; return n }) if v != 2 { t.Fatalf("cache.Do(1) did not returned saved value from original cache.Do(1)") } }
par
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/internal/par/work.go
// Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package par implements parallel execution helpers. package par import ( "math/rand" "sync" "sync/atomic" ) // Work manages a set of work items to be executed in parallel, at most once each. // The items in the set must all be valid map keys. type Work struct { f func(interface{}) // function to run for each item running int // total number of runners mu sync.Mutex added map[interface{}]bool // items added to set todo []interface{} // items yet to be run wait sync.Cond // wait when todo is empty waiting int // number of runners waiting for todo } func (w *Work) init() { if w.added == nil { w.added = make(map[interface{}]bool) } } // Add adds item to the work set, if it hasn't already been added. func (w *Work) Add(item interface{}) { w.mu.Lock() w.init() if !w.added[item] { w.added[item] = true w.todo = append(w.todo, item) if w.waiting > 0 { w.wait.Signal() } } w.mu.Unlock() } // Do runs f in parallel on items from the work set, // with at most n invocations of f running at a time. // It returns when everything added to the work set has been processed. // At least one item should have been added to the work set // before calling Do (or else Do returns immediately), // but it is allowed for f(item) to add new items to the set. // Do should only be used once on a given Work. func (w *Work) Do(n int, f func(item interface{})) { if n < 1 { panic("par.Work.Do: n < 1") } if w.running >= 1 { panic("par.Work.Do: already called Do") } w.running = n w.f = f w.wait.L = &w.mu for i := 0; i < n-1; i++ { go w.runner() } w.runner() } // runner executes work in w until both nothing is left to do // and all the runners are waiting for work. // (Then all the runners return.) func (w *Work) runner() { for { // Wait for something to do. w.mu.Lock() for len(w.todo) == 0 { w.waiting++ if w.waiting == w.running { // All done. w.wait.Broadcast() w.mu.Unlock() return } w.wait.Wait() w.waiting-- } // Pick something to do at random, // to eliminate pathological contention // in case items added at about the same time // are most likely to contend. i := rand.Intn(len(w.todo)) item := w.todo[i] w.todo[i] = w.todo[len(w.todo)-1] w.todo = w.todo[:len(w.todo)-1] w.mu.Unlock() w.f(item) } } // Cache runs an action once per key and caches the result. type Cache struct { m sync.Map } type cacheEntry struct { done uint32 mu sync.Mutex result interface{} } // Do calls the function f if and only if Do is being called for the first time with this key. // No call to Do with a given key returns until the one call to f returns. // Do returns the value returned by the one call to f. func (c *Cache) Do(key interface{}, f func() interface{}) interface{} { entryIface, ok := c.m.Load(key) if !ok { entryIface, _ = c.m.LoadOrStore(key, new(cacheEntry)) } e := entryIface.(*cacheEntry) if atomic.LoadUint32(&e.done) == 0 { e.mu.Lock() if atomic.LoadUint32(&e.done) == 0 { e.result = f() atomic.StoreUint32(&e.done, 1) } e.mu.Unlock() } return e.result } // Get returns the cached result associated with key. // It returns nil if there is no such result. // If the result for key is being computed, Get does not wait for the computation to finish. func (c *Cache) Get(key interface{}) interface{} { entryIface, ok := c.m.Load(key) if !ok { return nil } e := entryIface.(*cacheEntry) if atomic.LoadUint32(&e.done) == 0 { return nil } return e.result }
modfile
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/internal/modfile/rule.go
// Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package modfile import ( "bytes" "errors" "fmt" "path/filepath" "regexp" "sort" "strconv" "strings" "unicode" "cmd/go/internal/module" "cmd/go/internal/semver" ) // A File is the parsed, interpreted form of a go.mod file. type File struct { Module *Module Go *Go Require []*Require Exclude []*Exclude Replace []*Replace Syntax *FileSyntax } // A Module is the module statement. type Module struct { Mod module.Version Syntax *Line } // A Go is the go statement. type Go struct { Version string // "1.23" Syntax *Line } // A Require is a single require statement. type Require struct { Mod module.Version Indirect bool // has "// indirect" comment Syntax *Line } // An Exclude is a single exclude statement. type Exclude struct { Mod module.Version Syntax *Line } // A Replace is a single replace statement. type Replace struct { Old module.Version New module.Version Syntax *Line } func (f *File) AddModuleStmt(path string) error { if f.Syntax == nil { f.Syntax = new(FileSyntax) } if f.Module == nil { f.Module = &Module{ Mod: module.Version{Path: path}, Syntax: f.Syntax.addLine(nil, "module", AutoQuote(path)), } } else { f.Module.Mod.Path = path f.Syntax.updateLine(f.Module.Syntax, "module", AutoQuote(path)) } return nil } func (f *File) AddComment(text string) { if f.Syntax == nil { f.Syntax = new(FileSyntax) } f.Syntax.Stmt = append(f.Syntax.Stmt, &CommentBlock{ Comments: Comments{ Before: []Comment{ { Token: text, }, }, }, }) } type VersionFixer func(path, version string) (string, error) // Parse parses the data, reported in errors as being from file, // into a File struct. It applies fix, if non-nil, to canonicalize all module versions found. func Parse(file string, data []byte, fix VersionFixer) (*File, error) { return parseToFile(file, data, fix, true) } // ParseLax is like Parse but ignores unknown statements. // It is used when parsing go.mod files other than the main module, // under the theory that most statement types we add in the future will // only apply in the main module, like exclude and replace, // and so we get better gradual deployments if old go commands // simply ignore those statements when found in go.mod files // in dependencies. func ParseLax(file string, data []byte, fix VersionFixer) (*File, error) { return parseToFile(file, data, fix, false) } func parseToFile(file string, data []byte, fix VersionFixer, strict bool) (*File, error) { fs, err := parse(file, data) if err != nil { return nil, err } f := &File{ Syntax: fs, } var errs bytes.Buffer for _, x := range fs.Stmt { switch x := x.(type) { case *Line: f.add(&errs, x, x.Token[0], x.Token[1:], fix, strict) case *LineBlock: if len(x.Token) > 1 { if strict { fmt.Fprintf(&errs, "%s:%d: unknown block type: %s\n", file, x.Start.Line, strings.Join(x.Token, " ")) } continue } switch x.Token[0] { default: if strict { fmt.Fprintf(&errs, "%s:%d: unknown block type: %s\n", file, x.Start.Line, strings.Join(x.Token, " ")) } continue case "module", "require", "exclude", "replace": for _, l := range x.Line { f.add(&errs, l, x.Token[0], l.Token, fix, strict) } } } } if errs.Len() > 0 { return nil, errors.New(strings.TrimRight(errs.String(), "\n")) } return f, nil } var goVersionRE = regexp.MustCompile(`([1-9][0-9]*)\.(0|[1-9][0-9]*)`) func (f *File) add(errs *bytes.Buffer, line *Line, verb string, args []string, fix VersionFixer, strict bool) { // If strict is false, this module is a dependency. // We ignore all unknown directives as well as main-module-only // directives like replace and exclude. It will work better for // forward compatibility if we can depend on modules that have unknown // statements (presumed relevant only when acting as the main module) // and simply ignore those statements. if !strict { switch verb { case "module", "require", "go": // want these even for dependency go.mods default: return } } switch verb { default: fmt.Fprintf(errs, "%s:%d: unknown directive: %s\n", f.Syntax.Name, line.Start.Line, verb) case "go": if f.Go != nil { fmt.Fprintf(errs, "%s:%d: repeated go statement\n", f.Syntax.Name, line.Start.Line) return } if len(args) != 1 || !goVersionRE.MatchString(args[0]) { fmt.Fprintf(errs, "%s:%d: usage: go 1.23\n", f.Syntax.Name, line.Start.Line) return } f.Go = &Go{Syntax: line} f.Go.Version = args[0] case "module": if f.Module != nil { fmt.Fprintf(errs, "%s:%d: repeated module statement\n", f.Syntax.Name, line.Start.Line) return } f.Module = &Module{Syntax: line} if len(args) != 1 { fmt.Fprintf(errs, "%s:%d: usage: module module/path [version]\n", f.Syntax.Name, line.Start.Line) return } s, err := parseString(&args[0]) if err != nil { fmt.Fprintf(errs, "%s:%d: invalid quoted string: %v\n", f.Syntax.Name, line.Start.Line, err) return } f.Module.Mod = module.Version{Path: s} case "require", "exclude": if len(args) != 2 { fmt.Fprintf(errs, "%s:%d: usage: %s module/path v1.2.3\n", f.Syntax.Name, line.Start.Line, verb) return } s, err := parseString(&args[0]) if err != nil { fmt.Fprintf(errs, "%s:%d: invalid quoted string: %v\n", f.Syntax.Name, line.Start.Line, err) return } old := args[1] v, err := parseVersion(s, &args[1], fix) if err != nil { fmt.Fprintf(errs, "%s:%d: invalid module version %q: %v\n", f.Syntax.Name, line.Start.Line, old, err) return } pathMajor, err := modulePathMajor(s) if err != nil { fmt.Fprintf(errs, "%s:%d: %v\n", f.Syntax.Name, line.Start.Line, err) return } if !module.MatchPathMajor(v, pathMajor) { if pathMajor == "" { pathMajor = "v0 or v1" } fmt.Fprintf(errs, "%s:%d: invalid module: %s should be %s, not %s (%s)\n", f.Syntax.Name, line.Start.Line, s, pathMajor, semver.Major(v), v) return } if verb == "require" { f.Require = append(f.Require, &Require{ Mod: module.Version{Path: s, Version: v}, Syntax: line, Indirect: isIndirect(line), }) } else { f.Exclude = append(f.Exclude, &Exclude{ Mod: module.Version{Path: s, Version: v}, Syntax: line, }) } case "replace": arrow := 2 if len(args) >= 2 && args[1] == "=>" { arrow = 1 } if len(args) < arrow+2 || len(args) > arrow+3 || args[arrow] != "=>" { fmt.Fprintf(errs, "%s:%d: usage: %s module/path [v1.2.3] => other/module v1.4\n\t or %s module/path [v1.2.3] => ../local/directory\n", f.Syntax.Name, line.Start.Line, verb, verb) return } s, err := parseString(&args[0]) if err != nil { fmt.Fprintf(errs, "%s:%d: invalid quoted string: %v\n", f.Syntax.Name, line.Start.Line, err) return } pathMajor, err := modulePathMajor(s) if err != nil { fmt.Fprintf(errs, "%s:%d: %v\n", f.Syntax.Name, line.Start.Line, err) return } var v string if arrow == 2 { old := args[1] v, err = parseVersion(s, &args[1], fix) if err != nil { fmt.Fprintf(errs, "%s:%d: invalid module version %v: %v\n", f.Syntax.Name, line.Start.Line, old, err) return } if !module.MatchPathMajor(v, pathMajor) { if pathMajor == "" { pathMajor = "v0 or v1" } fmt.Fprintf(errs, "%s:%d: invalid module: %s should be %s, not %s (%s)\n", f.Syntax.Name, line.Start.Line, s, pathMajor, semver.Major(v), v) return } } ns, err := parseString(&args[arrow+1]) if err != nil { fmt.Fprintf(errs, "%s:%d: invalid quoted string: %v\n", f.Syntax.Name, line.Start.Line, err) return } nv := "" if len(args) == arrow+2 { if !IsDirectoryPath(ns) { fmt.Fprintf(errs, "%s:%d: replacement module without version must be directory path (rooted or starting with ./ or ../)\n", f.Syntax.Name, line.Start.Line) return } if filepath.Separator == '/' && strings.Contains(ns, `\`) { fmt.Fprintf(errs, "%s:%d: replacement directory appears to be Windows path (on a non-windows system)\n", f.Syntax.Name, line.Start.Line) return } } if len(args) == arrow+3 { old := args[arrow+1] nv, err = parseVersion(ns, &args[arrow+2], fix) if err != nil { fmt.Fprintf(errs, "%s:%d: invalid module version %v: %v\n", f.Syntax.Name, line.Start.Line, old, err) return } if IsDirectoryPath(ns) { fmt.Fprintf(errs, "%s:%d: replacement module directory path %q cannot have version\n", f.Syntax.Name, line.Start.Line, ns) return } } f.Replace = append(f.Replace, &Replace{ Old: module.Version{Path: s, Version: v}, New: module.Version{Path: ns, Version: nv}, Syntax: line, }) } } // isIndirect reports whether line has a "// indirect" comment, // meaning it is in go.mod only for its effect on indirect dependencies, // so that it can be dropped entirely once the effective version of the // indirect dependency reaches the given minimum version. func isIndirect(line *Line) bool { if len(line.Suffix) == 0 { return false } f := strings.Fields(line.Suffix[0].Token) return (len(f) == 2 && f[1] == "indirect" || len(f) > 2 && f[1] == "indirect;") && f[0] == "//" } // setIndirect sets line to have (or not have) a "// indirect" comment. func setIndirect(line *Line, indirect bool) { if isIndirect(line) == indirect { return } if indirect { // Adding comment. if len(line.Suffix) == 0 { // New comment. line.Suffix = []Comment{{Token: "// indirect", Suffix: true}} return } // Insert at beginning of existing comment. com := &line.Suffix[0] space := " " if len(com.Token) > 2 && com.Token[2] == ' ' || com.Token[2] == '\t' { space = "" } com.Token = "// indirect;" + space + com.Token[2:] return } // Removing comment. f := strings.Fields(line.Suffix[0].Token) if len(f) == 2 { // Remove whole comment. line.Suffix = nil return } // Remove comment prefix. com := &line.Suffix[0] i := strings.Index(com.Token, "indirect;") com.Token = "//" + com.Token[i+len("indirect;"):] } // IsDirectoryPath reports whether the given path should be interpreted // as a directory path. Just like on the go command line, relative paths // and rooted paths are directory paths; the rest are module paths. func IsDirectoryPath(ns string) bool { // Because go.mod files can move from one system to another, // we check all known path syntaxes, both Unix and Windows. return strings.HasPrefix(ns, "./") || strings.HasPrefix(ns, "../") || strings.HasPrefix(ns, "/") || strings.HasPrefix(ns, `.\`) || strings.HasPrefix(ns, `..\`) || strings.HasPrefix(ns, `\`) || len(ns) >= 2 && ('A' <= ns[0] && ns[0] <= 'Z' || 'a' <= ns[0] && ns[0] <= 'z') && ns[1] == ':' } // MustQuote reports whether s must be quoted in order to appear as // a single token in a go.mod line. func MustQuote(s string) bool { for _, r := range s { if !unicode.IsPrint(r) || r == ' ' || r == '"' || r == '\'' || r == '`' { return true } } return s == "" || strings.Contains(s, "//") || strings.Contains(s, "/*") } // AutoQuote returns s or, if quoting is required for s to appear in a go.mod, // the quotation of s. func AutoQuote(s string) string { if MustQuote(s) { return strconv.Quote(s) } return s } func parseString(s *string) (string, error) { t := *s if strings.HasPrefix(t, `"`) { var err error if t, err = strconv.Unquote(t); err != nil { return "", err } } else if strings.ContainsAny(t, "\"'`") { // Other quotes are reserved both for possible future expansion // and to avoid confusion. For example if someone types 'x' // we want that to be a syntax error and not a literal x in literal quotation marks. return "", fmt.Errorf("unquoted string cannot contain quote") } *s = AutoQuote(t) return t, nil } func parseVersion(path string, s *string, fix VersionFixer) (string, error) { t, err := parseString(s) if err != nil { return "", err } if fix != nil { var err error t, err = fix(path, t) if err != nil { return "", err } } if v := module.CanonicalVersion(t); v != "" { *s = v return *s, nil } return "", fmt.Errorf("version must be of the form v1.2.3") } func modulePathMajor(path string) (string, error) { _, major, ok := module.SplitPathVersion(path) if !ok { return "", fmt.Errorf("invalid module path") } return major, nil } func (f *File) Format() ([]byte, error) { return Format(f.Syntax), nil } // Cleanup cleans up the file f after any edit operations. // To avoid quadratic behavior, modifications like DropRequire // clear the entry but do not remove it from the slice. // Cleanup cleans out all the cleared entries. func (f *File) Cleanup() { w := 0 for _, r := range f.Require { if r.Mod.Path != "" { f.Require[w] = r w++ } } f.Require = f.Require[:w] w = 0 for _, x := range f.Exclude { if x.Mod.Path != "" { f.Exclude[w] = x w++ } } f.Exclude = f.Exclude[:w] w = 0 for _, r := range f.Replace { if r.Old.Path != "" { f.Replace[w] = r w++ } } f.Replace = f.Replace[:w] f.Syntax.Cleanup() } func (f *File) AddRequire(path, vers string) error { need := true for _, r := range f.Require { if r.Mod.Path == path { if need { r.Mod.Version = vers f.Syntax.updateLine(r.Syntax, "require", AutoQuote(path), vers) need = false } else { f.Syntax.removeLine(r.Syntax) *r = Require{} } } } if need { f.AddNewRequire(path, vers, false) } return nil } func (f *File) AddNewRequire(path, vers string, indirect bool) { line := f.Syntax.addLine(nil, "require", AutoQuote(path), vers) setIndirect(line, indirect) f.Require = append(f.Require, &Require{module.Version{Path: path, Version: vers}, indirect, line}) } func (f *File) SetRequire(req []*Require) { need := make(map[string]string) indirect := make(map[string]bool) for _, r := range req { need[r.Mod.Path] = r.Mod.Version indirect[r.Mod.Path] = r.Indirect } for _, r := range f.Require { if v, ok := need[r.Mod.Path]; ok { r.Mod.Version = v r.Indirect = indirect[r.Mod.Path] } } var newStmts []Expr for _, stmt := range f.Syntax.Stmt { switch stmt := stmt.(type) { case *LineBlock: if len(stmt.Token) > 0 && stmt.Token[0] == "require" { var newLines []*Line for _, line := range stmt.Line { if p, err := parseString(&line.Token[0]); err == nil && need[p] != "" { line.Token[1] = need[p] delete(need, p) setIndirect(line, indirect[p]) newLines = append(newLines, line) } } if len(newLines) == 0 { continue // drop stmt } stmt.Line = newLines } case *Line: if len(stmt.Token) > 0 && stmt.Token[0] == "require" { if p, err := parseString(&stmt.Token[1]); err == nil && need[p] != "" { stmt.Token[2] = need[p] delete(need, p) setIndirect(stmt, indirect[p]) } else { continue // drop stmt } } } newStmts = append(newStmts, stmt) } f.Syntax.Stmt = newStmts for path, vers := range need { f.AddNewRequire(path, vers, indirect[path]) } f.SortBlocks() } func (f *File) DropRequire(path string) error { for _, r := range f.Require { if r.Mod.Path == path { f.Syntax.removeLine(r.Syntax) *r = Require{} } } return nil } func (f *File) AddExclude(path, vers string) error { var hint *Line for _, x := range f.Exclude { if x.Mod.Path == path && x.Mod.Version == vers { return nil } if x.Mod.Path == path { hint = x.Syntax } } f.Exclude = append(f.Exclude, &Exclude{Mod: module.Version{Path: path, Version: vers}, Syntax: f.Syntax.addLine(hint, "exclude", AutoQuote(path), vers)}) return nil } func (f *File) DropExclude(path, vers string) error { for _, x := range f.Exclude { if x.Mod.Path == path && x.Mod.Version == vers { f.Syntax.removeLine(x.Syntax) *x = Exclude{} } } return nil } func (f *File) AddReplace(oldPath, oldVers, newPath, newVers string) error { need := true old := module.Version{Path: oldPath, Version: oldVers} new := module.Version{Path: newPath, Version: newVers} tokens := []string{"replace", AutoQuote(oldPath)} if oldVers != "" { tokens = append(tokens, oldVers) } tokens = append(tokens, "=>", AutoQuote(newPath)) if newVers != "" { tokens = append(tokens, newVers) } var hint *Line for _, r := range f.Replace { if r.Old.Path == oldPath && (oldVers == "" || r.Old.Version == oldVers) { if need { // Found replacement for old; update to use new. r.New = new f.Syntax.updateLine(r.Syntax, tokens...) need = false continue } // Already added; delete other replacements for same. f.Syntax.removeLine(r.Syntax) *r = Replace{} } if r.Old.Path == oldPath { hint = r.Syntax } } if need { f.Replace = append(f.Replace, &Replace{Old: old, New: new, Syntax: f.Syntax.addLine(hint, tokens...)}) } return nil } func (f *File) DropReplace(oldPath, oldVers string) error { for _, r := range f.Replace { if r.Old.Path == oldPath && r.Old.Version == oldVers { f.Syntax.removeLine(r.Syntax) *r = Replace{} } } return nil } func (f *File) SortBlocks() { f.removeDups() // otherwise sorting is unsafe for _, stmt := range f.Syntax.Stmt { block, ok := stmt.(*LineBlock) if !ok { continue } sort.Slice(block.Line, func(i, j int) bool { li := block.Line[i] lj := block.Line[j] for k := 0; k < len(li.Token) && k < len(lj.Token); k++ { if li.Token[k] != lj.Token[k] { return li.Token[k] < lj.Token[k] } } return len(li.Token) < len(lj.Token) }) } } func (f *File) removeDups() { have := make(map[module.Version]bool) kill := make(map[*Line]bool) for _, x := range f.Exclude { if have[x.Mod] { kill[x.Syntax] = true continue } have[x.Mod] = true } var excl []*Exclude for _, x := range f.Exclude { if !kill[x.Syntax] { excl = append(excl, x) } } f.Exclude = excl have = make(map[module.Version]bool) // Later replacements take priority over earlier ones. for i := len(f.Replace) - 1; i >= 0; i-- { x := f.Replace[i] if have[x.Old] { kill[x.Syntax] = true continue } have[x.Old] = true } var repl []*Replace for _, x := range f.Replace { if !kill[x.Syntax] { repl = append(repl, x) } } f.Replace = repl var stmts []Expr for _, stmt := range f.Syntax.Stmt { switch stmt := stmt.(type) { case *Line: if kill[stmt] { continue } case *LineBlock: var lines []*Line for _, line := range stmt.Line { if !kill[line] { lines = append(lines, line) } } stmt.Line = lines if len(lines) == 0 { continue } } stmts = append(stmts, stmt) } f.Syntax.Stmt = stmts }
modfile
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/internal/modfile/gopkgin.go
// Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // TODO: Figure out what gopkg.in should do. package modfile import "strings" // ParseGopkgIn splits gopkg.in import paths into their constituent parts func ParseGopkgIn(path string) (root, repo, major, subdir string, ok bool) { if !strings.HasPrefix(path, "gopkg.in/") { return } f := strings.Split(path, "/") if len(f) >= 2 { if elem, v, ok := dotV(f[1]); ok { root = strings.Join(f[:2], "/") repo = "github.com/go-" + elem + "/" + elem major = v subdir = strings.Join(f[2:], "/") return root, repo, major, subdir, true } } if len(f) >= 3 { if elem, v, ok := dotV(f[2]); ok { root = strings.Join(f[:3], "/") repo = "github.com/" + f[1] + "/" + elem major = v subdir = strings.Join(f[3:], "/") return root, repo, major, subdir, true } } return } func dotV(name string) (elem, v string, ok bool) { i := len(name) - 1 for i >= 0 && '0' <= name[i] && name[i] <= '9' { i-- } if i <= 2 || i+1 >= len(name) || name[i-1] != '.' || name[i] != 'v' || name[i+1] == '0' && len(name) != i+2 { return "", "", false } return name[:i-1], name[i:], true }
modfile
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/internal/modfile/rule_test.go
// Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package modfile import ( "bytes" "fmt" "testing" ) var addRequireTests = []struct { in string path string vers string out string }{ { ` module m require x.y/z v1.2.3 `, "x.y/z", "v1.5.6", ` module m require x.y/z v1.5.6 `, }, { ` module m require x.y/z v1.2.3 `, "x.y/w", "v1.5.6", ` module m require ( x.y/z v1.2.3 x.y/w v1.5.6 ) `, }, { ` module m require x.y/z v1.2.3 require x.y/q/v2 v2.3.4 `, "x.y/w", "v1.5.6", ` module m require x.y/z v1.2.3 require ( x.y/q/v2 v2.3.4 x.y/w v1.5.6 ) `, }, } func TestAddRequire(t *testing.T) { for i, tt := range addRequireTests { t.Run(fmt.Sprintf("#%d", i), func(t *testing.T) { f, err := Parse("in", []byte(tt.in), nil) if err != nil { t.Fatal(err) } g, err := Parse("out", []byte(tt.out), nil) if err != nil { t.Fatal(err) } golden, err := g.Format() if err != nil { t.Fatal(err) } if err := f.AddRequire(tt.path, tt.vers); err != nil { t.Fatal(err) } out, err := f.Format() if err != nil { t.Fatal(err) } if !bytes.Equal(out, golden) { t.Errorf("have:\n%s\nwant:\n%s", out, golden) } }) } }
modfile
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/internal/modfile/read_test.go
// Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package modfile import ( "bytes" "fmt" "io/ioutil" "os" "os/exec" "path/filepath" "reflect" "strings" "testing" ) // exists reports whether the named file exists. func exists(name string) bool { _, err := os.Stat(name) return err == nil } // Test that reading and then writing the golden files // does not change their output. func TestPrintGolden(t *testing.T) { outs, err := filepath.Glob("testdata/*.golden") if err != nil { t.Fatal(err) } for _, out := range outs { testPrint(t, out, out) } } // testPrint is a helper for testing the printer. // It reads the file named in, reformats it, and compares // the result to the file named out. func testPrint(t *testing.T, in, out string) { data, err := ioutil.ReadFile(in) if err != nil { t.Error(err) return } golden, err := ioutil.ReadFile(out) if err != nil { t.Error(err) return } base := "testdata/" + filepath.Base(in) f, err := parse(in, data) if err != nil { t.Error(err) return } ndata := Format(f) if !bytes.Equal(ndata, golden) { t.Errorf("formatted %s incorrectly: diff shows -golden, +ours", base) tdiff(t, string(golden), string(ndata)) return } } func TestParseLax(t *testing.T) { badFile := []byte(`module m surprise attack x y ( z ) exclude v1.2.3 replace <-!!! `) _, err := ParseLax("file", badFile, nil) if err != nil { t.Fatalf("ParseLax did not ignore irrelevant errors: %v", err) } } // Test that when files in the testdata directory are parsed // and printed and parsed again, we get the same parse tree // both times. func TestPrintParse(t *testing.T) { outs, err := filepath.Glob("testdata/*") if err != nil { t.Fatal(err) } for _, out := range outs { data, err := ioutil.ReadFile(out) if err != nil { t.Error(err) continue } base := "testdata/" + filepath.Base(out) f, err := parse(base, data) if err != nil { t.Errorf("parsing original: %v", err) continue } ndata := Format(f) f2, err := parse(base, ndata) if err != nil { t.Errorf("parsing reformatted: %v", err) continue } eq := eqchecker{file: base} if err := eq.check(f, f2); err != nil { t.Errorf("not equal (parse/Format/parse): %v", err) } pf1, err := Parse(base, data, nil) if err != nil { switch base { case "testdata/replace2.in", "testdata/gopkg.in.golden": t.Errorf("should parse %v: %v", base, err) } } if err == nil { pf2, err := Parse(base, ndata, nil) if err != nil { t.Errorf("Parsing reformatted: %v", err) continue } eq := eqchecker{file: base} if err := eq.check(pf1, pf2); err != nil { t.Errorf("not equal (parse/Format/Parse): %v", err) } ndata2, err := pf1.Format() if err != nil { t.Errorf("reformat: %v", err) } pf3, err := Parse(base, ndata2, nil) if err != nil { t.Errorf("Parsing reformatted2: %v", err) continue } eq = eqchecker{file: base} if err := eq.check(pf1, pf3); err != nil { t.Errorf("not equal (Parse/Format/Parse): %v", err) } ndata = ndata2 } if strings.HasSuffix(out, ".in") { golden, err := ioutil.ReadFile(strings.TrimSuffix(out, ".in") + ".golden") if err != nil { t.Error(err) continue } if !bytes.Equal(ndata, golden) { t.Errorf("formatted %s incorrectly: diff shows -golden, +ours", base) tdiff(t, string(golden), string(ndata)) return } } } } // An eqchecker holds state for checking the equality of two parse trees. type eqchecker struct { file string pos Position } // errorf returns an error described by the printf-style format and arguments, // inserting the current file position before the error text. func (eq *eqchecker) errorf(format string, args ...interface{}) error { return fmt.Errorf("%s:%d: %s", eq.file, eq.pos.Line, fmt.Sprintf(format, args...)) } // check checks that v and w represent the same parse tree. // If not, it returns an error describing the first difference. func (eq *eqchecker) check(v, w interface{}) error { return eq.checkValue(reflect.ValueOf(v), reflect.ValueOf(w)) } var ( posType = reflect.TypeOf(Position{}) commentsType = reflect.TypeOf(Comments{}) ) // checkValue checks that v and w represent the same parse tree. // If not, it returns an error describing the first difference. func (eq *eqchecker) checkValue(v, w reflect.Value) error { // inner returns the innermost expression for v. // if v is a non-nil interface value, it returns the concrete // value in the interface. inner := func(v reflect.Value) reflect.Value { for { if v.Kind() == reflect.Interface && !v.IsNil() { v = v.Elem() continue } break } return v } v = inner(v) w = inner(w) if v.Kind() == reflect.Invalid && w.Kind() == reflect.Invalid { return nil } if v.Kind() == reflect.Invalid { return eq.errorf("nil interface became %s", w.Type()) } if w.Kind() == reflect.Invalid { return eq.errorf("%s became nil interface", v.Type()) } if v.Type() != w.Type() { return eq.errorf("%s became %s", v.Type(), w.Type()) } if p, ok := v.Interface().(Expr); ok { eq.pos, _ = p.Span() } switch v.Kind() { default: return eq.errorf("unexpected type %s", v.Type()) case reflect.Bool, reflect.Int, reflect.String: vi := v.Interface() wi := w.Interface() if vi != wi { return eq.errorf("%v became %v", vi, wi) } case reflect.Slice: vl := v.Len() wl := w.Len() for i := 0; i < vl || i < wl; i++ { if i >= vl { return eq.errorf("unexpected %s", w.Index(i).Type()) } if i >= wl { return eq.errorf("missing %s", v.Index(i).Type()) } if err := eq.checkValue(v.Index(i), w.Index(i)); err != nil { return err } } case reflect.Struct: // Fields in struct must match. t := v.Type() n := t.NumField() for i := 0; i < n; i++ { tf := t.Field(i) switch { default: if err := eq.checkValue(v.Field(i), w.Field(i)); err != nil { return err } case tf.Type == posType: // ignore positions case tf.Type == commentsType: // ignore comment assignment } } case reflect.Ptr, reflect.Interface: if v.IsNil() != w.IsNil() { if v.IsNil() { return eq.errorf("unexpected %s", w.Elem().Type()) } return eq.errorf("missing %s", v.Elem().Type()) } if err := eq.checkValue(v.Elem(), w.Elem()); err != nil { return err } } return nil } // diff returns the output of running diff on b1 and b2. func diff(b1, b2 []byte) (data []byte, err error) { f1, err := ioutil.TempFile("", "testdiff") if err != nil { return nil, err } defer os.Remove(f1.Name()) defer f1.Close() f2, err := ioutil.TempFile("", "testdiff") if err != nil { return nil, err } defer os.Remove(f2.Name()) defer f2.Close() f1.Write(b1) f2.Write(b2) data, err = exec.Command("diff", "-u", f1.Name(), f2.Name()).CombinedOutput() if len(data) > 0 { // diff exits with a non-zero status when the files don't match. // Ignore that failure as long as we get output. err = nil } return } // tdiff logs the diff output to t.Error. func tdiff(t *testing.T, a, b string) { data, err := diff([]byte(a), []byte(b)) if err != nil { t.Error(err) return } t.Error(string(data)) } var modulePathTests = []struct { input []byte expected string }{ {input: []byte("module \"github.com/rsc/vgotest\""), expected: "github.com/rsc/vgotest"}, {input: []byte("module github.com/rsc/vgotest"), expected: "github.com/rsc/vgotest"}, {input: []byte("module \"github.com/rsc/vgotest\""), expected: "github.com/rsc/vgotest"}, {input: []byte("module github.com/rsc/vgotest"), expected: "github.com/rsc/vgotest"}, {input: []byte("module `github.com/rsc/vgotest`"), expected: "github.com/rsc/vgotest"}, {input: []byte("module \"github.com/rsc/vgotest/v2\""), expected: "github.com/rsc/vgotest/v2"}, {input: []byte("module github.com/rsc/vgotest/v2"), expected: "github.com/rsc/vgotest/v2"}, {input: []byte("module \"gopkg.in/yaml.v2\""), expected: "gopkg.in/yaml.v2"}, {input: []byte("module gopkg.in/yaml.v2"), expected: "gopkg.in/yaml.v2"}, {input: []byte("module \"gopkg.in/check.v1\"\n"), expected: "gopkg.in/check.v1"}, {input: []byte("module \"gopkg.in/check.v1\n\""), expected: ""}, {input: []byte("module gopkg.in/check.v1\n"), expected: "gopkg.in/check.v1"}, {input: []byte("module \"gopkg.in/check.v1\"\r\n"), expected: "gopkg.in/check.v1"}, {input: []byte("module gopkg.in/check.v1\r\n"), expected: "gopkg.in/check.v1"}, {input: []byte("module \"gopkg.in/check.v1\"\n\n"), expected: "gopkg.in/check.v1"}, {input: []byte("module gopkg.in/check.v1\n\n"), expected: "gopkg.in/check.v1"}, {input: []byte("module \n\"gopkg.in/check.v1\"\n\n"), expected: ""}, {input: []byte("module \ngopkg.in/check.v1\n\n"), expected: ""}, {input: []byte("module \"gopkg.in/check.v1\"asd"), expected: ""}, {input: []byte("module \n\"gopkg.in/check.v1\"\n\n"), expected: ""}, {input: []byte("module \ngopkg.in/check.v1\n\n"), expected: ""}, {input: []byte("module \"gopkg.in/check.v1\"asd"), expected: ""}, {input: []byte("module \nmodule a/b/c "), expected: "a/b/c"}, {input: []byte("module \" \""), expected: " "}, {input: []byte("module "), expected: ""}, {input: []byte("module \" a/b/c \""), expected: " a/b/c "}, {input: []byte("module \"github.com/rsc/vgotest1\" // with a comment"), expected: "github.com/rsc/vgotest1"}, } func TestModulePath(t *testing.T) { for _, test := range modulePathTests { t.Run(string(test.input), func(t *testing.T) { result := ModulePath(test.input) if result != test.expected { t.Fatalf("ModulePath(%q): %s, want %s", string(test.input), result, test.expected) } }) } }
modfile
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/internal/modfile/print.go
// Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Module file printer. package modfile import ( "bytes" "fmt" "strings" ) func Format(f *FileSyntax) []byte { pr := &printer{} pr.file(f) return pr.Bytes() } // A printer collects the state during printing of a file or expression. type printer struct { bytes.Buffer // output buffer comment []Comment // pending end-of-line comments margin int // left margin (indent), a number of tabs } // printf prints to the buffer. func (p *printer) printf(format string, args ...interface{}) { fmt.Fprintf(p, format, args...) } // indent returns the position on the current line, in bytes, 0-indexed. func (p *printer) indent() int { b := p.Bytes() n := 0 for n < len(b) && b[len(b)-1-n] != '\n' { n++ } return n } // newline ends the current line, flushing end-of-line comments. func (p *printer) newline() { if len(p.comment) > 0 { p.printf(" ") for i, com := range p.comment { if i > 0 { p.trim() p.printf("\n") for i := 0; i < p.margin; i++ { p.printf("\t") } } p.printf("%s", strings.TrimSpace(com.Token)) } p.comment = p.comment[:0] } p.trim() p.printf("\n") for i := 0; i < p.margin; i++ { p.printf("\t") } } // trim removes trailing spaces and tabs from the current line. func (p *printer) trim() { // Remove trailing spaces and tabs from line we're about to end. b := p.Bytes() n := len(b) for n > 0 && (b[n-1] == '\t' || b[n-1] == ' ') { n-- } p.Truncate(n) } // file formats the given file into the print buffer. func (p *printer) file(f *FileSyntax) { for _, com := range f.Before { p.printf("%s", strings.TrimSpace(com.Token)) p.newline() } for i, stmt := range f.Stmt { switch x := stmt.(type) { case *CommentBlock: // comments already handled p.expr(x) default: p.expr(x) p.newline() } for _, com := range stmt.Comment().After { p.printf("%s", strings.TrimSpace(com.Token)) p.newline() } if i+1 < len(f.Stmt) { p.newline() } } } func (p *printer) expr(x Expr) { // Emit line-comments preceding this expression. if before := x.Comment().Before; len(before) > 0 { // Want to print a line comment. // Line comments must be at the current margin. p.trim() if p.indent() > 0 { // There's other text on the line. Start a new line. p.printf("\n") } // Re-indent to margin. for i := 0; i < p.margin; i++ { p.printf("\t") } for _, com := range before { p.printf("%s", strings.TrimSpace(com.Token)) p.newline() } } switch x := x.(type) { default: panic(fmt.Errorf("printer: unexpected type %T", x)) case *CommentBlock: // done case *LParen: p.printf("(") case *RParen: p.printf(")") case *Line: sep := "" for _, tok := range x.Token { p.printf("%s%s", sep, tok) sep = " " } case *LineBlock: for _, tok := range x.Token { p.printf("%s ", tok) } p.expr(&x.LParen) p.margin++ for _, l := range x.Line { p.newline() p.expr(l) } p.margin-- p.newline() p.expr(&x.RParen) } // Queue end-of-line comments for printing when we // reach the end of the line. p.comment = append(p.comment, x.Comment().Suffix...) }
modfile
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/internal/modfile/read.go
// Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Module file parser. // This is a simplified copy of Google's buildifier parser. package modfile import ( "bytes" "fmt" "os" "strconv" "strings" "unicode" "unicode/utf8" ) // A Position describes the position between two bytes of input. type Position struct { Line int // line in input (starting at 1) LineRune int // rune in line (starting at 1) Byte int // byte in input (starting at 0) } // add returns the position at the end of s, assuming it starts at p. func (p Position) add(s string) Position { p.Byte += len(s) if n := strings.Count(s, "\n"); n > 0 { p.Line += n s = s[strings.LastIndex(s, "\n")+1:] p.LineRune = 1 } p.LineRune += utf8.RuneCountInString(s) return p } // An Expr represents an input element. type Expr interface { // Span returns the start and end position of the expression, // excluding leading or trailing comments. Span() (start, end Position) // Comment returns the comments attached to the expression. // This method would normally be named 'Comments' but that // would interfere with embedding a type of the same name. Comment() *Comments } // A Comment represents a single // comment. type Comment struct { Start Position Token string // without trailing newline Suffix bool // an end of line (not whole line) comment } // Comments collects the comments associated with an expression. type Comments struct { Before []Comment // whole-line comments before this expression Suffix []Comment // end-of-line comments after this expression // For top-level expressions only, After lists whole-line // comments following the expression. After []Comment } // Comment returns the receiver. This isn't useful by itself, but // a Comments struct is embedded into all the expression // implementation types, and this gives each of those a Comment // method to satisfy the Expr interface. func (c *Comments) Comment() *Comments { return c } // A FileSyntax represents an entire go.mod file. type FileSyntax struct { Name string // file path Comments Stmt []Expr } func (x *FileSyntax) Span() (start, end Position) { if len(x.Stmt) == 0 { return } start, _ = x.Stmt[0].Span() _, end = x.Stmt[len(x.Stmt)-1].Span() return start, end } func (x *FileSyntax) addLine(hint Expr, tokens ...string) *Line { if hint == nil { // If no hint given, add to the last statement of the given type. Loop: for i := len(x.Stmt) - 1; i >= 0; i-- { stmt := x.Stmt[i] switch stmt := stmt.(type) { case *Line: if stmt.Token != nil && stmt.Token[0] == tokens[0] { hint = stmt break Loop } case *LineBlock: if stmt.Token[0] == tokens[0] { hint = stmt break Loop } } } } if hint != nil { for i, stmt := range x.Stmt { switch stmt := stmt.(type) { case *Line: if stmt == hint { // Convert line to line block. stmt.InBlock = true block := &LineBlock{Token: stmt.Token[:1], Line: []*Line{stmt}} stmt.Token = stmt.Token[1:] x.Stmt[i] = block new := &Line{Token: tokens[1:], InBlock: true} block.Line = append(block.Line, new) return new } case *LineBlock: if stmt == hint { new := &Line{Token: tokens[1:], InBlock: true} stmt.Line = append(stmt.Line, new) return new } for j, line := range stmt.Line { if line == hint { // Add new line after hint. stmt.Line = append(stmt.Line, nil) copy(stmt.Line[j+2:], stmt.Line[j+1:]) new := &Line{Token: tokens[1:], InBlock: true} stmt.Line[j+1] = new return new } } } } } new := &Line{Token: tokens} x.Stmt = append(x.Stmt, new) return new } func (x *FileSyntax) updateLine(line *Line, tokens ...string) { if line.InBlock { tokens = tokens[1:] } line.Token = tokens } func (x *FileSyntax) removeLine(line *Line) { line.Token = nil } // Cleanup cleans up the file syntax x after any edit operations. // To avoid quadratic behavior, removeLine marks the line as dead // by setting line.Token = nil but does not remove it from the slice // in which it appears. After edits have all been indicated, // calling Cleanup cleans out the dead lines. func (x *FileSyntax) Cleanup() { w := 0 for _, stmt := range x.Stmt { switch stmt := stmt.(type) { case *Line: if stmt.Token == nil { continue } case *LineBlock: ww := 0 for _, line := range stmt.Line { if line.Token != nil { stmt.Line[ww] = line ww++ } } if ww == 0 { continue } if ww == 1 { // Collapse block into single line. line := &Line{ Comments: Comments{ Before: commentsAdd(stmt.Before, stmt.Line[0].Before), Suffix: commentsAdd(stmt.Line[0].Suffix, stmt.Suffix), After: commentsAdd(stmt.Line[0].After, stmt.After), }, Token: stringsAdd(stmt.Token, stmt.Line[0].Token), } x.Stmt[w] = line w++ continue } stmt.Line = stmt.Line[:ww] } x.Stmt[w] = stmt w++ } x.Stmt = x.Stmt[:w] } func commentsAdd(x, y []Comment) []Comment { return append(x[:len(x):len(x)], y...) } func stringsAdd(x, y []string) []string { return append(x[:len(x):len(x)], y...) } // A CommentBlock represents a top-level block of comments separate // from any rule. type CommentBlock struct { Comments Start Position } func (x *CommentBlock) Span() (start, end Position) { return x.Start, x.Start } // A Line is a single line of tokens. type Line struct { Comments Start Position Token []string InBlock bool End Position } func (x *Line) Span() (start, end Position) { return x.Start, x.End } // A LineBlock is a factored block of lines, like // // require ( // "x" // "y" // ) // type LineBlock struct { Comments Start Position LParen LParen Token []string Line []*Line RParen RParen } func (x *LineBlock) Span() (start, end Position) { return x.Start, x.RParen.Pos.add(")") } // An LParen represents the beginning of a parenthesized line block. // It is a place to store suffix comments. type LParen struct { Comments Pos Position } func (x *LParen) Span() (start, end Position) { return x.Pos, x.Pos.add(")") } // An RParen represents the end of a parenthesized line block. // It is a place to store whole-line (before) comments. type RParen struct { Comments Pos Position } func (x *RParen) Span() (start, end Position) { return x.Pos, x.Pos.add(")") } // An input represents a single input file being parsed. type input struct { // Lexing state. filename string // name of input file, for errors complete []byte // entire input remaining []byte // remaining input token []byte // token being scanned lastToken string // most recently returned token, for error messages pos Position // current input position comments []Comment // accumulated comments endRule int // position of end of current rule // Parser state. file *FileSyntax // returned top-level syntax tree parseError error // error encountered during parsing // Comment assignment state. pre []Expr // all expressions, in preorder traversal post []Expr // all expressions, in postorder traversal } func newInput(filename string, data []byte) *input { return &input{ filename: filename, complete: data, remaining: data, pos: Position{Line: 1, LineRune: 1, Byte: 0}, } } // parse parses the input file. func parse(file string, data []byte) (f *FileSyntax, err error) { in := newInput(file, data) // The parser panics for both routine errors like syntax errors // and for programmer bugs like array index errors. // Turn both into error returns. Catching bug panics is // especially important when processing many files. defer func() { if e := recover(); e != nil { if e == in.parseError { err = in.parseError } else { err = fmt.Errorf("%s:%d:%d: internal error: %v", in.filename, in.pos.Line, in.pos.LineRune, e) } } }() // Invoke the parser. in.parseFile() if in.parseError != nil { return nil, in.parseError } in.file.Name = in.filename // Assign comments to nearby syntax. in.assignComments() return in.file, nil } // Error is called to report an error. // The reason s is often "syntax error". // Error does not return: it panics. func (in *input) Error(s string) { if s == "syntax error" && in.lastToken != "" { s += " near " + in.lastToken } in.parseError = fmt.Errorf("%s:%d:%d: %v", in.filename, in.pos.Line, in.pos.LineRune, s) panic(in.parseError) } // eof reports whether the input has reached end of file. func (in *input) eof() bool { return len(in.remaining) == 0 } // peekRune returns the next rune in the input without consuming it. func (in *input) peekRune() int { if len(in.remaining) == 0 { return 0 } r, _ := utf8.DecodeRune(in.remaining) return int(r) } // peekPrefix reports whether the remaining input begins with the given prefix. func (in *input) peekPrefix(prefix string) bool { // This is like bytes.HasPrefix(in.remaining, []byte(prefix)) // but without the allocation of the []byte copy of prefix. for i := 0; i < len(prefix); i++ { if i >= len(in.remaining) || in.remaining[i] != prefix[i] { return false } } return true } // readRune consumes and returns the next rune in the input. func (in *input) readRune() int { if len(in.remaining) == 0 { in.Error("internal lexer error: readRune at EOF") } r, size := utf8.DecodeRune(in.remaining) in.remaining = in.remaining[size:] if r == '\n' { in.pos.Line++ in.pos.LineRune = 1 } else { in.pos.LineRune++ } in.pos.Byte += size return int(r) } type symType struct { pos Position endPos Position text string } // startToken marks the beginning of the next input token. // It must be followed by a call to endToken, once the token has // been consumed using readRune. func (in *input) startToken(sym *symType) { in.token = in.remaining sym.text = "" sym.pos = in.pos } // endToken marks the end of an input token. // It records the actual token string in sym.text if the caller // has not done that already. func (in *input) endToken(sym *symType) { if sym.text == "" { tok := string(in.token[:len(in.token)-len(in.remaining)]) sym.text = tok in.lastToken = sym.text } sym.endPos = in.pos } // lex is called from the parser to obtain the next input token. // It returns the token value (either a rune like '+' or a symbolic token _FOR) // and sets val to the data associated with the token. // For all our input tokens, the associated data is // val.Pos (the position where the token begins) // and val.Token (the input string corresponding to the token). func (in *input) lex(sym *symType) int { // Skip past spaces, stopping at non-space or EOF. countNL := 0 // number of newlines we've skipped past for !in.eof() { // Skip over spaces. Count newlines so we can give the parser // information about where top-level blank lines are, // for top-level comment assignment. c := in.peekRune() if c == ' ' || c == '\t' || c == '\r' { in.readRune() continue } // Comment runs to end of line. if in.peekPrefix("//") { in.startToken(sym) // Is this comment the only thing on its line? // Find the last \n before this // and see if it's all // spaces from there to here. i := bytes.LastIndex(in.complete[:in.pos.Byte], []byte("\n")) suffix := len(bytes.TrimSpace(in.complete[i+1:in.pos.Byte])) > 0 in.readRune() in.readRune() // Consume comment. for len(in.remaining) > 0 && in.readRune() != '\n' { } in.endToken(sym) sym.text = strings.TrimRight(sym.text, "\n") in.lastToken = "comment" // If we are at top level (not in a statement), hand the comment to // the parser as a _COMMENT token. The grammar is written // to handle top-level comments itself. if !suffix { // Not in a statement. Tell parser about top-level comment. return _COMMENT } // Otherwise, save comment for later attachment to syntax tree. if countNL > 1 { in.comments = append(in.comments, Comment{sym.pos, "", false}) } in.comments = append(in.comments, Comment{sym.pos, sym.text, suffix}) countNL = 1 return _EOL } if in.peekPrefix("/*") { in.Error(fmt.Sprintf("mod files must use // comments (not /* */ comments)")) } // Found non-space non-comment. break } // Found the beginning of the next token. in.startToken(sym) defer in.endToken(sym) // End of file. if in.eof() { in.lastToken = "EOF" return _EOF } // Punctuation tokens. switch c := in.peekRune(); c { case '\n': in.readRune() return c case '(': in.readRune() return c case ')': in.readRune() return c case '"', '`': // quoted string quote := c in.readRune() for { if in.eof() { in.pos = sym.pos in.Error("unexpected EOF in string") } if in.peekRune() == '\n' { in.Error("unexpected newline in string") } c := in.readRune() if c == quote { break } if c == '\\' && quote != '`' { if in.eof() { in.pos = sym.pos in.Error("unexpected EOF in string") } in.readRune() } } in.endToken(sym) return _STRING } // Checked all punctuation. Must be identifier token. if c := in.peekRune(); !isIdent(c) { in.Error(fmt.Sprintf("unexpected input character %#q", c)) } // Scan over identifier. for isIdent(in.peekRune()) { if in.peekPrefix("//") { break } if in.peekPrefix("/*") { in.Error(fmt.Sprintf("mod files must use // comments (not /* */ comments)")) } in.readRune() } return _IDENT } // isIdent reports whether c is an identifier rune. // We treat nearly all runes as identifier runes. func isIdent(c int) bool { return c != 0 && !unicode.IsSpace(rune(c)) } // Comment assignment. // We build two lists of all subexpressions, preorder and postorder. // The preorder list is ordered by start location, with outer expressions first. // The postorder list is ordered by end location, with outer expressions last. // We use the preorder list to assign each whole-line comment to the syntax // immediately following it, and we use the postorder list to assign each // end-of-line comment to the syntax immediately preceding it. // order walks the expression adding it and its subexpressions to the // preorder and postorder lists. func (in *input) order(x Expr) { if x != nil { in.pre = append(in.pre, x) } switch x := x.(type) { default: panic(fmt.Errorf("order: unexpected type %T", x)) case nil: // nothing case *LParen, *RParen: // nothing case *CommentBlock: // nothing case *Line: // nothing case *FileSyntax: for _, stmt := range x.Stmt { in.order(stmt) } case *LineBlock: in.order(&x.LParen) for _, l := range x.Line { in.order(l) } in.order(&x.RParen) } if x != nil { in.post = append(in.post, x) } } // assignComments attaches comments to nearby syntax. func (in *input) assignComments() { const debug = false // Generate preorder and postorder lists. in.order(in.file) // Split into whole-line comments and suffix comments. var line, suffix []Comment for _, com := range in.comments { if com.Suffix { suffix = append(suffix, com) } else { line = append(line, com) } } if debug { for _, c := range line { fmt.Fprintf(os.Stderr, "LINE %q :%d:%d #%d\n", c.Token, c.Start.Line, c.Start.LineRune, c.Start.Byte) } } // Assign line comments to syntax immediately following. for _, x := range in.pre { start, _ := x.Span() if debug { fmt.Printf("pre %T :%d:%d #%d\n", x, start.Line, start.LineRune, start.Byte) } xcom := x.Comment() for len(line) > 0 && start.Byte >= line[0].Start.Byte { if debug { fmt.Fprintf(os.Stderr, "ASSIGN LINE %q #%d\n", line[0].Token, line[0].Start.Byte) } xcom.Before = append(xcom.Before, line[0]) line = line[1:] } } // Remaining line comments go at end of file. in.file.After = append(in.file.After, line...) if debug { for _, c := range suffix { fmt.Fprintf(os.Stderr, "SUFFIX %q :%d:%d #%d\n", c.Token, c.Start.Line, c.Start.LineRune, c.Start.Byte) } } // Assign suffix comments to syntax immediately before. for i := len(in.post) - 1; i >= 0; i-- { x := in.post[i] start, end := x.Span() if debug { fmt.Printf("post %T :%d:%d #%d :%d:%d #%d\n", x, start.Line, start.LineRune, start.Byte, end.Line, end.LineRune, end.Byte) } // Do not assign suffix comments to end of line block or whole file. // Instead assign them to the last element inside. switch x.(type) { case *FileSyntax: continue } // Do not assign suffix comments to something that starts // on an earlier line, so that in // // x ( y // z ) // comment // // we assign the comment to z and not to x ( ... ). if start.Line != end.Line { continue } xcom := x.Comment() for len(suffix) > 0 && end.Byte <= suffix[len(suffix)-1].Start.Byte { if debug { fmt.Fprintf(os.Stderr, "ASSIGN SUFFIX %q #%d\n", suffix[len(suffix)-1].Token, suffix[len(suffix)-1].Start.Byte) } xcom.Suffix = append(xcom.Suffix, suffix[len(suffix)-1]) suffix = suffix[:len(suffix)-1] } } // We assigned suffix comments in reverse. // If multiple suffix comments were appended to the same // expression node, they are now in reverse. Fix that. for _, x := range in.post { reverseComments(x.Comment().Suffix) } // Remaining suffix comments go at beginning of file. in.file.Before = append(in.file.Before, suffix...) } // reverseComments reverses the []Comment list. func reverseComments(list []Comment) { for i, j := 0, len(list)-1; i < j; i, j = i+1, j-1 { list[i], list[j] = list[j], list[i] } } func (in *input) parseFile() { in.file = new(FileSyntax) var sym symType var cb *CommentBlock for { tok := in.lex(&sym) switch tok { case '\n': if cb != nil { in.file.Stmt = append(in.file.Stmt, cb) cb = nil } case _COMMENT: if cb == nil { cb = &CommentBlock{Start: sym.pos} } com := cb.Comment() com.Before = append(com.Before, Comment{Start: sym.pos, Token: sym.text}) case _EOF: if cb != nil { in.file.Stmt = append(in.file.Stmt, cb) } return default: in.parseStmt(&sym) if cb != nil { in.file.Stmt[len(in.file.Stmt)-1].Comment().Before = cb.Before cb = nil } } } } func (in *input) parseStmt(sym *symType) { start := sym.pos end := sym.endPos token := []string{sym.text} for { tok := in.lex(sym) switch tok { case '\n', _EOF, _EOL: in.file.Stmt = append(in.file.Stmt, &Line{ Start: start, Token: token, End: end, }) return case '(': in.file.Stmt = append(in.file.Stmt, in.parseLineBlock(start, token, sym)) return default: token = append(token, sym.text) end = sym.endPos } } } func (in *input) parseLineBlock(start Position, token []string, sym *symType) *LineBlock { x := &LineBlock{ Start: start, Token: token, LParen: LParen{Pos: sym.pos}, } var comments []Comment for { tok := in.lex(sym) switch tok { case _EOL: // ignore case '\n': if len(comments) == 0 && len(x.Line) > 0 || len(comments) > 0 && comments[len(comments)-1].Token != "" { comments = append(comments, Comment{}) } case _COMMENT: comments = append(comments, Comment{Start: sym.pos, Token: sym.text}) case _EOF: in.Error(fmt.Sprintf("syntax error (unterminated block started at %s:%d:%d)", in.filename, x.Start.Line, x.Start.LineRune)) case ')': x.RParen.Before = comments x.RParen.Pos = sym.pos tok = in.lex(sym) if tok != '\n' && tok != _EOF && tok != _EOL { in.Error("syntax error (expected newline after closing paren)") } return x default: l := in.parseLine(sym) x.Line = append(x.Line, l) l.Comment().Before = comments comments = nil } } } func (in *input) parseLine(sym *symType) *Line { start := sym.pos end := sym.endPos token := []string{sym.text} for { tok := in.lex(sym) switch tok { case '\n', _EOF, _EOL: return &Line{ Start: start, Token: token, End: end, InBlock: true, } default: token = append(token, sym.text) end = sym.endPos } } } const ( _EOF = -(1 + iota) _EOL _IDENT _STRING _COMMENT ) var ( slashSlash = []byte("//") moduleStr = []byte("module") ) // ModulePath returns the module path from the gomod file text. // If it cannot find a module path, it returns an empty string. // It is tolerant of unrelated problems in the go.mod file. func ModulePath(mod []byte) string { for len(mod) > 0 { line := mod mod = nil if i := bytes.IndexByte(line, '\n'); i >= 0 { line, mod = line[:i], line[i+1:] } if i := bytes.Index(line, slashSlash); i >= 0 { line = line[:i] } line = bytes.TrimSpace(line) if !bytes.HasPrefix(line, moduleStr) { continue } line = line[len(moduleStr):] n := len(line) line = bytes.TrimSpace(line) if len(line) == n || len(line) == 0 { continue } if line[0] == '"' || line[0] == '`' { p, err := strconv.Unquote(string(line)) if err != nil { return "" // malformed quoted string or multiline module path } return p } return string(line) } return "" // missing module path }
testdata
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/internal/modfile/testdata/replace2.in
module "abc" replace ( "xyz" v1.2.3 => "/tmp/z" "xyz" v1.3.4 => "my/xyz" "v1.3.4-me" xyz "v1.4.5" => "/tmp/my dir" xyz v1.5.6 => my/xyz v1.5.6 xyz => my/other/xyz v1.5.4 )
testdata
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/internal/modfile/testdata/comment.in
// comment module "x" // eol // mid comment // comment 2 // comment 2 line 2 module "y" // eoy // comment 3
testdata
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/internal/modfile/testdata/replace.golden
module abc replace xyz v1.2.3 => /tmp/z replace xyz v1.3.4 => my/xyz v1.3.4-me
testdata
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/internal/modfile/testdata/replace.in
module "abc" replace "xyz" v1.2.3 => "/tmp/z" replace "xyz" v1.3.4 => "my/xyz" v1.3.4-me
testdata
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/internal/modfile/testdata/module.in
module "abc"
testdata
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/internal/modfile/testdata/replace2.golden
module abc replace ( xyz v1.2.3 => /tmp/z xyz v1.3.4 => my/xyz v1.3.4-me xyz v1.4.5 => "/tmp/my dir" xyz v1.5.6 => my/xyz v1.5.6 xyz => my/other/xyz v1.5.4 )
testdata
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/internal/modfile/testdata/gopkg.in.golden
module x require ( gopkg.in/mgo.v2 v2.0.0-20160818020120-3f83fa500528 gopkg.in/yaml.v2 v2.2.1 )
testdata
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/internal/modfile/testdata/rule1.golden
module "x" module "y" require "x" require x
testdata
/home/linuxreitt/Michinereitt/Tuning/Workshop_Scripts/hf-codegen/data/golang_public_repos/vgo/vendor/cmd/go/internal/modfile/testdata/block.golden
// comment x "y" z // block block ( // block-eol // x-before-line "x" ( y // x-eol "x1" "x2" // line "x3" "x4" "x5" // y-line "y" // y-eol "z" // z-eol ) // block-eol2 block2 ( x y z ) // eof