I am reading some data from a YAML file inside my go code:
func main() {
yamlFile, err := ioutil.ReadFile("data.yaml")
if err != nil {
fmt.Println("Failed to open grid map file with err: ", err.Error())
return
// ... do something with the data from the yamlFile variable
}
However, when I make the binary using the go build
command, the YAML file does not get packaged into the binary file. Is there any way to package/embed it in the binary file using go 1.15? I do not want to use any CLI tools like statik, packr, pkger, etc as I have to incorporate it in an existing pipeline and that too without go generate
.
I know that this can be done in go 1.16 using the embed
package. But I have to use go 1.15.
The data in the YAML file will be provided by the user. Hence, hard coding is not an option.
The software will read the data from the YAML file and then the user can build the executable binary file using Docker to be deployed on their own hardware.