goundefined95% confidence\u2191 269

"undefined" function declared in another file?

Full error message
I'm trying to write a basic go program that calls a function on a different file, but a part of the same package. However, it returns:

undefined: NewEmployee

Here is the source code:

main.go:

package main

func main() {
emp := NewEmployee()    
}

employee.go:

package main

type Employee struct {
    name string
    age int
}   

func NewEmployee() *Employee {
    p := &Employee{}
    return p
}

func PrintEmployee (p *Employee)  {
    return "Hello world!"
}

Please read "How to Write Go Code". Use go build or go install within the package directory, or supply an import path for the package. Do not use file arguments for build or install. While you can use file arguments for go run, you should build a package instead, usually with go run ., though you should almost always use go install, or go build.

API access

Get this solution programmatically \u2014 free, no authentication.

curl https://depscope.dev/api/error/a88d5642df18dff1053e234790628f22c7fbba0d9b16331d9659bb117016923d
hash \u00b7 a88d5642df18dff1053e234790628f22c7fbba0d9b16331d9659bb117016923d
"undefined" function declared in another file? — DepScope fix | DepScope