Last active
April 30, 2020 15:32
-
-
Save itaysk/26d87458a5f0530449c26fa2ccc33567 to your computer and use it in GitHub Desktop.
Embed file in Go using go link flag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/base64" | |
"fmt" | |
) | |
var myfile string | |
func main() { | |
contents, _ := base64.StdEncoding.DecodeString(myfile) | |
fmt.Println(string(contents)) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b64contents = $(shell base64 -w 0 myfile) | |
build: | |
go build -ldflags "-X main.myfile=$(b64contents)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment