Skip to content

Commit 4db82ef

Browse files
committed
enable outputing lmap only
1 parent 23127e0 commit 4db82ef

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

cmd/cmap-gen/main.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var (
2626
valueType = flag.String("vt", "interface{}", "value type")
2727
hashFn = flag.String("hfn", "cmap.DefaultKeyHasher", "hash func")
2828
pkgPath = flag.String("p", "", "package path")
29+
lmapOnly = flag.Bool("lmap", false, "generate LMap only")
2930

3031
toStdout = flag.Bool("stdout", false, "write the output to stdout rather than creating a package")
3132

@@ -65,7 +66,12 @@ func main() {
6566
}
6667
}
6768

68-
r, closeReaders := multiFileReader(filepath.Join(cmapBase, "cmap.go"), filepath.Join(cmapBase, "lmap.go"))
69+
files := []string{filepath.Join(cmapBase, "cmap.go"), filepath.Join(cmapBase, "lmap.go")}
70+
if *lmapOnly {
71+
files = files[1:]
72+
}
73+
74+
r, closeReaders := multiFileReader(files...)
6975
var (
7076
filters = getLineFilters()
7177
buf bytes.Buffer
@@ -100,7 +106,12 @@ package %s
100106
log.Fatalf("error compiling code: \n\t%s\n\n%s", strings.Join(errs, "\n\t"), src)
101107
}
102108

103-
fp := filepath.Join(*pkgPath, "cmap.go")
109+
var fp string
110+
if *lmapOnly {
111+
fp = filepath.Join(*pkgPath, "lmap.go")
112+
} else {
113+
fp = filepath.Join(*pkgPath, "cmap.go")
114+
}
104115

105116
if *verbose {
106117
log.Printf("writing typed cmap %s.CMap[%s][%s] (using HashFn: %s) to file %s...", *pkgName, *keyType, *valueType, *hashFn, fp)

0 commit comments

Comments
 (0)