I'm trying to follow the Writing an intepreter in Go book, by Thorsten Ball, and in the first chapter he establish this simple scheme
file /Users/myuser/projects/monkey/token/token.go
file /Users/myuser/projects/monkey/lexer/lexer.go
file /Users/myuser/projects/monkey/lexer/lexer_test.go
In lexer/lexer.go and lexer/lexer_test.g the files start as
package lexer
And in lexer_test.go the imports are
import (
"testing"
"monkey/token"
)
Then he says that for running the test, I have to run (from /Users/myuser/projects/monkey directory):
go test lexer/lexer_test.go
But when I do this, I receive the error:
lexer/lexer_test.go:6:2: cannot find package "monkey/token" in any of:
/usr/local/opt/go/libexec/src/monkey/token (from $GOROOT)
/Users/myuser/golang/src/monkey/token (from $GOPATH)
FAIL command-line-arguments [setup failed]
FAIL
I've been trying to understand how to configure the packages in go, but I found a lot of very complicated documentation about GOPATH, GOROOT and go.mod. I've been trying all this approach without get rid of the issue.
Can someone help me please? I'm sure is a simple fix but I cannot figure it out :(
question from:
https://stackoverflow.com/questions/65871966/how-to-config-a-simple-go-project 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…