Skip to content
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

RSDK-9266: improve comments in golang module templates #4600

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions cli/module_generate/_templates/go/models/tmpl-module.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,30 @@ func init() {
}

type Config struct {
// Put config attributes here

/* if your model does not need a config,
replace *Config in the init function with resource.NoNativeConfig */
/*
Put config attributes here. There should be public/exported fields
with a `json` parameter at the end of each attribute.

Example config struct:
type Config struct {
Pin string `json:"pin"`
Board string `json:"board"`
MinDeg *float64 `json:"min_angle_deg,omitempty"`
}

If your model does not need a config, replace *Config in the init
function with resource.NoNativeConfig
*/

/* Uncomment this if your model does not need to be validated
and has no implicit dependecies. */
// resource.TriviallyValidateConfig

}

// Validate ensures all parts of the config are valid and important fields exist.
// Returns implicit dependencies based on the config.
// The path is the JSON path in your robot's config (not the `Config` struct) to the
// resource being validated; e.g. "components.0".
func (cfg *Config) Validate(path string) ([]string, error) {
// Add config validation code here
return nil, nil
Expand Down
23 changes: 18 additions & 5 deletions cli/module_generate/scripts/tmpl-module
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,30 @@ func init() {
}

type Config struct {
// Put config attributes here

/* if your model does not need a config,
replace *Config in the init function with resource.NoNativeConfig */
/*
Put config attributes here. There should be public/exported fields
with a `json` parameter at the end of each attribute.

Example config struct:
type Config struct {
Pin string `json:"pin"`
Board string `json:"board"`
MinDeg *float64 `json:"min_angle_deg,omitempty"`
}

If your model does not need a config, replace *Config in the init
function with resource.NoNativeConfig
*/

/* Uncomment this if your model does not need to be validated
and has no implicit dependecies. */
// resource.TriviallyValidateConfig

}

// Validate ensures all parts of the config are valid and important fields exist.
// Returns implicit dependencies based on the config.
// The path is the JSON path in your robot's config (not the `Config` struct) to the
// resource being validated; e.g. "components.0".
func (cfg *Config) Validate(path string) ([]string, error) {
// Add config validation code here
return nil, nil
Expand Down
Loading