...

Text file src/cmd/go/testdata/script/test_relative_import.txt

Documentation: cmd/go/testdata/script

     1# Relative imports in go test
     2env GO111MODULE=off # relative import not supported in module mode
     3
     4# Run tests outside GOPATH.
     5env GOPATH=$WORK/tmp
     6
     7go test ./testimport
     8stdout '^ok'
     9
    10-- testimport/p.go --
    11package p
    12
    13func F() int { return 1 }
    14-- testimport/p1/p1.go --
    15package p1
    16
    17func F() int { return 1 }
    18-- testimport/p_test.go --
    19package p
    20
    21import (
    22	"./p1"
    23
    24	"testing"
    25)
    26
    27func TestF(t *testing.T) {
    28	if F() != p1.F() {
    29		t.Fatal(F())
    30	}
    31}

View as plain text