I am new to golang and I need to understand how GO implements the packages in general. I want to implement a local package to separate my code and keep it organized.
I have the following example:
nums.go
package nums
func Even(i int) bool {
return i % 2 == 0
}
func Odd(i int) bool {
return i % 2 == 1
}
main.go
package main
import (
"./nums"
"fmt"
)
func main() {
a := 5
b := 6
fmt.Printf("%d is even %v?\n", a, nums.Even(a))
fmt.Printf("%d is odd %v?\n", b, nums.Odd(b))
}
Trying to run the go run main.go
command throws me the following error:
main.go: 4: 5: open / home / ubuntu / workspace / nums: no such file or directory
Why is this? What am I doing wrong?