-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[GO] Verifier #8030
base: master
Are you sure you want to change the base?
[GO] Verifier #8030
Conversation
Pull from google/flatbuffers
If a struct has a key the vector has to be sorted. To sort the vector you can't use "const".
* option indent_step is supported
Pull from google
Pull from google
Pull from master
go/verify.go
Outdated
// | ||
// /* Verify Monster table. Buffer name is 'MONS' and contains data length prefix */ | ||
// isValid := verifier.VerifyBuffer("MONS", true, MonsterVerify) | ||
func (verifier *Verifier) VerifyBuffer(identifier []byte, sizePrefixed bool, verifyObjFunc VerifyTableFunc) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In other places, I've used the type string
for the identifier, see for example the code in go/lib.go
and the FooIdentifier
constants in the generated code. So I suggest to use string
also in this code, for consistency.
Interestingly, your last example line
isValid := verifier.VerifyBuffer("MONS", true, MonsterVerify)
already assumes a string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
docs/source/GoUsage.md
Outdated
For a more detailed control of verification `MonsterVerify` for `Monster` | ||
type can be used: | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.go} | ||
# Sequence of calls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a mixture of Go and Python syntax somehow...
- To fix
b'MONS'
, I suggest simply using strings, so that would become"MONS"
. - The trailing
\
is invalid and can be removed as the line end with a.
- Comments start with
//
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To many different languages at the same time. fixed.
docs/source/GoUsage.md
Outdated
Each root type will have a verification function generated for it, | ||
e.g. `VerifyMonster`. This can be called as shown: | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.go} | ||
ok := VerifyMonster(buf); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove trailing ;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
tests/MyGame/Example/Any.go
Outdated
switch Any(typeId) { | ||
case AnyMonster: | ||
result = MonsterVerify(verifier, tablePos) | ||
break |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Go
, these break
statements are not needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
tests/MyGame/Example/Referrable.go
Outdated
@@ -47,6 +47,11 @@ func FinishReferrableBuffer(builder *flatbuffers.Builder, offset flatbuffers.UOf | |||
builder.Finish(offset) | |||
} | |||
|
|||
func VerifyReferrable(buf []byte) bool { | |||
return flatbuffers.NewVerifier(buf).VerifyBuffer(nil, false, ReferrableVerify) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid generating an empty line here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
What about the build step |
Any updates? |
This pull request is stale because it has been open 6 months with no activity. Please comment or label |
This pull request is stale because it has been open 6 months with no activity. Please comment or label |
not-stale |
Here a PR for verifier for GO.
I have added