我有一个具有以下目录结构的 Go 1.14 项目:
myapp/
server/
payments/
capture_payment.go
capture_payment_test.go
billing/
billing.go
billing_test.go
fulfillment/
fulfillment.go
fulfillment_test.go
在我的billing.go
文件中,我有:
package billing
import (
"fmt"
)
func Flim() {
fmt.Println("FLIM")
}
在我的fulfillment_test.go
文件中,我有:
package fulfillment
import (
"fmt"
)
func Flam() {
fmt.Println("FLAM")
}
在我的capture_payment_test.go
文件中,我有:
package payments
import (
"testing"
"github.com/myorg/myapp/billing"
"github.com/myorg/myapp/fulfillment"
)
func TestSomething(t *testing.T) {
billing.Flim()
fulfillment.Flam()
}
当我cd
进入server/payments
并运行时,go test
我收到以下错误:
$ go test
# github.com/myorg/myapp/server/payments [github.com/myorg/myapp/server/payment.test]
./capture_payment_test.go:12:2: undefined: fulfillment.Flam
FAIL github.com/myorg/myapp/server/payments [build failed]
谁能发现为什么 fulfillment.Flam()
未定义,但billing.Flim()
完全没问题?