How to access resource files after the 'go' tool installed the executable?

后端 未结 3 1162
情书的邮戳
情书的邮戳 2020-12-18 03:07

Lets assume that running go install -v importpath builds an executable and installs it into $GOPATH/bin/program. The go tool is unable

3条回答
  •  伪装坚强ぢ
    2020-12-18 03:46

    go install is not designed to do what you want to do.

    If you insist on using go install, you can embed the resources in the executable (byte arrays in source code).

    Another option is to use a deploy script that runs go install and then copies the resources to a place known by your executable.

    If you want your program to be installable by people other than you, you should use a packaging system that is standard on the os you're targeting (e.g. apt/rpm on Linux, an installer executable on Windows, .dmg file on Mac etc.)

提交回复
热议问题