summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--header.go5
-rw-r--r--main.go3
-rw-r--r--sort.go7
-rw-r--r--sortnew.go6
4 files changed, 12 insertions, 9 deletions
diff --git a/header.go b/header.go
index 6c38fed..3b267dc 100644
--- a/header.go
+++ b/header.go
@@ -23,10 +23,11 @@ func headerComment(w io.Writer) {
fmt.Fprintln(w, "")
}
-func header(w io.Writer, names map[string]string) {
+func header(w io.Writer, pf *File) {
// header must come first
headerComment(w)
- fmt.Fprintln(w, "package "+names["package"])
+ fmt.Fprintf(w, "package %s\n", pf.Package)
+ fmt.Fprintln(w, "")
fmt.Fprintln(w, "import (")
fmt.Fprintln(w, " \"fmt\"")
fmt.Fprintln(w, " \"sort\"")
diff --git a/main.go b/main.go
index c242ffd..81963b6 100644
--- a/main.go
+++ b/main.go
@@ -166,7 +166,8 @@ func main() {
sortmap["Bases"] = sortmap["Base"] + "s"
}
- // pb.makeSortfile(f)
+ pb.makeSortfile(f)
+ pb.makeNewSortfile(f)
}
func okExit(s string) {
diff --git a/sort.go b/sort.go
index bc376ed..1d202a6 100644
--- a/sort.go
+++ b/sort.go
@@ -7,10 +7,11 @@ import (
"strings"
)
-func makeSortfile() {
- f, _ := os.OpenFile(sortmap["protobase"]+".sort.pb.go", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
+// passes in the protobuf file protobuf
+func (pb *Files) makeSortfile(pf *File) {
+ f, _ := os.OpenFile(pf.Filebase+".sort.pb.go", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
- header(f, sortmap)
+ header(f, pf)
if sortmap["lock"] == "all" {
// if the lock is set to 'all' this means the mutex was put in the protoc-gen-go struct
diff --git a/sortnew.go b/sortnew.go
index 6479a2d..5b6084b 100644
--- a/sortnew.go
+++ b/sortnew.go
@@ -5,10 +5,10 @@ import (
"strings"
)
-func makeNewSortfile() {
- f, _ := os.OpenFile(sortmap["protobase"]+".newsort.pb.go", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
+func (pb *Files) makeNewSortfile(pf *File) {
+ f, _ := os.OpenFile(pf.Filebase+".newsort.pb.go", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
- header(f, sortmap)
+ header(f, pf)
if sortmap["lock"] == "all" {
// if the lock is set to 'all' this means the mutex was put in the protoc-gen-go struct