I'm trying to create and use a custom package in Go. It's probably something very obvious but I cannot find much information about this. Basically, I have these two files in the same folder:
mylib.go
package mylib
type SomeType struct {
}
main.go
package main
import (
"mylib"
)
func main() {
}
When I try to go run main.go
, I get this error:
main.go:4:2: import "mylib": cannot find package
I've tried to run go build mylib.go
first but it doesn't seem to be doing anything (no file generated, no error message). So any idea how I could do this?