summaryrefslogtreecommitdiff
path: root/generateHeader.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-01-11 04:03:41 -0600
committerJeff Carr <[email protected]>2025-01-11 04:03:41 -0600
commit1f9e4a682d3acf36aa7ee1279f1f9cc928bcd5fd (patch)
treeeac1d0677459b6cc55fc4eb292c6545d42315cbc /generateHeader.go
parentd8464bf21ffada0be45116e7a6c4573bcadbce1b (diff)
rename files
Diffstat (limited to 'generateHeader.go')
-rw-r--r--generateHeader.go45
1 files changed, 45 insertions, 0 deletions
diff --git a/generateHeader.go b/generateHeader.go
new file mode 100644
index 0000000..8d5fbfb
--- /dev/null
+++ b/generateHeader.go
@@ -0,0 +1,45 @@
+package main
+
+import (
+ "fmt"
+ "io"
+)
+
+func pbHeaderComment(w io.Writer) {
+ // technically this should be the first line and in this exact format:
+ fmt.Fprintln(w, "// Code modified by go.wit.com/apps/autogenpb DO NOT EDIT.")
+ fmt.Fprintln(w, "//")
+ fmt.Fprintln(w, "// user defined Mutex locks were auto added")
+ fmt.Fprintln(w, "//")
+ fmt.Fprintln(w, "// autogenpb version & build time:", VERSION, BUILDTIME)
+ fmt.Fprintln(w, "// autogenpb auto generates Sort(), Unique() and Marshal() functions")
+ fmt.Fprintln(w, "// go install go.wit.com/apps/autogenpb@latest")
+ fmt.Fprintln(w, "")
+}
+
+func headerComment(w io.Writer) {
+ // technically this should be the first line and in this exact format:
+ fmt.Fprintln(w, "// Code generated by go.wit.com/apps/autogenpb DO NOT EDIT.")
+ fmt.Fprintln(w, "// This file was autogenerated with autogenpb", VERSION, BUILDTIME)
+ fmt.Fprintln(w, "// go install go.wit.com/apps/autogenpb@latest")
+ fmt.Fprintln(w, "//")
+ fmt.Fprintln(w, "// define which structs (messages) you want to use in the .proto file")
+ fmt.Fprintln(w, "// Then sort.pb.go and marshal.pb.go files are autogenerated")
+ fmt.Fprintln(w, "//")
+ fmt.Fprintln(w, "// autogenpb uses it and has an example .proto file with instructions")
+ fmt.Fprintln(w, "//")
+ fmt.Fprintln(w, "")
+}
+
+func header(w io.Writer, pf *File) {
+ // header must come first
+ headerComment(w)
+ fmt.Fprintf(w, "package %s\n", pf.Package)
+ fmt.Fprintln(w, "")
+ fmt.Fprintln(w, "import (")
+ fmt.Fprintln(w, " \"fmt\"")
+ fmt.Fprintln(w, " \"sort\"")
+ fmt.Fprintln(w, " \"sync\"")
+ fmt.Fprintln(w, ")")
+ fmt.Fprintln(w, "")
+}