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

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

View as plain text