diff options
Diffstat (limited to 'addMutex.go')
| -rw-r--r-- | addMutex.go | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/addMutex.go b/addMutex.go index 082d1bc..fc1af97 100644 --- a/addMutex.go +++ b/addMutex.go @@ -13,8 +13,8 @@ import ( "go.wit.com/log" ) -func addMutex(names map[string]string) error { - fullname := names["protobase"] + ".pb.go" +func (pb *Files) addMutex(f *File) error { + fullname := f.Filebase + ".pb.go" log.Info("fullname:", fullname) data, err := os.ReadFile(fullname) if err != nil { @@ -22,14 +22,21 @@ func addMutex(names map[string]string) error { return err } - w, _ := os.OpenFile(names["protobase"]+".pb.go", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) + w, _ := os.OpenFile(f.Filebase+".pb.go", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) var found bool lines := strings.Split(string(data), "\n") for _, line := range lines { + if strings.HasPrefix(line, "package ") { + log.Info("CHANGING package:", line, "to package:", f.Package) + fmt.Fprintln(w, "package "+f.Package) + // log.Info("CHANGING package:", line, "to package:main") + // fmt.Fprintln(w, "package "+"main") + continue + } // log.Info("line:", line) - start := "type " + names["Bases"] + " struct {" + start := "type " + "sunshine" + " struct {" if strings.HasSuffix(line, start) { found = true log.Info("FOUND line:", line) |
