Answer the question
In order to leave comments, you need to log in
golang. Self-written package is not visible from the main module?
Started learning Go and just can't beat a simple problem.
Go 1.16
In accordance with the examples, I do this:
1. Set GOPATH = c:\projects\go
2. In the c:\projects\go folder I create the src subfolder
3. In the scr folder I create the mytest directory and folders, I get the following structure:
src\ mytest\package1
src\mytest\cmd
4. In package1 I create a package1.go file:
package paсkage1
// RetVal test function
func RetVal() string {
return "passed"
}
package main
import (
"fmt"
"mytest/package1"
)
func main() {
fmt.Println("Test of package:")
fmt.Println(package1.RetVal())
}
main.go:5:2: package mytest/package1 is not in GOROOT (c:\go\src\mytest\paсkage1)
Answer the question
In order to leave comments, you need to log in
Either get an old version of Go like the youtubers have, or finally start using go modules .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question