use filepath.Base
This commit is contained in:
parent
0b66b118b8
commit
23174e1f56
3 changed files with 4 additions and 2 deletions
|
@ -5,6 +5,7 @@ import (
|
|||
"encoding/gob"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
type assetKey struct {
|
||||
|
@ -12,6 +13,7 @@ type assetKey struct {
|
|||
path string
|
||||
}
|
||||
|
||||
// LoadGobz gunzips and gob-decodes a component from a file from a FS.
|
||||
func LoadGobz(dst interface{}, assets fs.FS, path string) error {
|
||||
f, err := assets.Open(path)
|
||||
if err != nil {
|
||||
|
@ -28,7 +30,7 @@ func LoadGobz(dst interface{}, assets fs.FS, path string) error {
|
|||
// SaveGobz takes an object, gob-encodes it, gzips it, and writes to disk.
|
||||
// This requires running on something with a disk to write to (not JS)
|
||||
func SaveGobz(src interface{}, name string) error {
|
||||
f, err := os.CreateTemp(".", name)
|
||||
f, err := os.CreateTemp(".", filepath.Base(name))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Binary file not shown.
2
main.go
2
main.go
|
@ -145,7 +145,7 @@ func writeLevel1() {
|
|||
},
|
||||
}
|
||||
|
||||
if err := engine.SaveGobz(level1, "level1.gobz"); err != nil {
|
||||
if err := engine.SaveGobz(level1, "game/assets/level1.gobz"); err != nil {
|
||||
log.Fatalf("Couldn't save level1.gobz: %v", err)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue