summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-11-29 11:56:57 -0600
committerJeff Carr <[email protected]>2024-11-29 11:56:57 -0600
commitdc640a6ccb70fa15a7d0cf3132aa0d484ea3b0f4 (patch)
treeb8a1b602988670ced877718efcc3a79426e21b88 /main.go
parent07e556e3799f815958c7c097686d6ba7176bbe33 (diff)
autogen the marshal file
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'main.go')
-rw-r--r--main.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/main.go b/main.go
index 1f0f6b9..312843b 100644
--- a/main.go
+++ b/main.go
@@ -26,7 +26,7 @@ func main() {
if !shell.Exists(argv.Proto) {
log.Info("protobuf", argv.Proto, "is missing")
- if ! argv.DryRun {
+ if !argv.DryRun {
os.Exit(-1)
}
}
@@ -54,6 +54,7 @@ func main() {
sortmap := make(map[string]string)
sortmap["package"] = packageName
+ sortmap["protobase"] = protobase
sortmap["base"] = argv.LoBase
sortmap["lock"] = sortmap["base"] + "slock"
sortmap["Base"] = argv.UpBase
@@ -79,13 +80,19 @@ func main() {
iterSort(f, sortmap)
iterAppend(f, sortmap)
iterEnd(f, sortmap)
+
+ // make the foo.marshal.pb.go file
+ marshal(sortmap)
}
func header(w io.Writer, names map[string]string) {
fmt.Fprintln(w, "package "+names["package"])
fmt.Fprintln(w, "")
- fmt.Fprintln(w, "// this is becoming a standard format")
- fmt.Fprintln(w, "// todo: autogenerate this from the .proto file?")
+ fmt.Fprintln(w, "// this file was autogenerated with autogenpb")
+ fmt.Fprintln(w, "//")
+ fmt.Fprintln(w, "// you might be able to use it on simple, strictly defined protobuf files")
+ fmt.Fprintln(w, "//")
+ fmt.Fprintln(w, "// go install go.wit.com/apps/autogenpb@latest")
fmt.Fprintln(w, "")
fmt.Fprintln(w, "import (")
fmt.Fprintln(w, " \"fmt\"")