Add flag to disable datatype exports?
mjmar01 opened this issue · 4 comments
When compiling into an existing package it might be desirable to not export any functions or datatypes. This would be usefull in cases where the functions only get used inside the package or if I want to write my own wrapper functions to convert between types or similar.
Sounds reasonable and happy to add this, but until then as workarounds:
For the former case you could put it into an internal
subdirectory so its API was only exposed to a parent package.
For the latter case, in the past I've added converters.go
or etc files sitting along side generated files in the same package for that purpose.
But again, not an unreasonable ask.
A few things. Most of them relate to sub types and slices of sub types.
- There is a little typo in the parameter
-private-defintions
:) - Type declarations are now lower case, references are still upper case in some places:
type block struct {
a string
b string
} // Correct
type body struct {
c Block
} // Block not found
- Point 2 also applies when pre allocating space for arrays using make(). So something like this might occur:
bbp.block = make([]Block, iohelp.ReadUint32Bytes(buf[at:])) // Block not found
- The functions
maketype
andmaketypeFromBytes
are called likeMakeType...
which will say unknown function - Relating to 4 the new functions are not properly camelCase so
maketype
instead ofmakeType
- Finally it might be good to run a go fmt over the output
Functionality it works tho. Does what I wanted it to
Did a more thorough look through with additional tests. I thought about adding a --format
option to the CLI, but it's not a great experience:
- If you don't have gofmt installed, the program will error (and so we cannot just run
gofmt
always) - If you want to use a formatter that doesn't accept
-w $file
to rewrite a file in place, you can't bebopc-go ... --format "gofmt"
is not an improvement overbebopc-go ...; gofmt -w ...
; the latter has the benefit that you can use whatever formatter accepting whatever arguments you want.