I am trying to import a package in Golang, however I am unable to refrence a function declared within the package.
The following code is for the package i'm trying to import.
//image.go
pacakage image
import "pixel"
type Image struct {
Matrix [][]pixel.Pixel
}
func New(width, height int) *Image{
//Code
}
The following code is for the main file
//main.go
pacakage main
import (
"image"
"fmt"
)
func main(){
img := image.New(10,4)
fmt.Println(img)
}
When I run the main.go with go run main.go I get an error that says
undefined: image.New
I have ensured that my function is defined with an uppercase letter so i'm unsure why I'm able to call the New function. I am however able to declare a new image.Image variable.
Edit:
The problem was that I was developing outside the designated GOPATH/src. I was creating a file outside the GOPATH and resetting my GOPATH to my work file. This prevented me from properly importing and compiling my packages.