I am new to GO (and procedural programming) and I was working on an example code
My main.go import statement is
package main
import (
"fmt"
"packagetest/mymath"
)
func main() {
fmt.Println(mymath.Add(2, 3))
}
My mymath.go package is
package mymath
func Add(a, b int) int {
return a + b
}
func sub(a, b int) int {
return a - b
}
My GOPATH is C:\Users\tonyf\Desktop\go-workspace-2.0
This is where my main.go is C:\Users\tonyf\Desktop\go-workspace-2.0\src\packagetest
This is where my mymath.go is C:\Users\tonyf\Desktop\go-workspace-2.0\src\packagetest\mymath
When I run main.go i get a error like this
main.go:5:2: package packagetest/mymath is not in GOROOT (C:\Program Files\Go\src\packagetest\mymath)
And problem
could not import packagetest/mymath (cannot find package "packagetest/mymath" in any of
C:\Program Files\Go\src\packagetest\mymath (from $GOROOT)
C\src\packagetest\mymath (from $GOPATH)
\Users\tonyf\Desktop\go-workspace-2.0\src\packagetest\mymath (from $GOPATH))
Please Help