46 | {{end}}
47 |
48 |
49 |
50 |
51 |
52 | {{if .PlayEnabled}}
53 |
54 | {{end}}
55 |
56 | {{end}}
57 |
58 | {{define "newline"}}
59 |
60 | {{end}}
61 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/cmd/stringer/testdata/cgo.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // Import "C" shouldn't be imported.
6 |
7 | package main
8 |
9 | /*
10 | #define HELLO 1
11 | */
12 | import "C"
13 |
14 | import "fmt"
15 |
16 | type Cgo uint32
17 |
18 | const (
19 | // MustScanSubDirs indicates that events were coalesced hierarchically.
20 | MustScanSubDirs Cgo = 1 << iota
21 | )
22 |
23 | func main() {
24 | _ = C.HELLO
25 | ck(MustScanSubDirs, "MustScanSubDirs")
26 | }
27 |
28 | func ck(day Cgo, str string) {
29 | if fmt.Sprint(day) != str {
30 | panic("cgo.go: " + str)
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/cmd/stringer/testdata/day.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // Simple test: enumeration of type int starting at 0.
6 |
7 | package main
8 |
9 | import "fmt"
10 |
11 | type Day int
12 |
13 | const (
14 | Monday Day = iota
15 | Tuesday
16 | Wednesday
17 | Thursday
18 | Friday
19 | Saturday
20 | Sunday
21 | )
22 |
23 | func main() {
24 | ck(Monday, "Monday")
25 | ck(Tuesday, "Tuesday")
26 | ck(Wednesday, "Wednesday")
27 | ck(Thursday, "Thursday")
28 | ck(Friday, "Friday")
29 | ck(Saturday, "Saturday")
30 | ck(Sunday, "Sunday")
31 | ck(-127, "Day(-127)")
32 | ck(127, "Day(127)")
33 | }
34 |
35 | func ck(day Day, str string) {
36 | if fmt.Sprint(day) != str {
37 | panic("day.go: " + str)
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/cmd/stringer/testdata/gap.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // Gaps and an offset.
6 |
7 | package main
8 |
9 | import "fmt"
10 |
11 | type Gap int
12 |
13 | const (
14 | Two Gap = 2
15 | Three Gap = 3
16 | Five Gap = 5
17 | Six Gap = 6
18 | Seven Gap = 7
19 | Eight Gap = 8
20 | Nine Gap = 9
21 | Eleven Gap = 11
22 | )
23 |
24 | func main() {
25 | ck(0, "Gap(0)")
26 | ck(1, "Gap(1)")
27 | ck(Two, "Two")
28 | ck(Three, "Three")
29 | ck(4, "Gap(4)")
30 | ck(Five, "Five")
31 | ck(Six, "Six")
32 | ck(Seven, "Seven")
33 | ck(Eight, "Eight")
34 | ck(Nine, "Nine")
35 | ck(10, "Gap(10)")
36 | ck(Eleven, "Eleven")
37 | ck(12, "Gap(12)")
38 | }
39 |
40 | func ck(gap Gap, str string) {
41 | if fmt.Sprint(gap) != str {
42 | panic("gap.go: " + str)
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/cmd/stringer/testdata/num.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // Signed integers spanning zero.
6 |
7 | package main
8 |
9 | import "fmt"
10 |
11 | type Num int
12 |
13 | const (
14 | m_2 Num = -2 + iota
15 | m_1
16 | m0
17 | m1
18 | m2
19 | )
20 |
21 | func main() {
22 | ck(-3, "Num(-3)")
23 | ck(m_2, "m_2")
24 | ck(m_1, "m_1")
25 | ck(m0, "m0")
26 | ck(m1, "m1")
27 | ck(m2, "m2")
28 | ck(3, "Num(3)")
29 | }
30 |
31 | func ck(num Num, str string) {
32 | if fmt.Sprint(num) != str {
33 | panic("num.go: " + str)
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/cmd/stringer/testdata/number.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // Enumeration with an offset.
6 | // Also includes a duplicate.
7 |
8 | package main
9 |
10 | import "fmt"
11 |
12 | type Number int
13 |
14 | const (
15 | _ Number = iota
16 | One
17 | Two
18 | Three
19 | AnotherOne = One // Duplicate; note that AnotherOne doesn't appear below.
20 | )
21 |
22 | func main() {
23 | ck(One, "One")
24 | ck(Two, "Two")
25 | ck(Three, "Three")
26 | ck(AnotherOne, "One")
27 | ck(127, "Number(127)")
28 | }
29 |
30 | func ck(num Number, str string) {
31 | if fmt.Sprint(num) != str {
32 | panic("number.go: " + str)
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/cmd/stringer/testdata/prime.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // Enough gaps to trigger a map implementation of the method.
6 | // Also includes a duplicate to test that it doesn't cause problems
7 |
8 | package main
9 |
10 | import "fmt"
11 |
12 | type Prime int
13 |
14 | const (
15 | p2 Prime = 2
16 | p3 Prime = 3
17 | p5 Prime = 5
18 | p7 Prime = 7
19 | p77 Prime = 7 // Duplicate; note that p77 doesn't appear below.
20 | p11 Prime = 11
21 | p13 Prime = 13
22 | p17 Prime = 17
23 | p19 Prime = 19
24 | p23 Prime = 23
25 | p29 Prime = 29
26 | p37 Prime = 31
27 | p41 Prime = 41
28 | p43 Prime = 43
29 | )
30 |
31 | func main() {
32 | ck(0, "Prime(0)")
33 | ck(1, "Prime(1)")
34 | ck(p2, "p2")
35 | ck(p3, "p3")
36 | ck(4, "Prime(4)")
37 | ck(p5, "p5")
38 | ck(p7, "p7")
39 | ck(p77, "p7")
40 | ck(p11, "p11")
41 | ck(p13, "p13")
42 | ck(p17, "p17")
43 | ck(p19, "p19")
44 | ck(p23, "p23")
45 | ck(p29, "p29")
46 | ck(p37, "p37")
47 | ck(p41, "p41")
48 | ck(p43, "p43")
49 | ck(44, "Prime(44)")
50 | }
51 |
52 | func ck(prime Prime, str string) {
53 | if fmt.Sprint(prime) != str {
54 | panic("prime.go: " + str)
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/cmd/stringer/testdata/unum.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // Unsigned integers spanning zero.
6 |
7 | package main
8 |
9 | import "fmt"
10 |
11 | type Unum uint8
12 |
13 | const (
14 | m_2 Unum = iota + 253
15 | m_1
16 | )
17 |
18 | const (
19 | m0 Unum = iota
20 | m1
21 | m2
22 | )
23 |
24 | func main() {
25 | ck(^Unum(0)-3, "Unum(252)")
26 | ck(m_2, "m_2")
27 | ck(m_1, "m_1")
28 | ck(m0, "m0")
29 | ck(m1, "m1")
30 | ck(m2, "m2")
31 | ck(3, "Unum(3)")
32 | }
33 |
34 | func ck(unum Unum, str string) {
35 | if fmt.Sprint(unum) != str {
36 | panic("unum.go: " + str)
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/cmd/tipgodoc/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM golang:1.4.1
2 |
3 | RUN apt-get update && apt-get install --no-install-recommends -y -q build-essential git
4 |
5 | # golang puts its go install here (weird but true)
6 | ENV GOROOT_BOOTSTRAP /usr/src/go
7 |
8 | # golang sets GOPATH=/go
9 | ADD . /go/src/tipgodoc
10 | RUN go install tipgodoc
11 | ENTRYPOINT ["/go/bin/tipgodoc"]
12 | # Kubernetes expects us to listen on port 8080
13 | EXPOSE 8080
14 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/cmd/tipgodoc/README:
--------------------------------------------------------------------------------
1 | To deploy as an App Engine Manged VM, use gcloud:
2 |
3 | $ gcloud --project golang-org preview app deploy .
4 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/cmd/tipgodoc/app.yaml:
--------------------------------------------------------------------------------
1 | application: golang-org
2 | version: tip
3 | runtime: custom
4 | api_version: go1
5 | vm: true
6 |
7 | manual_scaling:
8 | instances: 1
9 |
10 | handlers:
11 | - url: /.*
12 | script: _go_app
13 |
14 | health_check:
15 | enable_health_check: False
16 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/cmd/vet/assign.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | /*
6 | This file contains the code to check for useless assignments.
7 | */
8 |
9 | package main
10 |
11 | import (
12 | "go/ast"
13 | "go/token"
14 | "reflect"
15 | )
16 |
17 | func init() {
18 | register("assign",
19 | "check for useless assignments",
20 | checkAssignStmt,
21 | assignStmt)
22 | }
23 |
24 | // TODO: should also check for assignments to struct fields inside methods
25 | // that are on T instead of *T.
26 |
27 | // checkAssignStmt checks for assignments of the form " = ".
28 | // These are almost always useless, and even when they aren't they are usually a mistake.
29 | func checkAssignStmt(f *File, node ast.Node) {
30 | stmt := node.(*ast.AssignStmt)
31 | if stmt.Tok != token.ASSIGN {
32 | return // ignore :=
33 | }
34 | if len(stmt.Lhs) != len(stmt.Rhs) {
35 | // If LHS and RHS have different cardinality, they can't be the same.
36 | return
37 | }
38 | for i, lhs := range stmt.Lhs {
39 | rhs := stmt.Rhs[i]
40 | if reflect.TypeOf(lhs) != reflect.TypeOf(rhs) {
41 | continue // short-circuit the heavy-weight gofmt check
42 | }
43 | le := f.gofmt(lhs)
44 | re := f.gofmt(rhs)
45 | if le == re {
46 | f.Badf(stmt.Pos(), "self-assignment of %s to %s", re, le)
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/cmd/vet/testdata/asm.go:
--------------------------------------------------------------------------------
1 | // Copyright 2010 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build ignore
6 |
7 | // This file contains declarations to test the assembly in test_asm.s.
8 |
9 | package testdata
10 |
11 | func arg1(x int8, y uint8)
12 | func arg2(x int16, y uint16)
13 | func arg4(x int32, y uint32)
14 | func arg8(x int64, y uint64)
15 | func argint(x int, y uint)
16 | func argptr(x *byte, y *byte, c chan int, m map[int]int, f func())
17 | func argstring(x, y string)
18 | func argslice(x, y []string)
19 | func argiface(x interface{}, y interface {
20 | m()
21 | })
22 | func returnint() int
23 | func returnbyte(x int) byte
24 | func returnnamed(x byte) (r1 int, r2 int16, r3 string, r4 byte)
25 | func returnintmissing() int
26 | func leaf(x, y int) int
27 |
28 | func noprof(x int)
29 | func dupok(x int)
30 | func nosplit(x int)
31 | func rodata(x int)
32 | func noptr(x int)
33 | func wrapper(x int)
34 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/cmd/vet/testdata/asm4.s:
--------------------------------------------------------------------------------
1 | // Copyright 2013 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build amd64
6 | // +build vet_test
7 |
8 | // Test cases for symbolic NOSPLIT etc. on TEXT symbols.
9 |
10 | TEXT ·noprof(SB),NOPROF,$0-8
11 | RET
12 |
13 | TEXT ·dupok(SB),DUPOK,$0-8
14 | RET
15 |
16 | TEXT ·nosplit(SB),NOSPLIT,$0
17 | RET
18 |
19 | TEXT ·rodata(SB),RODATA,$0-8
20 | RET
21 |
22 | TEXT ·noptr(SB),NOPTR|NOSPLIT,$0
23 | RET
24 |
25 | TEXT ·wrapper(SB),WRAPPER,$0-8
26 | RET
27 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/cmd/vet/testdata/assign.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // This file contains tests for the useless-assignment checker.
6 |
7 | package testdata
8 |
9 | type ST struct {
10 | x int
11 | }
12 |
13 | func (s *ST) SetX(x int) {
14 | // Accidental self-assignment; it should be "s.x = x"
15 | x = x // ERROR "self-assignment of x to x"
16 | // Another mistake
17 | s.x = s.x // ERROR "self-assignment of s.x to s.x"
18 | }
19 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/cmd/vet/testdata/atomic.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // This file contains tests for the atomic checker.
6 |
7 | package testdata
8 |
9 | import (
10 | "sync/atomic"
11 | )
12 |
13 | type Counter uint64
14 |
15 | func AtomicTests() {
16 | x := uint64(1)
17 | x = atomic.AddUint64(&x, 1) // ERROR "direct assignment to atomic value"
18 | _, x = 10, atomic.AddUint64(&x, 1) // ERROR "direct assignment to atomic value"
19 | x, _ = atomic.AddUint64(&x, 1), 10 // ERROR "direct assignment to atomic value"
20 |
21 | y := &x
22 | *y = atomic.AddUint64(y, 1) // ERROR "direct assignment to atomic value"
23 |
24 | var su struct{ Counter uint64 }
25 | su.Counter = atomic.AddUint64(&su.Counter, 1) // ERROR "direct assignment to atomic value"
26 | z1 := atomic.AddUint64(&su.Counter, 1)
27 | _ = z1 // Avoid err "z declared and not used"
28 |
29 | var sp struct{ Counter *uint64 }
30 | *sp.Counter = atomic.AddUint64(sp.Counter, 1) // ERROR "direct assignment to atomic value"
31 | z2 := atomic.AddUint64(sp.Counter, 1)
32 | _ = z2 // Avoid err "z declared and not used"
33 |
34 | au := []uint64{10, 20}
35 | au[0] = atomic.AddUint64(&au[0], 1) // ERROR "direct assignment to atomic value"
36 | au[1] = atomic.AddUint64(&au[0], 1)
37 |
38 | ap := []*uint64{&au[0], &au[1]}
39 | *ap[0] = atomic.AddUint64(ap[0], 1) // ERROR "direct assignment to atomic value"
40 | *ap[1] = atomic.AddUint64(ap[0], 1)
41 |
42 | x = atomic.AddUint64() // Used to make vet crash; now silently ignored.
43 | }
44 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/cmd/vet/testdata/buildtag.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // This file contains tests for the buildtag checker.
6 |
7 | // +builder // ERROR "possible malformed \+build comment"
8 | // +build !ignore
9 |
10 | package testdata
11 |
12 | // +build toolate // ERROR "build comment must appear before package clause and be followed by a blank line"
13 |
14 | var _ = 3
15 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/cmd/vet/testdata/buildtag_bad.go:
--------------------------------------------------------------------------------
1 | // This file contains misplaced or malformed build constraints.
2 | // The Go tool will skip it, because the constraints are invalid.
3 | // It serves only to test the tag checker during make test.
4 |
5 | // Mention +build // ERROR "possible malformed \+build comment"
6 |
7 | // +build !!bang // ERROR "invalid double negative in build constraint"
8 | // +build @#$ // ERROR "invalid non-alphanumeric build constraint"
9 |
10 | // +build toolate // ERROR "build comment must appear before package clause and be followed by a blank line"
11 | package bad
12 |
13 | // This is package 'bad' rather than 'main' so the erroneous build
14 | // tag doesn't end up looking like a package doc for the vet command
15 | // when examined by godoc.
16 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/cmd/vet/testdata/composite.go:
--------------------------------------------------------------------------------
1 | // Copyright 2012 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // This file contains tests for the untagged struct literal checker.
6 |
7 | // This file contains the test for untagged struct literals.
8 |
9 | package testdata
10 |
11 | import (
12 | "flag"
13 | "go/scanner"
14 | )
15 |
16 | var Okay1 = []string{
17 | "Name",
18 | "Usage",
19 | "DefValue",
20 | }
21 |
22 | var Okay2 = map[string]bool{
23 | "Name": true,
24 | "Usage": true,
25 | "DefValue": true,
26 | }
27 |
28 | var Okay3 = struct {
29 | X string
30 | Y string
31 | Z string
32 | }{
33 | "Name",
34 | "Usage",
35 | "DefValue",
36 | }
37 |
38 | type MyStruct struct {
39 | X string
40 | Y string
41 | Z string
42 | }
43 |
44 | var Okay4 = MyStruct{
45 | "Name",
46 | "Usage",
47 | "DefValue",
48 | }
49 |
50 | // Testing is awkward because we need to reference things from a separate package
51 | // to trigger the warnings.
52 |
53 | var BadStructLiteralUsedInTests = flag.Flag{ // ERROR "unkeyed fields"
54 | "Name",
55 | "Usage",
56 | nil, // Value
57 | "DefValue",
58 | }
59 |
60 | // Used to test the check for slices and arrays: If that test is disabled and
61 | // vet is run with --compositewhitelist=false, this line triggers an error.
62 | // Clumsy but sufficient.
63 | var scannerErrorListTest = scanner.ErrorList{nil, nil}
64 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/cmd/vet/testdata/method.go:
--------------------------------------------------------------------------------
1 | // Copyright 2010 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // This file contains tests for the canonical method checker.
6 |
7 | // This file contains the code to check canonical methods.
8 |
9 | package testdata
10 |
11 | import (
12 | "fmt"
13 | )
14 |
15 | type MethodTest int
16 |
17 | func (t *MethodTest) Scan(x fmt.ScanState, c byte) { // ERROR "should have signature Scan"
18 | }
19 |
20 | type MethodTestInterface interface {
21 | ReadByte() byte // ERROR "should have signature ReadByte"
22 | }
23 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/cmd/vet/testdata/nilfunc.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package testdata
6 |
7 | func F() {}
8 |
9 | type T struct {
10 | F func()
11 | }
12 |
13 | func (T) M() {}
14 |
15 | var Fv = F
16 |
17 | func Comparison() {
18 | var t T
19 | var fn func()
20 | if fn == nil || Fv == nil || t.F == nil {
21 | // no error; these func vars or fields may be nil
22 | }
23 | if F == nil { // ERROR "comparison of function F == nil is always false"
24 | panic("can't happen")
25 | }
26 | if t.M == nil { // ERROR "comparison of function M == nil is always false"
27 | panic("can't happen")
28 | }
29 | if F != nil { // ERROR "comparison of function F != nil is always true"
30 | if t.M != nil { // ERROR "comparison of function M != nil is always true"
31 | return
32 | }
33 | }
34 | panic("can't happen")
35 | }
36 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/container/intsets/util_test.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package intsets
6 |
7 | import "testing"
8 |
9 | func TestNLZ(t *testing.T) {
10 | // Test the platform-specific edge case.
11 | // NB: v must be a var (not const) so that the word() conversion is dynamic.
12 | // Otherwise the compiler will report an error.
13 | v := uint64(0x0000801000000000)
14 | n := nlz(word(v))
15 | want := 32 // (on 32-bit)
16 | if bitsPerWord == 64 {
17 | want = 16
18 | }
19 | if n != want {
20 | t.Errorf("%d-bit nlz(%d) = %d, want %d", bitsPerWord, v, n, want)
21 | }
22 | }
23 |
24 | // Backdoor for testing.
25 | func (s *Sparse) Check() error { return s.check() }
26 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/ast/astutil/util.go:
--------------------------------------------------------------------------------
1 | package astutil
2 |
3 | import "go/ast"
4 |
5 | // Unparen returns e with any enclosing parentheses stripped.
6 | func Unparen(e ast.Expr) ast.Expr {
7 | for {
8 | p, ok := e.(*ast.ParenExpr)
9 | if !ok {
10 | return e
11 | }
12 | e = p.X
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/buildutil/allpackages_test.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package buildutil_test
6 |
7 | import (
8 | "go/build"
9 | "testing"
10 |
11 | "golang.org/x/tools/go/buildutil"
12 | )
13 |
14 | func TestAllPackages(t *testing.T) {
15 | all := buildutil.AllPackages(&build.Default)
16 |
17 | set := make(map[string]bool)
18 | for _, pkg := range all {
19 | set[pkg] = true
20 | }
21 |
22 | const wantAtLeast = 250
23 | if len(all) < wantAtLeast {
24 | t.Errorf("Found only %d packages, want at least %d", len(all), wantAtLeast)
25 | }
26 |
27 | for _, want := range []string{"fmt", "crypto/sha256", "golang.org/x/tools/go/buildutil"} {
28 | if !set[want] {
29 | t.Errorf("Package %q not found; got %s", want, all)
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/buildutil/util_test.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package buildutil_test
6 |
7 | import (
8 | "go/build"
9 | "os"
10 | "path/filepath"
11 | "runtime"
12 | "testing"
13 |
14 | "golang.org/x/tools/go/buildutil"
15 | )
16 |
17 | func TestContainingPackage(t *testing.T) {
18 | // unvirtualized:
19 | goroot := runtime.GOROOT()
20 | gopath := filepath.SplitList(os.Getenv("GOPATH"))[0]
21 |
22 | for _, test := range [][2]string{
23 | {goroot + "/src/fmt/print.go", "fmt"},
24 | {goroot + "/src/encoding/json/foo.go", "encoding/json"},
25 | {goroot + "/src/encoding/missing/foo.go", "(not found)"},
26 | {gopath + "/src/golang.org/x/tools/go/buildutil/util_test.go",
27 | "golang.org/x/tools/go/buildutil"},
28 | } {
29 | file, want := test[0], test[1]
30 | bp, err := buildutil.ContainingPackage(&build.Default, ".", file)
31 | got := bp.ImportPath
32 | if err != nil {
33 | got = "(not found)"
34 | }
35 | if got != want {
36 | t.Errorf("ContainingPackage(%q) = %s, want %s", file, got, want)
37 | }
38 | }
39 |
40 | // TODO(adonovan): test on virtualized GOPATH too.
41 | }
42 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/callgraph/cha/testdata/func.go:
--------------------------------------------------------------------------------
1 | //+build ignore
2 |
3 | package main
4 |
5 | // Test of dynamic function calls; no interfaces.
6 |
7 | func A(int) {}
8 |
9 | var (
10 | B = func(int) {}
11 | C = func(int) {}
12 | )
13 |
14 | func f() {
15 | pfn := B
16 | pfn(0) // calls A, B, C, even though A is not even address-taken
17 | }
18 |
19 | // WANT:
20 | // Dynamic calls
21 | // f --> A
22 | // f --> init$1
23 | // f --> init$2
24 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/callgraph/cha/testdata/iface.go:
--------------------------------------------------------------------------------
1 | //+build ignore
2 |
3 | package main
4 |
5 | // Test of interface calls. None of the concrete types are ever
6 | // instantiated or converted to interfaces.
7 |
8 | type I interface {
9 | f()
10 | }
11 |
12 | type J interface {
13 | f()
14 | g()
15 | }
16 |
17 | type C int // implements I
18 |
19 | func (*C) f()
20 |
21 | type D int // implements I and J
22 |
23 | func (*D) f()
24 | func (*D) g()
25 |
26 | func one(i I, j J) {
27 | i.f() // calls *C and *D
28 | }
29 |
30 | func two(i I, j J) {
31 | j.f() // calls *D (but not *C, even though it defines method f)
32 | }
33 |
34 | func three(i I, j J) {
35 | j.g() // calls *D
36 | }
37 |
38 | func four(i I, j J) {
39 | Jf := J.f
40 | if unknown {
41 | Jf = nil // suppress SSA constant propagation
42 | }
43 | Jf(nil) // calls *D
44 | }
45 |
46 | func five(i I, j J) {
47 | jf := j.f
48 | if unknown {
49 | jf = nil // suppress SSA constant propagation
50 | }
51 | jf() // calls *D
52 | }
53 |
54 | var unknown bool
55 |
56 | // WANT:
57 | // Dynamic calls
58 | // (J).f$bound --> (*D).f
59 | // (J).f$thunk --> (*D).f
60 | // five --> (J).f$bound
61 | // four --> (J).f$thunk
62 | // one --> (*C).f
63 | // one --> (*D).f
64 | // three --> (*D).g
65 | // two --> (*D).f
66 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/callgraph/cha/testdata/recv.go:
--------------------------------------------------------------------------------
1 | //+build ignore
2 |
3 | package main
4 |
5 | type I interface {
6 | f()
7 | }
8 |
9 | type J interface {
10 | g()
11 | }
12 |
13 | type C int // C and *C implement I; *C implements J
14 |
15 | func (C) f()
16 | func (*C) g()
17 |
18 | type D int // *D implements I and J
19 |
20 | func (*D) f()
21 | func (*D) g()
22 |
23 | func f(i I) {
24 | i.f() // calls C, *C, *D
25 | }
26 |
27 | func g(j J) {
28 | j.g() // calls *C, *D
29 | }
30 |
31 | // WANT:
32 | // Dynamic calls
33 | // f --> (*C).f
34 | // f --> (*D).f
35 | // f --> (C).f
36 | // g --> (*C).g
37 | // g --> (*D).g
38 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/callgraph/rta/testdata/func.go:
--------------------------------------------------------------------------------
1 | //+build ignore
2 |
3 | package main
4 |
5 | // Test of dynamic function calls.
6 | // No interfaces, so no runtime/reflect types.
7 |
8 | func A1() {
9 | A2(0)
10 | }
11 |
12 | func A2(int) {} // not address-taken
13 |
14 | func B() {} // unreachable
15 |
16 | var (
17 | C = func(int) {}
18 | D = func(int) {}
19 | )
20 |
21 | func main() {
22 | A1()
23 |
24 | pfn := C
25 | pfn(0) // calls C and D but not A2 (same sig but not address-taken)
26 | }
27 |
28 | // WANT:
29 | // Dynamic calls
30 | // main --> init$1
31 | // main --> init$2
32 | // Reachable functions
33 | // A1
34 | // A2
35 | // init$1
36 | // init$2
37 | // Reflect types
38 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/callgraph/rta/testdata/iface.go:
--------------------------------------------------------------------------------
1 | //+build ignore
2 |
3 | package main
4 |
5 | // Test of interface calls.
6 |
7 | func use(interface{})
8 |
9 | type A byte // instantiated but not a reflect type
10 |
11 | func (A) f() {} // called directly
12 | func (A) F() {} // unreachable
13 |
14 | type B int // a reflect type
15 |
16 | func (*B) f() {} // reachable via interface invoke
17 | func (*B) F() {} // reachable: exported method of reflect type
18 |
19 | type B2 int // a reflect type, and *B2 also
20 |
21 | func (B2) f() {} // reachable via interface invoke
22 | func (B2) g() {} // reachable: exported method of reflect type
23 |
24 | type C string // not instantiated
25 |
26 | func (C) f() {} // unreachable
27 | func (C) F() {} // unreachable
28 |
29 | type D uint // instantiated only in dead code
30 |
31 | func (D) f() {} // unreachable
32 | func (D) F() {} // unreachable
33 |
34 | func main() {
35 | A(0).f()
36 |
37 | use(new(B))
38 | use(B2(0))
39 |
40 | var i interface {
41 | f()
42 | }
43 | i.f() // calls (*B).f, (*B2).f and (B2.f)
44 |
45 | live()
46 | }
47 |
48 | func live() {
49 | var j interface {
50 | f()
51 | g()
52 | }
53 | j.f() // calls (B2).f and (*B2).f but not (*B).f (no g method).
54 | }
55 |
56 | func dead() {
57 | use(D(0))
58 | }
59 |
60 | // WANT:
61 | // Dynamic calls
62 | // live --> (*B2).f
63 | // live --> (B2).f
64 | // main --> (*B).f
65 | // main --> (*B2).f
66 | // main --> (B2).f
67 | // Reachable functions
68 | // (*B).F
69 | // (*B).f
70 | // (*B2).f
71 | // (A).f
72 | // (B2).f
73 | // live
74 | // use
75 | // Reflect types
76 | // *B
77 | // *B2
78 | // B
79 | // B2
80 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/callgraph/rta/testdata/rtype.go:
--------------------------------------------------------------------------------
1 | //+build ignore
2 |
3 | package main
4 |
5 | // Test of runtime types (types for which descriptors are needed).
6 |
7 | func use(interface{})
8 |
9 | type A byte // neither A nor byte are runtime types
10 |
11 | type B struct{ x uint } // B and uint are runtime types, but not the struct
12 |
13 | func main() {
14 | var x int // not a runtime type
15 | print(x)
16 |
17 | var y string // runtime type due to interface conversion
18 | use(y)
19 |
20 | use(struct{ uint64 }{}) // struct is a runtime type
21 |
22 | use(new(B)) // *B is a runtime type
23 | }
24 |
25 | // WANT:
26 | // Dynamic calls
27 | // Reachable functions
28 | // use
29 | // Reflect types
30 | // *B
31 | // B
32 | // string
33 | // struct{uint64}
34 | // uint
35 | // uint64
36 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/callgraph/static/static.go:
--------------------------------------------------------------------------------
1 | // Package static computes the call graph of a Go program containing
2 | // only static call edges.
3 | package static
4 |
5 | import (
6 | "golang.org/x/tools/go/callgraph"
7 | "golang.org/x/tools/go/ssa"
8 | "golang.org/x/tools/go/ssa/ssautil"
9 | )
10 |
11 | // CallGraph computes the call graph of the specified program
12 | // considering only static calls.
13 | //
14 | func CallGraph(prog *ssa.Program) *callgraph.Graph {
15 | cg := callgraph.New(nil) // TODO(adonovan) eliminate concept of rooted callgraph
16 |
17 | // TODO(adonovan): opt: use only a single pass over the ssa.Program.
18 | for f := range ssautil.AllFunctions(prog) {
19 | fnode := cg.CreateNode(f)
20 | for _, b := range f.Blocks {
21 | for _, instr := range b.Instrs {
22 | if site, ok := instr.(ssa.CallInstruction); ok {
23 | if g := site.Common().StaticCallee(); g != nil {
24 | gnode := cg.CreateNode(g)
25 | callgraph.AddEdge(fnode, site, gnode)
26 | }
27 | }
28 | }
29 | }
30 | }
31 |
32 | return cg
33 | }
34 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/exact/go13.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !go1.4
6 |
7 | package exact
8 |
9 | import (
10 | "math"
11 | "math/big"
12 | )
13 |
14 | func ratToFloat32(x *big.Rat) (float32, bool) {
15 | // Before 1.4, there's no Rat.Float32.
16 | // Emulate it, albeit at the cost of
17 | // imprecision in corner cases.
18 | x64, exact := x.Float64()
19 | x32 := float32(x64)
20 | if math.IsInf(float64(x32), 0) {
21 | exact = false
22 | }
23 | return x32, exact
24 | }
25 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/exact/go14.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build go1.4
6 |
7 | package exact
8 |
9 | import "math/big"
10 |
11 | func ratToFloat32(x *big.Rat) (float32, bool) {
12 | return x.Float32()
13 | }
14 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/gccgoimporter/testdata/complexnums.go:
--------------------------------------------------------------------------------
1 | package complexnums
2 |
3 | const NN = -1 - 1i
4 | const NP = -1 + 1i
5 | const PN = 1 - 1i
6 | const PP = 1 + 1i
7 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/gccgoimporter/testdata/complexnums.gox:
--------------------------------------------------------------------------------
1 | v1;
2 | package complexnums;
3 | pkgpath complexnums;
4 | priority 1;
5 | const NN = -0.1E1-0.1E1i ;
6 | const NP = -0.1E1+0.1E1i ;
7 | const PN = 0.1E1-0.1E1i ;
8 | const PP = 0.1E1+0.1E1i ;
9 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/gccgoimporter/testdata/imports.go:
--------------------------------------------------------------------------------
1 | package imports
2 |
3 | import "fmt"
4 |
5 | var Hello = fmt.Sprintf("Hello, world")
6 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/gccgoimporter/testdata/imports.gox:
--------------------------------------------------------------------------------
1 | v1;
2 | package imports;
3 | pkgpath imports;
4 | priority 7;
5 | import fmt fmt "fmt";
6 | init imports imports..import 7 math math..import 1 runtime runtime..import 1 strconv strconv..import 2 io io..import 3 reflect reflect..import 3 syscall syscall..import 3 time time..import 4 os os..import 5 fmt fmt..import 6;
7 | var Hello ;
8 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/gccgoimporter/testdata/pointer.go:
--------------------------------------------------------------------------------
1 | package pointer
2 |
3 | type Int8Ptr *int8
4 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/gccgoimporter/testdata/pointer.gox:
--------------------------------------------------------------------------------
1 | v1;
2 | package pointer;
3 | pkgpath pointer;
4 | type >>;
5 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/loader/testdata/a.go:
--------------------------------------------------------------------------------
1 | package P
2 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/loader/testdata/b.go:
--------------------------------------------------------------------------------
1 | package P
2 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/loader/testdata/badpkgdecl.go:
--------------------------------------------------------------------------------
1 | // this file has no package decl
2 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/pointer/TODO:
--------------------------------------------------------------------------------
1 | -*- text -*-
2 |
3 | Pointer analysis to-do list
4 | ===========================
5 |
6 | CONSTRAINT GENERATION:
7 | - support reflection:
8 | - a couple of operators are missing
9 | - reflect.Values may contain lvalues (CanAddr)
10 | - implement native intrinsics. These vary by platform.
11 | - add to pts(a.panic) a label representing all runtime panics, e.g.
12 | runtime.{TypeAssertionError,errorString,errorCString}.
13 |
14 | OPTIMISATIONS
15 | - pre-solver:
16 | pointer equivalence: extend HVN to HRU
17 | location equivalence
18 | - solver: HCD, LCD.
19 | - experiment with map+slice worklist in lieu of bitset.
20 | It may have faster insert.
21 |
22 | MISC:
23 | - Test on all platforms.
24 | Currently we assume these go/build tags: linux, amd64, !cgo.
25 |
26 | MAINTAINABILITY
27 | - Think about ways to make debugging this code easier. PTA logs
28 | routinely exceed a million lines and require training to read.
29 |
30 | BUGS:
31 | - There's a crash bug in stdlib_test + reflection, rVCallConstraint.
32 |
33 |
34 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/pointer/print.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package pointer
6 |
7 | import "fmt"
8 |
9 | func (c *addrConstraint) String() string {
10 | return fmt.Sprintf("addr n%d <- {&n%d}", c.dst, c.src)
11 | }
12 |
13 | func (c *copyConstraint) String() string {
14 | return fmt.Sprintf("copy n%d <- n%d", c.dst, c.src)
15 | }
16 |
17 | func (c *loadConstraint) String() string {
18 | return fmt.Sprintf("load n%d <- n%d[%d]", c.dst, c.src, c.offset)
19 | }
20 |
21 | func (c *storeConstraint) String() string {
22 | return fmt.Sprintf("store n%d[%d] <- n%d", c.dst, c.offset, c.src)
23 | }
24 |
25 | func (c *offsetAddrConstraint) String() string {
26 | return fmt.Sprintf("offsetAddr n%d <- n%d.#%d", c.dst, c.src, c.offset)
27 | }
28 |
29 | func (c *typeFilterConstraint) String() string {
30 | return fmt.Sprintf("typeFilter n%d <- n%d.(%s)", c.dst, c.src, c.typ)
31 | }
32 |
33 | func (c *untagConstraint) String() string {
34 | return fmt.Sprintf("untag n%d <- n%d.(%s)", c.dst, c.src, c.typ)
35 | }
36 |
37 | func (c *invokeConstraint) String() string {
38 | return fmt.Sprintf("invoke n%d.%s(n%d ...)", c.iface, c.method.Name(), c.params)
39 | }
40 |
41 | func (n nodeid) String() string {
42 | return fmt.Sprintf("n%d", n)
43 | }
44 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/pointer/testdata/a_test.go:
--------------------------------------------------------------------------------
1 | // +build ignore
2 |
3 | package a
4 |
5 | // This test exercises the synthesis of testmain packages for tests.
6 | // The test framework doesn't directly let us perform negative
7 | // assertions (i.e. that TestingQuux isn't called, or that its
8 | // parameter's PTS is empty) so this test is rather roundabout.
9 |
10 | import "testing"
11 |
12 | func log(f func(*testing.T)) {
13 | // The PTS of f is the set of called tests. TestingQuux is not present.
14 | print(f) // @pointsto main.Test | main.TestFoo
15 | }
16 |
17 | func Test(t *testing.T) {
18 | // Don't assert @pointsto(t) since its label contains a fragile line number.
19 | log(Test)
20 | }
21 |
22 | func TestFoo(t *testing.T) {
23 | // Don't assert @pointsto(t) since its label contains a fragile line number.
24 | log(TestFoo)
25 | }
26 |
27 | func TestingQuux(t *testing.T) {
28 | // We can't assert @pointsto(t) since this is dead code.
29 | log(TestingQuux)
30 | }
31 |
32 | func BenchmarkFoo(b *testing.B) {
33 | }
34 |
35 | func ExampleBar() {
36 | }
37 |
38 | // Excludes TestingQuux.
39 | // @calls testing.tRunner -> main.Test
40 | // @calls testing.tRunner -> main.TestFoo
41 | // @calls testing.runExample -> main.ExampleBar
42 | // @calls (*testing.B).runN -> main.BenchmarkFoo
43 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/pointer/testdata/another.go:
--------------------------------------------------------------------------------
1 | // +build ignore
2 |
3 | package main
4 |
5 | var unknown bool
6 |
7 | type S string
8 |
9 | func incr(x int) int { return x + 1 }
10 |
11 | func main() {
12 | var i interface{}
13 | i = 1
14 | if unknown {
15 | i = S("foo")
16 | }
17 | if unknown {
18 | i = (func(int, int))(nil) // NB type compares equal to that below.
19 | }
20 | // Look, the test harness can handle equal-but-not-String-equal
21 | // types because we parse types and using a typemap.
22 | if unknown {
23 | i = (func(x int, y int))(nil)
24 | }
25 | if unknown {
26 | i = incr
27 | }
28 | print(i) // @types int | S | func(int, int) | func(int) int
29 |
30 | // NB, an interface may never directly alias any global
31 | // labels, even though it may contain pointers that do.
32 | print(i) // @pointsto makeinterface:func(x int) int | makeinterface:func(x int, y int) | makeinterface:func(int, int) | makeinterface:int | makeinterface:main.S
33 | print(i.(func(int) int)) // @pointsto main.incr
34 |
35 | print() // regression test for crash
36 | }
37 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/pointer/testdata/chanreflect1.go:
--------------------------------------------------------------------------------
1 | // +build ignore
2 |
3 | package main
4 |
5 | import "reflect"
6 |
7 | //
8 | // This test is very sensitive to line-number perturbations!
9 |
10 | // Test of channels with reflection.
11 |
12 | var a, b int
13 |
14 | func chanreflect1() {
15 | ch := make(chan *int, 0)
16 | crv := reflect.ValueOf(ch)
17 | crv.Send(reflect.ValueOf(&a))
18 | print(crv.Interface()) // @types chan *int
19 | print(crv.Interface().(chan *int)) // @pointsto makechan@testdata/chanreflect.go:15:12
20 | print(<-ch) // @pointsto main.a
21 | }
22 |
23 | func chanreflect2() {
24 | ch := make(chan *int, 0)
25 | ch <- &b
26 | crv := reflect.ValueOf(ch)
27 | r, _ := crv.Recv()
28 | print(r.Interface()) // @types *int
29 | print(r.Interface().(*int)) // @pointsto main.b
30 | }
31 |
32 | func main() {
33 | chanreflect1()
34 | chanreflect2()
35 | }
36 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/pointer/testdata/context.go:
--------------------------------------------------------------------------------
1 | // +build ignore
2 |
3 | package main
4 |
5 | // Test of context-sensitive treatment of certain function calls,
6 | // e.g. static calls to simple accessor methods.
7 |
8 | var a, b int
9 |
10 | type T struct{ x *int }
11 |
12 | func (t *T) SetX(x *int) { t.x = x }
13 | func (t *T) GetX() *int { return t.x }
14 |
15 | func context1() {
16 | var t1, t2 T
17 | t1.SetX(&a)
18 | t2.SetX(&b)
19 | print(t1.GetX()) // @pointsto main.a
20 | print(t2.GetX()) // @pointsto main.b
21 | }
22 |
23 | func context2() {
24 | id := func(x *int) *int {
25 | print(x) // @pointsto main.a | main.b
26 | return x
27 | }
28 | print(id(&a)) // @pointsto main.a
29 | print(id(&b)) // @pointsto main.b
30 |
31 | // Same again, but anon func has free vars.
32 | var c int // @line context2c
33 | id2 := func(x *int) (*int, *int) {
34 | print(x) // @pointsto main.a | main.b
35 | return x, &c
36 | }
37 | p, q := id2(&a)
38 | print(p) // @pointsto main.a
39 | print(q) // @pointsto c@context2c:6
40 | r, s := id2(&b)
41 | print(r) // @pointsto main.b
42 | print(s) // @pointsto c@context2c:6
43 | }
44 |
45 | func main() {
46 | context1()
47 | context2()
48 | }
49 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/pointer/testdata/conv.go:
--------------------------------------------------------------------------------
1 | // +build ignore
2 |
3 | package main
4 |
5 | import "unsafe"
6 |
7 | var a int
8 |
9 | func conv1() {
10 | // Conversions of channel direction.
11 | ch := make(chan int) // @line c1make
12 | print((<-chan int)(ch)) // @pointsto makechan@c1make:12
13 | print((chan<- int)(ch)) // @pointsto makechan@c1make:12
14 | }
15 |
16 | func conv2() {
17 | // string -> []byte/[]rune conversion
18 | s := "foo"
19 | ba := []byte(s) // @line c2ba
20 | ra := []rune(s) // @line c2ra
21 | print(ba) // @pointsto convert@c2ba:14
22 | print(ra) // @pointsto convert@c2ra:14
23 | }
24 |
25 | func conv3() {
26 | // Conversion of same underlying types.
27 | type PI *int
28 | pi := PI(&a)
29 | print(pi) // @pointsto main.a
30 |
31 | pint := (*int)(pi)
32 | print(pint) // @pointsto main.a
33 |
34 | // Conversions between pointers to identical base types.
35 | var y *PI = &pi
36 | var x **int = (**int)(y)
37 | print(*x) // @pointsto main.a
38 | print(*y) // @pointsto main.a
39 | y = (*PI)(x)
40 | print(*y) // @pointsto main.a
41 | }
42 |
43 | func conv4() {
44 | // Handling of unsafe.Pointer conversion is unsound:
45 | // we lose the alias to main.a and get something like new(int) instead.
46 | p := (*int)(unsafe.Pointer(&a)) // @line c2p
47 | print(p) // @pointsto convert@c2p:13
48 | }
49 |
50 | // Regression test for b/8231.
51 | func conv5() {
52 | type P unsafe.Pointer
53 | var i *struct{}
54 | _ = P(i)
55 | }
56 |
57 | func main() {
58 | conv1()
59 | conv2()
60 | conv3()
61 | conv4()
62 | conv5()
63 | }
64 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/pointer/testdata/flow.go:
--------------------------------------------------------------------------------
1 | // +build ignore
2 |
3 | package main
4 |
5 | // Demonstration of directionality of flow edges.
6 |
7 | func f1() {}
8 | func f2() {}
9 |
10 | var somepred bool
11 |
12 | // Tracking functions.
13 | func flow1() {
14 | s := f1
15 | p := f2
16 | q := p
17 | r := q
18 | if somepred {
19 | r = s
20 | }
21 | print(s) // @pointsto main.f1
22 | print(p) // @pointsto main.f2
23 | print(q) // @pointsto main.f2
24 | print(r) // @pointsto main.f1 | main.f2
25 | }
26 |
27 | // Tracking concrete types in interfaces.
28 | func flow2() {
29 | var s interface{} = 1
30 | var p interface{} = "foo"
31 | q := p
32 | r := q
33 | if somepred {
34 | r = s
35 | }
36 | print(s) // @types int
37 | print(p) // @types string
38 | print(q) // @types string
39 | print(r) // @types int | string
40 | }
41 |
42 | var g1, g2 int
43 |
44 | // Tracking addresses of globals.
45 | func flow3() {
46 | s := &g1
47 | p := &g2
48 | q := p
49 | r := q
50 | if somepred {
51 | r = s
52 | }
53 | print(s) // @pointsto main.g1
54 | print(p) // @pointsto main.g2
55 | print(q) // @pointsto main.g2
56 | print(r) // @pointsto main.g2 | main.g1
57 | }
58 |
59 | func main() {
60 | flow1()
61 | flow2()
62 | flow3()
63 | }
64 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/pointer/testdata/fmtexcerpt.go:
--------------------------------------------------------------------------------
1 | // +build ignore
2 |
3 | // This is a slice of the fmt package.
4 |
5 | package main
6 |
7 | type pp struct {
8 | field interface{}
9 | }
10 |
11 | func newPrinter() *pp {
12 | return new(pp)
13 | }
14 |
15 | func Fprintln(a ...interface{}) {
16 | p := newPrinter()
17 | p.doPrint(a, true, true)
18 | }
19 |
20 | func Println(a ...interface{}) {
21 | Fprintln(a...)
22 | }
23 |
24 | func (p *pp) doPrint(a []interface{}, addspace, addnewline bool) {
25 | print(a[0]) // @types S | string
26 | stringer := a[0].(interface {
27 | String() string
28 | })
29 |
30 | stringer.String()
31 | print(stringer) // @types S
32 | }
33 |
34 | type S int
35 |
36 | func (S) String() string { return "" }
37 |
38 | func main() {
39 | Println("Hello, World!", S(0))
40 | }
41 |
42 | // @calls (*main.pp).doPrint -> (main.S).String
43 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/pointer/testdata/hello.go:
--------------------------------------------------------------------------------
1 | // +build ignore
2 |
3 | package main
4 |
5 | import (
6 | "fmt"
7 | "os"
8 | )
9 |
10 | type S int
11 |
12 | var theS S
13 |
14 | func (s *S) String() string {
15 | print(s) // @pointsto main.theS
16 | return ""
17 | }
18 |
19 | func main() {
20 | // os.Args is considered intrinsically allocated,
21 | // but may also be set explicitly (e.g. on Windows), hence '...'.
22 | print(os.Args) // @pointsto | ...
23 | fmt.Println("Hello, World!", &theS)
24 | }
25 |
26 | // @calls main.main -> fmt.Println
27 | // @calls (*fmt.pp).handleMethods -> (*main.S).String
28 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/pointer/testdata/issue9002.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | func main() {
4 | // Regression test for golang issue 9002.
5 | //
6 | // The two-result "value,ok" receive operation generated a
7 | // too-wide constraint loading (value int, ok bool), not bool,
8 | // from the channel.
9 | //
10 | // This bug manifested itself in an out-of-bounds array access
11 | // when the makechan object was the highest-numbered node, as in
12 | // this program.
13 | //
14 | // In more realistic programs it silently resulted in bogus
15 | // constraints.
16 | _, _ = <-make(chan int)
17 | }
18 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/pointer/testdata/maps.go:
--------------------------------------------------------------------------------
1 | // +build ignore
2 |
3 | package main
4 |
5 | // Test of maps.
6 |
7 | var a, b, c int
8 |
9 | func maps1() {
10 | m1 := map[*int]*int{&a: &b} // @line m1m1
11 | m2 := make(map[*int]*int) // @line m1m2
12 | m2[&b] = &a
13 |
14 | print(m1[nil]) // @pointsto main.b | main.c
15 | print(m2[nil]) // @pointsto main.a
16 |
17 | print(m1) // @pointsto makemap@m1m1:21
18 | print(m2) // @pointsto makemap@m1m2:12
19 |
20 | m1[&b] = &c
21 |
22 | for k, v := range m1 {
23 | print(k) // @pointsto main.a | main.b
24 | print(v) // @pointsto main.b | main.c
25 | }
26 |
27 | for k, v := range m2 {
28 | print(k) // @pointsto main.b
29 | print(v) // @pointsto main.a
30 | }
31 |
32 | // Lookup doesn't create any aliases.
33 | print(m2[&c]) // @pointsto main.a
34 | if _, ok := m2[&a]; ok {
35 | print(m2[&c]) // @pointsto main.a
36 | }
37 | }
38 |
39 | func maps2() {
40 | m1 := map[*int]*int{&a: &b}
41 | m2 := map[*int]*int{&b: &c}
42 | _ = []map[*int]*int{m1, m2} // (no spurious merging of m1, m2)
43 |
44 | print(m1[nil]) // @pointsto main.b
45 | print(m2[nil]) // @pointsto main.c
46 | }
47 |
48 | func main() {
49 | maps1()
50 | maps2()
51 | }
52 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/pointer/testdata/panic.go:
--------------------------------------------------------------------------------
1 | // +build ignore
2 |
3 | package main
4 |
5 | // Test of value flow from panic() to recover().
6 | // We model them as stores/loads of a global location.
7 | // We ignore concrete panic types originating from the runtime.
8 |
9 | var someval int
10 |
11 | type myPanic struct{}
12 |
13 | func f(int) {}
14 |
15 | func g() string { return "" }
16 |
17 | func deadcode() {
18 | panic(123) // not reached
19 | }
20 |
21 | func main() {
22 | switch someval {
23 | case 0:
24 | panic("oops")
25 | case 1:
26 | panic(myPanic{})
27 | case 2:
28 | panic(f)
29 | case 3:
30 | panic(g)
31 | }
32 | ex := recover()
33 | print(ex) // @types myPanic | string | func(int) | func() string
34 | print(ex.(func(int))) // @pointsto main.f
35 | print(ex.(func() string)) // @pointsto main.g
36 | }
37 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/pointer/testdata/recur.go:
--------------------------------------------------------------------------------
1 | // +build ignore
2 |
3 | package main
4 |
5 | // Analysis abstraction of recursive calls is finite.
6 |
7 | func main() {
8 | main()
9 | }
10 |
11 | // @calls main.main -> main.main
12 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/pointer/testdata/rtti.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | // Regression test for oracle crash
4 | // https://code.google.com/p/go/issues/detail?id=6605
5 | //
6 | // Using reflection, methods may be called on types that are not the
7 | // operand of any ssa.MakeInterface instruction. In this example,
8 | // (Y).F is called by deriving the type Y from *Y. Prior to the fix,
9 | // no RTTI (or method set) for type Y was included in the program, so
10 | // the F() call would crash.
11 |
12 | import "reflect"
13 |
14 | var a int
15 |
16 | type X struct{}
17 |
18 | func (X) F() *int {
19 | return &a
20 | }
21 |
22 | type I interface {
23 | F() *int
24 | }
25 |
26 | func main() {
27 | type Y struct{ X }
28 | print(reflect.Indirect(reflect.ValueOf(new(Y))).Interface().(I).F()) // @pointsto main.a
29 | }
30 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/pointer/testdata/structreflect.go:
--------------------------------------------------------------------------------
1 | // +build ignore
2 |
3 | package main
4 |
5 | import "reflect"
6 |
7 | type A struct {
8 | f *int
9 | g interface{}
10 | h bool
11 | }
12 |
13 | var dyn string
14 |
15 | func reflectTypeFieldByName() {
16 | f, _ := reflect.TypeOf(A{}).FieldByName("f")
17 | print(f.Type) // @pointsto *int
18 |
19 | g, _ := reflect.TypeOf(A{}).FieldByName("g")
20 | print(g.Type) // @pointsto interface{}
21 | print(reflect.Zero(g.Type)) // @pointsto
22 | print(reflect.Zero(g.Type)) // @types interface{}
23 |
24 | print(reflect.Zero(g.Type).Interface()) // @pointsto
25 | print(reflect.Zero(g.Type).Interface()) // @types
26 |
27 | h, _ := reflect.TypeOf(A{}).FieldByName("h")
28 | print(h.Type) // @pointsto bool
29 |
30 | missing, _ := reflect.TypeOf(A{}).FieldByName("missing")
31 | print(missing.Type) // @pointsto
32 |
33 | dyn, _ := reflect.TypeOf(A{}).FieldByName(dyn)
34 | print(dyn.Type) // @pointsto *int | bool | interface{}
35 | }
36 |
37 | func reflectTypeField() {
38 | fld := reflect.TypeOf(A{}).Field(0)
39 | print(fld.Type) // @pointsto *int | bool | interface{}
40 | }
41 |
42 | func main() {
43 | reflectTypeFieldByName()
44 | reflectTypeField()
45 | }
46 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/pointer/testdata/timer.go:
--------------------------------------------------------------------------------
1 | // +build ignore
2 |
3 | package main
4 |
5 | import "time"
6 |
7 | func after() {}
8 |
9 | func main() {
10 | // @calls time.startTimer -> time.sendTime
11 | ticker := time.NewTicker(1)
12 | <-ticker.C
13 |
14 | // @calls time.startTimer -> time.sendTime
15 | timer := time.NewTimer(time.Second)
16 | <-timer.C
17 |
18 | // @calls time.startTimer -> time.goFunc
19 | // @calls time.goFunc -> main.after
20 | timer = time.AfterFunc(time.Second, after)
21 | <-timer.C
22 | }
23 |
24 | // @calls time.sendTime -> time.Now
25 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/ssa/interp/external_darwin.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build darwin
6 |
7 | package interp
8 |
9 | import "syscall"
10 |
11 | func init() {
12 | externals["syscall.Sysctl"] = ext۰syscall۰Sysctl
13 | }
14 |
15 | func ext۰syscall۰Sysctl(fr *frame, args []value) value {
16 | r, err := syscall.Sysctl(args[0].(string))
17 | return tuple{r, wrapError(err)}
18 | }
19 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/ssa/interp/external_freebsd.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build freebsd
6 |
7 | package interp
8 |
9 | import "syscall"
10 |
11 | func init() {
12 | externals["syscall.Sysctl"] = ext۰syscall۰Sysctl
13 | externals["syscall.SysctlUint32"] = ext۰syscall۰SysctlUint32
14 | }
15 |
16 | func ext۰syscall۰Sysctl(fr *frame, args []value) value {
17 | r, err := syscall.Sysctl(args[0].(string))
18 | return tuple{r, wrapError(err)}
19 | }
20 |
21 | func ext۰syscall۰SysctlUint32(fr *frame, args []value) value {
22 | r, err := syscall.SysctlUint32(args[0].(string))
23 | return tuple{r, wrapError(err)}
24 | }
25 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/ssa/interp/external_windows.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package interp
6 |
7 | import "syscall"
8 |
9 | func ext۰syscall۰Close(fr *frame, args []value) value {
10 | panic("syscall.Close not yet implemented")
11 | }
12 | func ext۰syscall۰Fstat(fr *frame, args []value) value {
13 | panic("syscall.Fstat not yet implemented")
14 | }
15 | func ext۰syscall۰Kill(fr *frame, args []value) value {
16 | panic("syscall.Kill not yet implemented")
17 | }
18 | func ext۰syscall۰Lstat(fr *frame, args []value) value {
19 | panic("syscall.Lstat not yet implemented")
20 | }
21 | func ext۰syscall۰Open(fr *frame, args []value) value {
22 | panic("syscall.Open not yet implemented")
23 | }
24 | func ext۰syscall۰ParseDirent(fr *frame, args []value) value {
25 | panic("syscall.ParseDirent not yet implemented")
26 | }
27 | func ext۰syscall۰Read(fr *frame, args []value) value {
28 | panic("syscall.Read not yet implemented")
29 | }
30 | func ext۰syscall۰ReadDirent(fr *frame, args []value) value {
31 | panic("syscall.ReadDirent not yet implemented")
32 | }
33 | func ext۰syscall۰Stat(fr *frame, args []value) value {
34 | panic("syscall.Stat not yet implemented")
35 | }
36 | func ext۰syscall۰Write(fr *frame, args []value) value {
37 | panic("syscall.Write not yet implemented")
38 | }
39 | func ext۰syscall۰RawSyscall(fr *frame, args []value) value {
40 | return tuple{uintptr(0), uintptr(0), uintptr(syscall.ENOSYS)}
41 | }
42 | func syswrite(fd int, b []byte) (int, error) {
43 | panic("syswrite not yet implemented")
44 | }
45 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/ssa/interp/testdata/a_test.go:
--------------------------------------------------------------------------------
1 | package a
2 |
3 | import "testing"
4 |
5 | func TestFoo(t *testing.T) {
6 | t.Error("foo")
7 | }
8 |
9 | func TestBar(t *testing.T) {
10 | t.Error("bar")
11 | }
12 |
13 | func BenchmarkWiz(b *testing.B) {
14 | b.Error("wiz")
15 | }
16 |
17 | // Don't test Examples since that testing package needs pipe(2) for that.
18 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/ssa/interp/testdata/b_test.go:
--------------------------------------------------------------------------------
1 | package b
2 |
3 | import "testing"
4 |
5 | func NotATest(t *testing.T) {
6 | t.Error("foo")
7 | }
8 |
9 | func NotABenchmark(b *testing.B) {
10 | b.Error("wiz")
11 | }
12 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/ssa/interp/testdata/callstack.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "path"
6 | "runtime"
7 | "strings"
8 | )
9 |
10 | var stack string
11 |
12 | func f() {
13 | pc := make([]uintptr, 6)
14 | pc = pc[:runtime.Callers(1, pc)]
15 | for _, f := range pc {
16 | Func := runtime.FuncForPC(f)
17 | name := Func.Name()
18 | if strings.Contains(name, "$") || strings.Contains(name, ".func") {
19 | name = "func" // anon funcs vary across toolchains
20 | }
21 | file, line := Func.FileLine(0)
22 | stack += fmt.Sprintf("%s at %s:%d\n", name, path.Base(file), line)
23 | }
24 | }
25 |
26 | func g() { f() }
27 | func h() { g() }
28 | func i() { func() { h() }() }
29 |
30 | // Hack: the 'func' and the call to Caller are on the same line,
31 | // to paper over differences between toolchains.
32 | // (The interpreter's location info isn't yet complete.)
33 | func runtimeCaller0() (uintptr, string, int, bool) { return runtime.Caller(0) }
34 |
35 | func main() {
36 | i()
37 | if stack != `main.f at callstack.go:12
38 | main.g at callstack.go:26
39 | main.h at callstack.go:27
40 | func at callstack.go:28
41 | main.i at callstack.go:28
42 | main.main at callstack.go:35
43 | ` {
44 | panic("unexpected stack: " + stack)
45 | }
46 |
47 | pc, file, line, _ := runtimeCaller0()
48 | got := fmt.Sprintf("%s @ %s:%d", runtime.FuncForPC(pc).Name(), path.Base(file), line)
49 | if got != "main.runtimeCaller0 @ callstack.go:33" {
50 | panic("runtime.Caller: " + got)
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/ssa/interp/testdata/complit.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | // Tests of composite literals.
4 |
5 | import "fmt"
6 |
7 | // Map literals.
8 | func init() {
9 | type M map[int]int
10 | m1 := []*M{{1: 1}, &M{2: 2}}
11 | want := "map[1:1] map[2:2]"
12 | if got := fmt.Sprint(*m1[0], *m1[1]); got != want {
13 | panic(got)
14 | }
15 | m2 := []M{{1: 1}, M{2: 2}}
16 | if got := fmt.Sprint(m2[0], m2[1]); got != want {
17 | panic(got)
18 | }
19 | }
20 |
21 | // Nonliteral keys in composite literal.
22 | func init() {
23 | const zero int = 1
24 | var v = []int{1 + zero: 42}
25 | if x := fmt.Sprint(v); x != "[0 0 42]" {
26 | panic(x)
27 | }
28 | }
29 |
30 | // Test for in-place initialization.
31 | func init() {
32 | // struct
33 | type S struct {
34 | a, b int
35 | }
36 | s := S{1, 2}
37 | s = S{b: 3}
38 | if s.a != 0 {
39 | panic("s.a != 0")
40 | }
41 | if s.b != 3 {
42 | panic("s.b != 3")
43 | }
44 | s = S{}
45 | if s.a != 0 {
46 | panic("s.a != 0")
47 | }
48 | if s.b != 0 {
49 | panic("s.b != 0")
50 | }
51 |
52 | // array
53 | type A [4]int
54 | a := A{2, 4, 6, 8}
55 | a = A{1: 6, 2: 4}
56 | if a[0] != 0 {
57 | panic("a[0] != 0")
58 | }
59 | if a[1] != 6 {
60 | panic("a[1] != 6")
61 | }
62 | if a[2] != 4 {
63 | panic("a[2] != 4")
64 | }
65 | if a[3] != 0 {
66 | panic("a[3] != 0")
67 | }
68 | a = A{}
69 | if a[0] != 0 {
70 | panic("a[0] != 0")
71 | }
72 | if a[1] != 0 {
73 | panic("a[1] != 0")
74 | }
75 | if a[2] != 0 {
76 | panic("a[2] != 0")
77 | }
78 | if a[3] != 0 {
79 | panic("a[3] != 0")
80 | }
81 | }
82 |
83 | func main() {
84 | }
85 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/ssa/interp/testdata/defer.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | // Tests of defer. (Deferred recover() belongs is recover.go.)
4 |
5 | import "fmt"
6 |
7 | func deferMutatesResults(noArgReturn bool) (a, b int) {
8 | defer func() {
9 | if a != 1 || b != 2 {
10 | panic(fmt.Sprint(a, b))
11 | }
12 | a, b = 3, 4
13 | }()
14 | if noArgReturn {
15 | a, b = 1, 2
16 | return
17 | }
18 | return 1, 2
19 | }
20 |
21 | func init() {
22 | a, b := deferMutatesResults(true)
23 | if a != 3 || b != 4 {
24 | panic(fmt.Sprint(a, b))
25 | }
26 | a, b = deferMutatesResults(false)
27 | if a != 3 || b != 4 {
28 | panic(fmt.Sprint(a, b))
29 | }
30 | }
31 |
32 | // We concatenate init blocks to make a single function, but we must
33 | // run defers at the end of each block, not the combined function.
34 | var deferCount = 0
35 |
36 | func init() {
37 | deferCount = 1
38 | defer func() {
39 | deferCount++
40 | }()
41 | // defer runs HERE
42 | }
43 |
44 | func init() {
45 | // Strictly speaking the spec says deferCount may be 0 or 2
46 | // since the relative order of init blocks is unspecified.
47 | if deferCount != 2 {
48 | panic(deferCount) // defer call has not run!
49 | }
50 | }
51 |
52 | func main() {
53 | }
54 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/ssa/interp/testdata/ifaceprom.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | // Test of promotion of methods of an interface embedded within a
4 | // struct. In particular, this test exercises that the correct
5 | // method is called.
6 |
7 | type I interface {
8 | one() int
9 | two() string
10 | }
11 |
12 | type S struct {
13 | I
14 | }
15 |
16 | type impl struct{}
17 |
18 | func (impl) one() int {
19 | return 1
20 | }
21 |
22 | func (impl) two() string {
23 | return "two"
24 | }
25 |
26 | func main() {
27 | var s S
28 | s.I = impl{}
29 | if one := s.I.one(); one != 1 {
30 | panic(one)
31 | }
32 | if one := s.one(); one != 1 {
33 | panic(one)
34 | }
35 | closOne := s.I.one
36 | if one := closOne(); one != 1 {
37 | panic(one)
38 | }
39 | closOne = s.one
40 | if one := closOne(); one != 1 {
41 | panic(one)
42 | }
43 |
44 | if two := s.I.two(); two != "two" {
45 | panic(two)
46 | }
47 | if two := s.two(); two != "two" {
48 | panic(two)
49 | }
50 | closTwo := s.I.two
51 | if two := closTwo(); two != "two" {
52 | panic(two)
53 | }
54 | closTwo = s.two
55 | if two := closTwo(); two != "two" {
56 | panic(two)
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/ssa/interp/testdata/initorder.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import "fmt"
4 |
5 | // Test of initialization order of package-level vars.
6 |
7 | var counter int
8 |
9 | func next() int {
10 | c := counter
11 | counter++
12 | return c
13 | }
14 |
15 | func next2() (x int, y int) {
16 | x = next()
17 | y = next()
18 | return
19 | }
20 |
21 | func makeOrder() int {
22 | _, _, _, _ = f, b, d, e
23 | return 0
24 | }
25 |
26 | func main() {
27 | // Initialization constraints:
28 | // - {f,b,c/d,e} < order (ref graph traversal)
29 | // - order < {a} (lexical order)
30 | // - b < c/d < e < f (lexical order)
31 | // Solution: a b c/d e f
32 | abcdef := [6]int{a, b, c, d, e, f}
33 | if abcdef != [6]int{0, 1, 2, 3, 4, 5} {
34 | panic(abcdef)
35 | }
36 | }
37 |
38 | var order = makeOrder()
39 |
40 | var a, b = next(), next()
41 | var c, d = next2()
42 | var e, f = next(), next()
43 |
44 | // ------------------------------------------------------------------------
45 |
46 | var order2 []string
47 |
48 | func create(x int, name string) int {
49 | order2 = append(order2, name)
50 | return x
51 | }
52 |
53 | var C = create(B+1, "C")
54 | var A, B = create(1, "A"), create(2, "B")
55 |
56 | // Initialization order of package-level value specs.
57 | func init() {
58 | x := fmt.Sprint(order2)
59 | // Result varies by toolchain. This is a spec bug.
60 | if x != "[B C A]" && // gc
61 | x != "[A B C]" { // go/types
62 | panic(x)
63 | }
64 | if C != 3 {
65 | panic(c)
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/ssa/interp/testdata/methprom.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | // Tests of method promotion logic.
4 |
5 | type A struct{ magic int }
6 |
7 | func (a A) x() {
8 | if a.magic != 1 {
9 | panic(a.magic)
10 | }
11 | }
12 | func (a *A) y() *A {
13 | return a
14 | }
15 |
16 | type B struct{ magic int }
17 |
18 | func (b B) p() {
19 | if b.magic != 2 {
20 | panic(b.magic)
21 | }
22 | }
23 | func (b *B) q() {
24 | if b != theC.B {
25 | panic("oops")
26 | }
27 | }
28 |
29 | type I interface {
30 | f()
31 | }
32 |
33 | type impl struct{ magic int }
34 |
35 | func (i impl) f() {
36 | if i.magic != 3 {
37 | panic("oops")
38 | }
39 | }
40 |
41 | type C struct {
42 | A
43 | *B
44 | I
45 | }
46 |
47 | func assert(cond bool) {
48 | if !cond {
49 | panic("failed")
50 | }
51 | }
52 |
53 | var theC = C{
54 | A: A{1},
55 | B: &B{2},
56 | I: impl{3},
57 | }
58 |
59 | func addr() *C {
60 | return &theC
61 | }
62 |
63 | func value() C {
64 | return theC
65 | }
66 |
67 | func main() {
68 | // address
69 | addr().x()
70 | if addr().y() != &theC.A {
71 | panic("oops")
72 | }
73 | addr().p()
74 | addr().q()
75 | addr().f()
76 |
77 | // addressable value
78 | var c C = value()
79 | c.x()
80 | if c.y() != &c.A {
81 | panic("oops")
82 | }
83 | c.p()
84 | c.q()
85 | c.f()
86 |
87 | // non-addressable value
88 | value().x()
89 | // value().y() // not in method set
90 | value().p()
91 | value().q()
92 | value().f()
93 | }
94 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/ssa/interp/testdata/mrvchain.go:
--------------------------------------------------------------------------------
1 | // Tests of call chaining f(g()) when g has multiple return values (MRVs).
2 | // See https://code.google.com/p/go/issues/detail?id=4573.
3 |
4 | package main
5 |
6 | func assert(actual, expected int) {
7 | if actual != expected {
8 | panic(actual)
9 | }
10 | }
11 |
12 | func g() (int, int) {
13 | return 5, 7
14 | }
15 |
16 | func g2() (float64, float64) {
17 | return 5, 7
18 | }
19 |
20 | func f1v(x int, v ...int) {
21 | assert(x, 5)
22 | assert(v[0], 7)
23 | }
24 |
25 | func f2(x, y int) {
26 | assert(x, 5)
27 | assert(y, 7)
28 | }
29 |
30 | func f2v(x, y int, v ...int) {
31 | assert(x, 5)
32 | assert(y, 7)
33 | assert(len(v), 0)
34 | }
35 |
36 | func complexArgs() (float64, float64) {
37 | return 5, 7
38 | }
39 |
40 | func appendArgs() ([]string, string) {
41 | return []string{"foo"}, "bar"
42 | }
43 |
44 | func h() (i interface{}, ok bool) {
45 | m := map[int]string{1: "hi"}
46 | i, ok = m[1] // string->interface{} conversion within multi-valued expression
47 | return
48 | }
49 |
50 | func h2() (i interface{}, ok bool) {
51 | ch := make(chan string, 1)
52 | ch <- "hi"
53 | i, ok = <-ch // string->interface{} conversion within multi-valued expression
54 | return
55 | }
56 |
57 | func main() {
58 | f1v(g())
59 | f2(g())
60 | f2v(g())
61 | if c := complex(complexArgs()); c != 5+7i {
62 | panic(c)
63 | }
64 | if s := append(appendArgs()); len(s) != 2 || s[0] != "foo" || s[1] != "bar" {
65 | panic(s)
66 | }
67 | i, ok := h()
68 | if !ok || i.(string) != "hi" {
69 | panic(i)
70 | }
71 | i, ok = h2()
72 | if !ok || i.(string) != "hi" {
73 | panic(i)
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/ssa/interp/testdata/range.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | // Tests of range loops.
4 |
5 | import "fmt"
6 |
7 | // Range over string.
8 | func init() {
9 | if x := len("Hello, 世界"); x != 13 { // bytes
10 | panic(x)
11 | }
12 | var indices []int
13 | var runes []rune
14 | for i, r := range "Hello, 世界" {
15 | runes = append(runes, r)
16 | indices = append(indices, i)
17 | }
18 | if x := fmt.Sprint(runes); x != "[72 101 108 108 111 44 32 19990 30028]" {
19 | panic(x)
20 | }
21 | if x := fmt.Sprint(indices); x != "[0 1 2 3 4 5 6 7 10]" {
22 | panic(x)
23 | }
24 | s := ""
25 | for _, r := range runes {
26 | s = fmt.Sprintf("%s%c", s, r)
27 | }
28 | if s != "Hello, 世界" {
29 | panic(s)
30 | }
31 |
32 | var x int
33 | for range "Hello, 世界" {
34 | x++
35 | }
36 | if x != len(indices) {
37 | panic(x)
38 | }
39 | }
40 |
41 | // Regression test for range of pointer to named array type.
42 | func init() {
43 | type intarr [3]int
44 | ia := intarr{1, 2, 3}
45 | var count int
46 | for _, x := range &ia {
47 | count += x
48 | }
49 | if count != 6 {
50 | panic(count)
51 | }
52 | }
53 |
54 | func main() {
55 | }
56 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/ssa/interp/testdata/recover.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | // Tests of panic/recover.
4 |
5 | import "fmt"
6 |
7 | func fortyTwo() (r int) {
8 | r = 42
9 | // The next two statements simulate a 'return' statement.
10 | defer func() { recover() }()
11 | panic(nil)
12 | }
13 |
14 | func zero() int {
15 | defer func() { recover() }()
16 | panic(1)
17 | }
18 |
19 | func zeroEmpty() (int, string) {
20 | defer func() { recover() }()
21 | panic(1)
22 | }
23 |
24 | func main() {
25 | if r := fortyTwo(); r != 42 {
26 | panic(r)
27 | }
28 | if r := zero(); r != 0 {
29 | panic(r)
30 | }
31 | if r, s := zeroEmpty(); r != 0 || s != "" {
32 | panic(fmt.Sprint(r, s))
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/ssa/interp/testdata/reflect.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import "reflect"
4 |
5 | func main() {
6 | // Regression test for issue 9462.
7 | got := reflect.SliceOf(reflect.TypeOf(byte(0))).String()
8 | if got != "[]uint8" && got != "[]byte" { // result varies by toolchain
9 | println("BUG: " + got)
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/ssa/interp/testdata/static.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | // Static tests of SSA builder (via the sanity checker).
4 | // Dynamic semantics are not exercised.
5 |
6 | func init() {
7 | // Regression test for issue 6806.
8 | ch := make(chan int)
9 | select {
10 | case n, _ := <-ch:
11 | _ = n
12 | default:
13 | // The default case disables the simplification of
14 | // select to a simple receive statement.
15 | }
16 |
17 | // value,ok-form receive where TypeOf(ok) is a named boolean.
18 | type mybool bool
19 | var x int
20 | var y mybool
21 | select {
22 | case x, y = <-ch:
23 | default:
24 | // The default case disables the simplification of
25 | // select to a simple receive statement.
26 | }
27 | _ = x
28 | _ = y
29 | }
30 |
31 | var a int
32 |
33 | // Regression test for issue 7840 (covered by SSA sanity checker).
34 | func bug7840() bool {
35 | // This creates a single-predecessor block with a φ-node.
36 | return false && a == 0 && a == 0
37 | }
38 |
39 | // A blocking select (sans "default:") cannot fall through.
40 | // Regression test for issue 7022.
41 | func bug7022() int {
42 | var c1, c2 chan int
43 | select {
44 | case <-c1:
45 | return 123
46 | case <-c2:
47 | return 456
48 | }
49 | }
50 |
51 | // Parens should not prevent intrinsic treatment of built-ins.
52 | // (Regression test for a crash.)
53 | func init() {
54 | _ = (new)(int)
55 | _ = (make)([]int, 0)
56 | }
57 |
58 | func main() {}
59 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/types/go11.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !go1.2
6 |
7 | package types
8 |
9 | import "go/ast"
10 |
11 | func slice3(x *ast.SliceExpr) bool {
12 | return false
13 | }
14 |
15 | func sliceMax(x *ast.SliceExpr) ast.Expr {
16 | return nil
17 | }
18 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/types/go12.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build go1.2
6 |
7 | package types
8 |
9 | import "go/ast"
10 |
11 | func slice3(x *ast.SliceExpr) bool {
12 | return x.Slice3
13 | }
14 |
15 | func sliceMax(x *ast.SliceExpr) ast.Expr {
16 | return x.Max
17 | }
18 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/types/objset.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // This file implements objsets.
6 | //
7 | // An objset is similar to a Scope but objset elements
8 | // are identified by their unique id, instead of their
9 | // object name.
10 |
11 | package types
12 |
13 | // An objset is a set of objects identified by their unique id.
14 | // The zero value for objset is a ready-to-use empty objset.
15 | type objset map[string]Object // initialized lazily
16 |
17 | // insert attempts to insert an object obj into objset s.
18 | // If s already contains an alternative object alt with
19 | // the same name, insert leaves s unchanged and returns alt.
20 | // Otherwise it inserts obj and returns nil.
21 | func (s *objset) insert(obj Object) Object {
22 | id := obj.Id()
23 | if alt := (*s)[id]; alt != nil {
24 | return alt
25 | }
26 | if *s == nil {
27 | *s = make(map[string]Object)
28 | }
29 | (*s)[id] = obj
30 | return nil
31 | }
32 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/types/testdata/blank.src:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package _ /* ERROR invalid package name */
6 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/types/testdata/cycles1.src:
--------------------------------------------------------------------------------
1 | // Copyright 2013 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package p
6 |
7 | type (
8 | A interface {
9 | a() interface {
10 | ABC1
11 | }
12 | }
13 | B interface {
14 | b() interface {
15 | ABC2
16 | }
17 | }
18 | C interface {
19 | c() interface {
20 | ABC3
21 | }
22 | }
23 |
24 | AB interface {
25 | A
26 | B
27 | }
28 | BC interface {
29 | B
30 | C
31 | }
32 |
33 | ABC1 interface {
34 | A
35 | B
36 | C
37 | }
38 | ABC2 interface {
39 | AB
40 | C
41 | }
42 | ABC3 interface {
43 | A
44 | BC
45 | }
46 | )
47 |
48 | var (
49 | x1 ABC1
50 | x2 ABC2
51 | x3 ABC3
52 | )
53 |
54 | func _() {
55 | // all types have the same method set
56 | x1 = x2
57 | x2 = x1
58 |
59 | x1 = x3
60 | x3 = x1
61 |
62 | x2 = x3
63 | x3 = x2
64 |
65 | // all methods return the same type again
66 | x1 = x1.a()
67 | x1 = x1.b()
68 | x1 = x1.c()
69 |
70 | x2 = x2.a()
71 | x2 = x2.b()
72 | x2 = x2.c()
73 |
74 | x3 = x3.a()
75 | x3 = x3.b()
76 | x3 = x3.c()
77 | }
78 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/types/testdata/cycles3.src:
--------------------------------------------------------------------------------
1 | // Copyright 2013 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package p
6 |
7 | import "unsafe"
8 |
9 | var (
10 | _ A = A(nil).a().b().c().d().e().f()
11 | _ A = A(nil).b().c().d().e().f()
12 | _ A = A(nil).c().d().e().f()
13 | _ A = A(nil).d().e().f()
14 | _ A = A(nil).e().f()
15 | _ A = A(nil).f()
16 | _ A = A(nil)
17 | )
18 |
19 | type (
20 | A interface {
21 | a() B
22 | B
23 | }
24 |
25 | B interface {
26 | b() C
27 | C
28 | }
29 |
30 | C interface {
31 | c() D
32 | D
33 | }
34 |
35 | D interface {
36 | d() E
37 | E
38 | }
39 |
40 | E interface {
41 | e() F
42 | F
43 | }
44 |
45 | F interface {
46 | f() A
47 | }
48 | )
49 |
50 | type (
51 | U interface {
52 | V
53 | }
54 |
55 | V interface {
56 | v() [unsafe.Sizeof(u)]int
57 | }
58 | )
59 |
60 | var u U
61 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/types/testdata/expr1.src:
--------------------------------------------------------------------------------
1 | // Copyright 2012 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // binary expressions
6 |
7 | package expr1
8 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/types/testdata/importdecl0a.src:
--------------------------------------------------------------------------------
1 | // Copyright 2013 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package importdecl0
6 |
7 | import ()
8 |
9 | import (
10 | // we can have multiple blank imports (was bug)
11 | _ "math"
12 | _ "net/rpc"
13 | init /* ERROR "cannot declare init" */ "fmt"
14 | // reflect defines a type "flag" which shows up in the gc export data
15 | "reflect"
16 | . /* ERROR "imported but not used" */ "reflect"
17 | )
18 |
19 | import "math" /* ERROR "imported but not used" */
20 | import m /* ERROR "imported but not used as m" */ "math"
21 | import _ "math"
22 |
23 | import (
24 | "math/big" /* ERROR "imported but not used" */
25 | b /* ERROR "imported but not used" */ "math/big"
26 | _ "math/big"
27 | )
28 |
29 | import "fmt"
30 | import f1 "fmt"
31 | import f2 "fmt"
32 |
33 | // reflect.flag must not be visible in this package
34 | type flag int
35 | type _ reflect /* ERROR "not exported" */ .flag
36 |
37 | // imported package name may conflict with local objects
38 | type reflect /* ERROR "reflect already declared" */ int
39 |
40 | // dot-imported exported objects may conflict with local objects
41 | type Value /* ERROR "Value already declared through dot-import of package reflect" */ struct{}
42 |
43 | var _ = fmt.Println // use "fmt"
44 |
45 | func _() {
46 | f1.Println() // use "fmt"
47 | }
48 |
49 | func _() {
50 | _ = func() {
51 | f2.Println() // use "fmt"
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/types/testdata/importdecl0b.src:
--------------------------------------------------------------------------------
1 | // Copyright 2013 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package importdecl0
6 |
7 | import "math"
8 | import m "math"
9 |
10 | import . "testing" // declares T in file scope
11 | import . /* ERROR "imported but not used" */ "unsafe"
12 | import . "fmt" // declares Println in file scope
13 |
14 | import (
15 | // TODO(gri) At the moment, 2 errors are reported because both go/parser
16 | // and the type checker report it. Eventually, this test should not be
17 | // done by the parser anymore.
18 | "" /* ERROR invalid import path */ /* ERROR invalid import path */
19 | "a!b" /* ERROR invalid import path */ /* ERROR invalid import path */
20 | "abc\xffdef" /* ERROR invalid import path */ /* ERROR invalid import path */
21 | )
22 |
23 | // using "math" in this file doesn't affect its use in other files
24 | const Pi0 = math.Pi
25 | const Pi1 = m.Pi
26 |
27 | type _ T // use "testing"
28 |
29 | func _() func() interface{} {
30 | return func() interface{} {
31 | return Println // use "fmt"
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/types/testdata/importdecl1a.src:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // Test case for issue 8969.
6 |
7 | package importdecl1
8 |
9 | import . "unsafe"
10 |
11 | var _ Pointer // use dot-imported package unsafe
12 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/types/testdata/importdecl1b.src:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package importdecl1
6 |
7 | import . /* ERROR "imported but not used" */ "unsafe"
8 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/types/token_test.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // This file checks invariants of token.Token ordering that we rely on
6 | // since package go/token doesn't provide any guarantees at the moment.
7 |
8 | package types
9 |
10 | import (
11 | "go/token"
12 | "testing"
13 | )
14 |
15 | var assignOps = map[token.Token]token.Token{
16 | token.ADD_ASSIGN: token.ADD,
17 | token.SUB_ASSIGN: token.SUB,
18 | token.MUL_ASSIGN: token.MUL,
19 | token.QUO_ASSIGN: token.QUO,
20 | token.REM_ASSIGN: token.REM,
21 | token.AND_ASSIGN: token.AND,
22 | token.OR_ASSIGN: token.OR,
23 | token.XOR_ASSIGN: token.XOR,
24 | token.SHL_ASSIGN: token.SHL,
25 | token.SHR_ASSIGN: token.SHR,
26 | token.AND_NOT_ASSIGN: token.AND_NOT,
27 | }
28 |
29 | func TestZeroTok(t *testing.T) {
30 | // zero value for token.Token must be token.ILLEGAL
31 | var zero token.Token
32 | if token.ILLEGAL != zero {
33 | t.Errorf("%s == %d; want 0", token.ILLEGAL, zero)
34 | }
35 | }
36 |
37 | func TestAssignOp(t *testing.T) {
38 | // there are fewer than 256 tokens
39 | for i := 0; i < 256; i++ {
40 | tok := token.Token(i)
41 | got := assignOp(tok)
42 | want := assignOps[tok]
43 | if got != want {
44 | t.Errorf("for assignOp(%s): got %s; want %s", tok, got, want)
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/types/typeutil/example_test.go:
--------------------------------------------------------------------------------
1 | package typeutil_test
2 |
3 | import (
4 | "fmt"
5 | "sort"
6 |
7 | "go/ast"
8 | "go/parser"
9 | "go/token"
10 |
11 | "golang.org/x/tools/go/types"
12 | "golang.org/x/tools/go/types/typeutil"
13 | )
14 |
15 | func ExampleMap() {
16 | const source = `package P
17 |
18 | var X []string
19 | var Y []string
20 |
21 | const p, q = 1.0, 2.0
22 |
23 | func f(offset int32) (value byte, ok bool)
24 | func g(rune) (uint8, bool)
25 | `
26 |
27 | // Parse and type-check the package.
28 | fset := token.NewFileSet()
29 | f, err := parser.ParseFile(fset, "P.go", source, 0)
30 | if err != nil {
31 | panic(err)
32 | }
33 | pkg, err := new(types.Config).Check("P", fset, []*ast.File{f}, nil)
34 | if err != nil {
35 | panic(err)
36 | }
37 |
38 | scope := pkg.Scope()
39 |
40 | // Group names of package-level objects by their type.
41 | var namesByType typeutil.Map // value is []string
42 | for _, name := range scope.Names() {
43 | T := scope.Lookup(name).Type()
44 |
45 | names, _ := namesByType.At(T).([]string)
46 | names = append(names, name)
47 | namesByType.Set(T, names)
48 | }
49 |
50 | // Format, sort, and print the map entries.
51 | var lines []string
52 | namesByType.Iterate(func(T types.Type, names interface{}) {
53 | lines = append(lines, fmt.Sprintf("%s %s", names, T))
54 | })
55 | sort.Strings(lines)
56 | for _, line := range lines {
57 | fmt.Println(line)
58 | }
59 |
60 | // Output:
61 | // [X Y] []string
62 | // [f g] func(offset int32) (value byte, ok bool)
63 | // [p q] untyped float
64 | }
65 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/types/typeutil/imports.go:
--------------------------------------------------------------------------------
1 | package typeutil
2 |
3 | import "golang.org/x/tools/go/types"
4 |
5 | // Dependencies returns all dependencies of the specified packages.
6 | //
7 | // Dependent packages appear in topological order: if package P imports
8 | // package Q, Q appears earlier than P in the result.
9 | // The algorithm follows import statements in the order they
10 | // appear in the source code, so the result is a total order.
11 | //
12 | func Dependencies(pkgs ...*types.Package) []*types.Package {
13 | var result []*types.Package
14 | seen := make(map[*types.Package]bool)
15 | var visit func(pkgs []*types.Package)
16 | visit = func(pkgs []*types.Package) {
17 | for _, p := range pkgs {
18 | if !seen[p] {
19 | seen[p] = true
20 | visit(p.Imports())
21 | result = append(result, p)
22 | }
23 | }
24 | }
25 | visit(pkgs)
26 | return result
27 | }
28 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/types/typeutil/ui.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package typeutil
6 |
7 | // This file defines utilities for user interfaces that display types.
8 |
9 | import "golang.org/x/tools/go/types"
10 |
11 | // IntuitiveMethodSet returns the intuitive method set of a type, T.
12 | //
13 | // The result contains MethodSet(T) and additionally, if T is a
14 | // concrete type, methods belonging to *T if there is no identically
15 | // named method on T itself. This corresponds to user intuition about
16 | // method sets; this function is intended only for user interfaces.
17 | //
18 | // The order of the result is as for types.MethodSet(T).
19 | //
20 | func IntuitiveMethodSet(T types.Type, msets *types.MethodSetCache) []*types.Selection {
21 | var result []*types.Selection
22 | mset := msets.MethodSet(T)
23 | if _, ok := T.Underlying().(*types.Interface); ok {
24 | for i, n := 0, mset.Len(); i < n; i++ {
25 | result = append(result, mset.At(i))
26 | }
27 | } else {
28 | pmset := msets.MethodSet(types.NewPointer(T))
29 | for i, n := 0, pmset.Len(); i < n; i++ {
30 | meth := pmset.At(i)
31 | if m := mset.Lookup(meth.Obj().Pkg(), meth.Obj().Name()); m != nil {
32 | meth = m
33 | }
34 | result = append(result, meth)
35 | }
36 | }
37 | return result
38 | }
39 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/go/vcs/env.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package vcs
6 |
7 | import (
8 | "os"
9 | "strings"
10 | )
11 |
12 | // envForDir returns a copy of the environment
13 | // suitable for running in the given directory.
14 | // The environment is the current process's environment
15 | // but with an updated $PWD, so that an os.Getwd in the
16 | // child will be faster.
17 | func envForDir(dir string) []string {
18 | env := os.Environ()
19 | // Internally we only use rooted paths, so dir is rooted.
20 | // Even if dir is not rooted, no harm done.
21 | return mergeEnvLists([]string{"PWD=" + dir}, env)
22 | }
23 |
24 | // mergeEnvLists merges the two environment lists such that
25 | // variables with the same name in "in" replace those in "out".
26 | func mergeEnvLists(in, out []string) []string {
27 | NextVar:
28 | for _, inkv := range in {
29 | k := strings.SplitAfterN(inkv, "=", 2)[0]
30 | for i, outkv := range out {
31 | if strings.HasPrefix(outkv, k) {
32 | out[i] = inkv
33 | continue NextVar
34 | }
35 | }
36 | out = append(out, inkv)
37 | }
38 | return out
39 | }
40 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/godoc/page.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package godoc
6 |
7 | import (
8 | "net/http"
9 | "runtime"
10 | )
11 |
12 | // Page describes the contents of the top-level godoc webpage.
13 | type Page struct {
14 | Title string
15 | Tabtitle string
16 | Subtitle string
17 | Query string
18 | Body []byte
19 |
20 | // filled in by servePage
21 | SearchBox bool
22 | Playground bool
23 | Version string
24 | }
25 |
26 | func (p *Presentation) ServePage(w http.ResponseWriter, page Page) {
27 | if page.Tabtitle == "" {
28 | page.Tabtitle = page.Title
29 | }
30 | page.SearchBox = p.Corpus.IndexEnabled
31 | page.Playground = p.ShowPlayground
32 | page.Version = runtime.Version()
33 | applyTemplateToResponseWriter(w, p.GodocHTML, page)
34 | }
35 |
36 | func (p *Presentation) ServeError(w http.ResponseWriter, r *http.Request, relpath string, err error) {
37 | w.WriteHeader(http.StatusNotFound)
38 | p.ServePage(w, Page{
39 | Title: "File " + relpath,
40 | Subtitle: relpath,
41 | Body: applyTemplate(p.ErrorHTML, "errorHTML", err), // err may contain an absolute path!
42 | })
43 | }
44 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/call-eg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/call-eg.png
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/call3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/call3.png
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/callers1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/callers1.png
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/callers2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/callers2.png
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/chan1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/chan1.png
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/chan2a.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/chan2a.png
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/chan2b.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/chan2b.png
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/error1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/error1.png
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/ident-def.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/ident-def.png
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/ident-field.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/ident-field.png
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/ident-func.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/ident-func.png
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/ipcg-func.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/ipcg-func.png
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/ipcg-pkg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/ipcg-pkg.png
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/typeinfo-pkg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/typeinfo-pkg.png
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/typeinfo-src.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/owenthereal/nut/351e37e97477d1b67162c071c03a75bf38ae0bb0/vendor/_nuts/golang.org/x/tools/godoc/static/analysis/typeinfo-src.png
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/godoc/static/callgraph.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
▹ Internal call graph
4 |
5 |
6 |
▾ Internal call graph
7 |
8 | This viewer shows the portion of the internal call
9 | graph of this package that is reachable from this function.
10 | See the package's call
11 | graph for more information.
12 |
32 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/godoc/static/doc.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // Package static exports a map of static file content that supports the godoc
6 | // user interface. The map should be used with the mapfs package, see
7 | // golang.org/x/tools/godoc/vfs/mapfs.
8 | package static
9 |
--------------------------------------------------------------------------------
/vendor/_nuts/golang.org/x/tools/godoc/static/error.html:
--------------------------------------------------------------------------------
1 |
6 |
7 |