Skip to content
This repository was archived by the owner on Sep 19, 2018. It is now read-only.

Commit bfe36d3

Browse files
author
Jim Teeuwen
committed
Merge pull request #108 from liggitt/nometadata
Allow excluding metadata from built assets
2 parents dce55d0 + 7f4fb11 commit bfe36d3

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

config.go

+2
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ type Config struct {
127127
// repository.
128128
Dev bool
129129

130+
// When true, size, mode and modtime are not preserved from files
131+
NoMetadata bool
130132
// When nonzero, use this as mode for all files.
131133
Mode uint
132134
// When nonzero, use this as unix timestamp for all files.

go-bindata/main.go

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ func parseArgs() *bindata.Config {
4747
flag.StringVar(&c.Package, "pkg", c.Package, "Package name to use in the generated code.")
4848
flag.BoolVar(&c.NoMemCopy, "nomemcopy", c.NoMemCopy, "Use a .rodata hack to get rid of unnecessary memcopies. Refer to the documentation to see what implications this carries.")
4949
flag.BoolVar(&c.NoCompress, "nocompress", c.NoCompress, "Assets will *not* be GZIP compressed when this flag is specified.")
50+
flag.BoolVar(&c.NoMetadata, "nometadata", c.NoMetadata, "Assets will not preserve size, mode, and modtime info.")
5051
flag.UintVar(&c.Mode, "mode", c.Mode, "Optional file mode override for all files.")
5152
flag.Int64Var(&c.ModTime, "modtime", c.ModTime, "Optional modification unix timestamp override for all files.")
5253
flag.StringVar(&c.Output, "o", c.Output, "Optional name of the output file to be generated.")

release.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,12 @@ func asset_release_common(w io.Writer, c *Config, asset *Asset) error {
359359

360360
mode := uint(fi.Mode())
361361
modTime := fi.ModTime().Unix()
362-
362+
size := fi.Size()
363+
if c.NoMetadata {
364+
mode = 0
365+
modTime = 0
366+
size = 0
367+
}
363368
if c.Mode > 0 {
364369
mode = uint(os.ModePerm) & c.Mode
365370
}
@@ -377,6 +382,6 @@ func asset_release_common(w io.Writer, c *Config, asset *Asset) error {
377382
return a, nil
378383
}
379384
380-
`, asset.Func, asset.Func, asset.Name, fi.Size(), mode, modTime)
385+
`, asset.Func, asset.Func, asset.Name, size, mode, modTime)
381386
return err
382387
}

0 commit comments

Comments
 (0)