summaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
Diffstat (limited to 'example')
-rw-r--r--example/Makefile18
-rw-r--r--example/file.proto1
-rw-r--r--example/fruit.proto33
3 files changed, 45 insertions, 7 deletions
diff --git a/example/Makefile b/example/Makefile
index 22a8c65..3a045bd 100644
--- a/example/Makefile
+++ b/example/Makefile
@@ -4,6 +4,20 @@ BUILDTIME = $(shell date +%Y.%m.%d_%H%M)
all: clean simpleMutexProtoc goimports build
./example
+# if this passes, then autogenpb should be working
+# and it is OK to 'go install' the binary
+test: testGlobal testProtoc
+
+testGlobal:
+ make clean
+ ../autogenpb --proto fruit.proto --package main --mutex=false # first build with a global mutex
+ make build
+
+testProtoc:
+ make clean
+ ../autogenpb --proto fruit.proto --package main # inserts mutex into protoc .pb.go file
+ make build
+
modproto: clean withMutex goimports vet build
./example
@@ -47,6 +61,10 @@ withoutMutex: clean
../autogenpb --proto file.proto --package main --mutex=false
../autogenpb --proto patchset.proto --package main --mutex=false
+dryrun:
+ ../autogenpb --proto fruit.proto --package main --dry-run
+ # ../autogenpb --proto file.proto --package main
+
goimports:
goimports -w *.go
diff --git a/example/file.proto b/example/file.proto
index 18b096a..2f1b377 100644
--- a/example/file.proto
+++ b/example/file.proto
@@ -41,6 +41,7 @@ message MsgName {
repeated string sort = 7; // keys to sort on
repeated string unique = 8; // if the fields should have AppendUnique() functions
repeated MsgVar vars = 9; // store all the vars in the message
+ bool needIter = 10; // true if the sort iterator has not been generated yet
}
message File {
diff --git a/example/fruit.proto b/example/fruit.proto
index 92e46ef..d43a741 100644
--- a/example/fruit.proto
+++ b/example/fruit.proto
@@ -22,17 +22,35 @@ message Apple { // `autogenpb:marshal`
}
message Pear {
- string name = 1; //
- string favorite = 2; // `autogenpb:sort`
+ string name = 1; // `autogenpb:sort`
+ string favorite = 2; // `autogenpb:sort` `autogenpb:unique`
+}
+
+message Banana {
+ repeated string name = 1; // `autogenpb:sort`
+ string favorite = 2; // `autogenpb:sort` `autogenpb:unique`
+ string country = 3; // `autogenpb:sort`
+}
+
+message Basket {
+ repeated string name = 1; // `autogenpb:sort` `autogenpb:unique`
+ string favorite = 2; // `autogenpb:sort` `autogenpb:unique`
+ int64 price = 3; // `autogenpb:sort`
+ repeated Banana banna = 4;
+ repeated Pear pears = 5;
+ repeated Apple stacks = 6;
}
// "Fruit" must exist. you can put anything in it
message Fruit { // `autogenpb:marshal`
- string brand = 1; // `autogenpb:unique` `autogenpb:sort`
- repeated Apple apples = 2;
- repeated Pear pears = 3;
- string UPC = 4; // `autogenpb:sort` `autogenpb:unique`
- string city = 5; // `autogenpb:sort`
+ string brand = 1; // `autogenpb:unique` `autogenpb:sort`
+ repeated Apple apples = 2;
+ repeated Pear pears = 3;
+ string UPC = 4; // `autogenpb:sort` `autogenpb:unique`
+ string city = 5; // `autogenpb:sort`
+ repeated Pear notpears = 6;
+ repeated Pear fakepears = 7;
+ repeated Basket gifts = 8;
}
// "Fruits" MUST EXIST and start exactly this way
@@ -43,4 +61,5 @@ message Fruits { // `autogenpb:marshal` `autogenpb:mutex`
repeated Fruit Fruits = 3; // THIS MUST BE "Fruit" and then "Fruit" + "s"
// you can add additional things here but the three lines above must conform to the standard above
int64 cost = 4;
+ map<string, string> junk = 5;
}