{"id":1229,"hash":"a88d5642df18dff1053e234790628f22c7fbba0d9b16331d9659bb117016923d","pattern":"&quot;undefined&quot; function declared in another file?","full_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:\n\nundefined: NewEmployee\n\nHere is the source code:\n\nmain.go:\n\npackage main\n\nfunc main() {\nemp := NewEmployee()    \n}\n\nemployee.go:\n\npackage main\n\ntype Employee struct {\n    name string\n    age int\n}   \n\nfunc NewEmployee() *Employee {\n    p := &Employee{}\n    return p\n}\n\nfunc PrintEmployee (p *Employee)  {\n    return \"Hello world!\"\n}","ecosystem":"go","package_name":"undefined","package_version":null,"solution":"Please read \"How to Write Go Code\".\n\nUse 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.\n\nWhile 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.","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/28153203/undefined-function-declared-in-another-file","votes":269,"created_at":"2026-04-19T04:52:38.788238+00:00","updated_at":"2026-04-19T04:52:38.788238+00:00"}