Fail to compile when move files to a sub-folder

I have a folder named util, and it contains several files related. So I want to move them into a sub-folder named value. I don’t change their package name, so they are still with “package util”

    renamed:    util/func.go -> util/value/func.go
    renamed:    util/transform.go -> util/value/transform.go
    renamed:    util/unit.go -> util/value/unit.go

In util, there are callers in file conf.go to call functions in these files. But after moving files to sub-folder, it can’t find the functions in value.

go build
util/conf.go:227:2: undefined: loadConfigPluginData

I use

If the files are in a different folder, they are in a different package, you need to import them then and also make sure that the symbols you reference are exported (uppercase).

1 Like