Created
April 6, 2020 11:16
-
-
Save wiless/624cc1324e8ed3ecc9fd9e59ba7a3a50 to your computer and use it in GitHub Desktop.
Read small icon files and covert to []byte variable to embed in go code
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 ( | |
"fmt" | |
"io/ioutil" | |
"os" | |
"strings" | |
) | |
// Reads the input file (e.g. favicon.ico) and creates outputs variable=[...bytes].. build go files with the output for embeddineg ico impages | |
func main() { | |
f, _ := os.Open(os.Args[1]) | |
data, _ := ioutil.ReadAll(f) | |
str := fmt.Sprintf("%d", data) | |
str = strings.ReplaceAll(str, " ", ",") | |
str = strings.ReplaceAll(str, "[", "{") | |
str = strings.ReplaceAll(str, "]", "}") | |
fmt.Println("package main\n var favicon=[]byte", str) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment