获取父路径

I am creating Go command-line app and I need to generate some stuff in the current directory (the directory which the user execute the commands from)

to get the pwd I need to use

os.Getwd()

but this give me path like

/Users/s05333/go/src/appcmd

and I need path like this

/Users/s05333/go/src/

which option I've in this case? Omit the last string after the / or there is better way in Go?

Take a look at the filepath package, particularly filepath.Dir:

wd,err := os.Getwd()
if err != nil {
    panic(err)
}
parent := filepath.Dir(wd)

Per the docs:

Dir returns all but the last element of path, typically the path's directory.