works with mutex and without again
This commit is contained in:
parent
502826cf8c
commit
76968c90e8
4
Makefile
4
Makefile
|
@ -2,8 +2,8 @@ VERSION = $(shell git describe --tags)
|
|||
BUILDTIME = $(shell date +%Y.%m.%d_%H%M)
|
||||
|
||||
simple: build
|
||||
# make -C example clean simpleMutexGlobal goimports vet
|
||||
make -C example clean simpleMutexProtoc goimports vet
|
||||
make -C example clean simpleMutexGlobal goimports vet
|
||||
# make -C example clean simpleMutexProtoc goimports vet
|
||||
|
||||
full: install clean auto goimports vet build test install
|
||||
@echo everything worked and the example ran
|
||||
|
|
12
addMutex.go
12
addMutex.go
|
@ -48,7 +48,10 @@ func (pb *Files) addMutex(f *File) error {
|
|||
|
||||
w, _ := os.OpenFile(f.Pbfilename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
|
||||
|
||||
// the default is to insert a mutex directly into the struct
|
||||
if argv.Mutex {
|
||||
pbHeaderComment(w)
|
||||
}
|
||||
|
||||
lines := strings.Split(string(data), "\n")
|
||||
for _, line := range lines {
|
||||
|
@ -59,6 +62,12 @@ func (pb *Files) addMutex(f *File) error {
|
|||
// fmt.Fprintln(w, "package "+"main")
|
||||
continue
|
||||
}
|
||||
// the default is to insert a mutex directly into the struct
|
||||
if !argv.Mutex {
|
||||
// mutex is not to be added, only fix the package name
|
||||
fmt.Fprintln(w, line)
|
||||
continue
|
||||
}
|
||||
|
||||
if f.structMatch(line) {
|
||||
if argv.Mutex {
|
||||
|
@ -78,11 +87,14 @@ func (pb *Files) addMutex(f *File) error {
|
|||
fmt.Fprintln(w, line)
|
||||
}
|
||||
}
|
||||
if argv.Mutex {
|
||||
// verify every structure was found
|
||||
for _, msg := range f.MsgNames {
|
||||
if !msg.MutexFound && msg.DoMutex {
|
||||
return fmt.Errorf("addMutex() parse didn't work for %s", msg.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ syntax = "proto3";
|
|||
// "Fruits" MUST EXIST and start exactly this way
|
||||
// It must be "Fruit" + 's' and must match the name of this file: "fruit.proto"
|
||||
|
||||
package fruit;
|
||||
package main;
|
||||
|
||||
import "google/protobuf/timestamp.proto"; // Import the well-known type for Timestamp
|
||||
|
||||
|
|
Loading…
Reference in New Issue