-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Sebastian Schleemilch <[email protected]>
- Loading branch information
1 parent
4e186f2
commit ec100a4
Showing
10 changed files
with
651 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Go lang struct exporter | ||
|
||
This exporter produces type struct definitions for the [go](https://go.dev/) programming language. | ||
|
||
## Exporter specific arguments | ||
|
||
### `--package` | ||
|
||
The name of the package the generated sources (output and types output) will have. | ||
|
||
# Example | ||
|
||
Input model: | ||
```yaml | ||
# model.vspec | ||
Vehicle: | ||
type: branch | ||
description: Vehicle | ||
Vehicle.Speed: | ||
type: sensor | ||
description: Speed | ||
datatype: uint16 | ||
Vehicle.Location: | ||
type: sensor | ||
description: Location | ||
datatype: Types.GPSLocation | ||
``` | ||
Input type definitions: | ||
```yaml | ||
# types.vspec | ||
Types: | ||
type: branch | ||
description: Custom Types | ||
Types.GPSLocation: | ||
type: struct | ||
description: GPS Location | ||
Types.GPSLocation.Longitude: | ||
type: property | ||
description: Longitude | ||
datatype: float | ||
Types.GPSLocation.Latitude: | ||
type: property | ||
description: Latitude | ||
datatype: float | ||
``` | ||
Generator call: | ||
```bash | ||
vspec export go --vspec model.vspec --types types.vspec --package vss --output vss.go | ||
``` | ||
|
||
Generated file: | ||
```go | ||
// vss.go | ||
package vss | ||
|
||
type Vehicle struct { | ||
Speed uint16 | ||
Location GPSLocation | ||
} | ||
type GPSLocation struct { | ||
Longitude float32 | ||
Latitude float32 | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.