Last active
July 26, 2019 15:36
-
-
Save kasvith/5a7683dc8833db7e29c86867767ff4c2 to your computer and use it in GitHub Desktop.
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
resources := make(map[string][]byte) | |
err := filepath.Walk("resources", func(path string, info os.FileInfo, err error) error { | |
if err != nil { | |
log.Println("Error :", err) | |
return err | |
} | |
relativePath := filepath.ToSlash(strings.TrimPrefix(path, "resources")) | |
if info.IsDir() { | |
log.Println(path, "is a directory, skipping...") | |
return nil | |
} else { | |
log.Println(path, "is a file, baking in...") | |
b, err := ioutil.ReadFile(path) | |
if err != nil { | |
log.Printf("Error reading %s: %s", path, err) | |
return err | |
} | |
resources[relativePath] = b | |
} | |
return nil | |
}) | |
if err != nil { | |
log.Fatal("Error walking through resources directory:",err) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment