Commit Graph

9 Commits

Author SHA1 Message Date
Jeroen Demeyer 6c8a8d054d
Go: make generated code more compliant to "go fmt" (#7907)
Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-04-26 05:19:07 +00:00
Michael Le 60975d6f7e
Add key lookup support for tables in Go (#7644)
* Add support for key lookup for tables in Go

* Run clang format

* Run go fmt on tests

* Remove TODO in tests

* Update LookupByKey API

* Update LookupByKey API

* Don't use resolvePointer in expectEq

* Use generated getters instead of reading values directly from buffer

* Fix typo

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-11-22 14:08:19 -08:00
Gh0u1L5 41d6903294
[Go] Fix GenNativeUnionUnPack for imported union type. (#7579)
* Fix GenNativeUnionUnPack for imported union type.

* Update test results.

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-11-13 11:52:02 -08:00
Somo bee1df96dc [Go] Replace references to hardcoded ”Monster" etc with idiomatic go wherever possible (#5716)
* go: replace objAPI-generated Pack func with method

See discussion at https://github.com/google/flatbuffers/issues/5668

* go: replace generated union type UnPack func with method

Similar to discussion https://github.com/google/flatbuffers/issues/5668

But signature:
```
func AnyUnPack(t Any, table flatbuffers.Table) *AnyT
```

Becomes,
```
func (rcv Any) UnPack(table flatbuffers.Table) *AnyT
```
2020-01-16 16:19:00 -08:00
Tiago Silva 3c964e10ab [GO] Fix support for enums with underscores and Unions with imported members (#5600)
* Fix Enum Stringer method when Enum has underscores

Fixes #5481

* Fix go package importing itself when Union has imported members.
2019-11-26 12:25:36 -08:00
iceboy 32254b7acd [Go] Object API support (#5339)
* start

* works for current usages!

* unpack: vector of struct

* optimize byte slice

* support nested struct

* support null table

* support struct

* support union

* update generated code

* grumble

* fix compiler warning

* update generated code

* wrap type in namespace

* bug

* wrap in namespace

* enum byte arrays

* generate struct for unions

* basic testing

* remove branching

* fix assert

* pack vector of fixed structs correctly

* omit null vectors

* Refactor Union Pack and UnPack methods

Remove append usage to increase code efficiency when dealing with large vectors

* generate goldens
2019-10-31 11:13:45 -07:00
iceboy 9d92fd92e1 Rename AnyUniqueAliases.T to AnyUniqueAliases.TS to avoid naming conflict (#5362) 2019-05-30 16:02:57 -07:00
David Reiss 718ddea558 [Go] Make enums into real types, add String() (#5235)
* [Go] Make enums into real types, add String()

This changes the generated code for enums: instead of type aliases,
they're now distinct types, allowing for better type-checking. Some
client code may have to be changed to add casts.

Enum types now have a String() method, so they implement fmt.Stringer.

An EnumValues map is now generated, in addition to the existing
EnumNames map, to easily map strings to values.

Generated enum files are now gofmt-clean.

Fixes #5207

* use example.ColorGreen explicitly

* use valid enum value in mutation test, add new test for "invalid" enum

* add length check and comment
2019-05-17 12:41:39 -07:00
Frank Benkstein 91fe9ba93f make unions with type aliases more usable (#5019)
Some generic C++ and Rust code is not generated when unions use type
aliases because of potential ambiguity. Actually check for this
ambiguity and only disable offending code only if it is found.
2018-11-01 12:51:25 -07:00