$ go version
go version go1.14 darwin/amd64
$cat go.mod
module go-testgo 1.14
I have a sample project with following folder structure:
go-test
|- src
|— server
|----- server.go
|— test
|----- test.go
go.mod
go.sum
server.go is in package main and test.go is in package test.
I created this project using go mod init go-test and trying to build and run the project.
First issue is I’m not able to import the test folder in server.go:
import ( test "go-test/test )
I’m not able to build and run the project:
user-MacBook-Pro:src $ go build server/server.go
server/server.go:6:2: package go-test/test is not in GOROOT (/usr/local/opt/go/libexec/src/go-test/test)
user-MacBook-Pro:src $ go install
can't load package: package .: no Go files in /Users/c****/go-test/src
user-MacBook-Pro:src $ go get server
go get server: package server is not in GOROOT (/usr/local/opt/go/libexec/src/server)
user-MacBook-Pro:src $ go get server/server.go
go get server/server.go: malformed module path "server/server.go": missing dot in first path element
user-MacBook-Pro:src$ go get . server/server.go
go get .: path /Users/c****/go-test/src is not a package in module rooted at /Users/c****/go-test