Skip to content

Commit

Permalink
exporter: go, added docs
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Schleemilch <[email protected]>
  • Loading branch information
sschleemilch committed Sep 16, 2024
1 parent 0438348 commit 78189ea
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
63 changes: 63 additions & 0 deletions docs/go.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# 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

```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
```
```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
```
```bash
vspec export go --vspec model.vspec --types types.vspec --package vss --output vss.go
```

```go
package vss

type Vehicle struct {
Speed uint16
Location TypesGPSLocation
}
type TypesGPSLocation struct {
Longitude float32
Latitude float32
}
```

`--types-output` can be used to write `Types*` definitions into a separate file with the same package name.
1 change: 1 addition & 0 deletions docs/vspec.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ vspec export json --vspec spec/VehicleSignalSpecification.vspec --output vss.jso
- [id](./id.md)
- [protobuf](./protobuf.md)
- [samm](./samm.md)
- [go](./go.md)

## Argument Explanations

Expand Down

0 comments on commit 78189ea

Please sign in to comment.