craft_parts.plugins.go_plugin module¶
The Go plugin.
- class craft_parts.plugins.go_plugin.GoPlugin(*, properties, part_info)[source]¶
Bases:
Plugin
A plugin for go projects using go.mod.
The go plugin requires a go compiler installed on your system. This can be achieved by adding the appropriate golang package to
build-packages
, or to have it installed or built in a different part. In this case, the name of the part supplying the go compiler must be “go”.The go plugin uses the common plugin keywords as well as those for “sources”. Additionally, the following plugin-specific keywords can be used:
go-buildtags
(list of strings) Tags to use during the go build. Default is not to use any build tags.go-generate
(list of strings) Parameters to pass to go generate before building. Each item on the list will be a separate go generate call. Default is not to call go generate.
- Parameters:
properties (
PluginProperties
)part_info (
PartInfo
)
- get_build_commands()[source]¶
Return a list of commands to run during the build step.
- Return type:
list
[str
]
- get_build_environment()[source]¶
Return a dictionary with the environment to use in the build step.
- Return type:
dict
[str
,str
]
- get_build_packages()[source]¶
Return a set of required packages to install in the build environment.
- Return type:
set
[str
]
- get_build_snaps()[source]¶
Return a set of required snaps to install in the build environment.
- Return type:
set
[str
]
- properties_class¶
alias of
GoPluginProperties
- validator_class¶
alias of
GoPluginEnvironmentValidator
- class craft_parts.plugins.go_plugin.GoPluginEnvironmentValidator(*, part_name, env, properties)[source]¶
Bases:
PluginEnvironmentValidator
Check the execution environment for the Go plugin.
- Parameters:
part_name (
str
) – The part whose build environment is being validated.env (
str
) – A string containing the build step environment setup.properties (
PluginProperties
)
- validate_environment(*, part_dependencies=None)[source]¶
Ensure the environment contains dependencies needed by the plugin.
- Parameters:
part_dependencies (
Optional
[list
[str
]]) – A list of the parts this part depends on.- Raises:
PluginEnvironmentValidationError – If go is invalid and there are no parts named go.
- Return type:
None
- class craft_parts.plugins.go_plugin.GoPluginProperties(**data)[source]¶
Bases:
PluginProperties
The part properties used by the Go plugin.
- Parameters:
data (
Any
)
-
go_buildtags:
list
[str
]¶
-
go_generate:
list
[str
]¶
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}¶
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function PluginProperties.<lambda>>, 'extra': 'forbid', 'frozen': True, 'validate_assignment': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'go_buildtags': FieldInfo(annotation=list[str], required=False, default=[], alias='go-buildtags', alias_priority=1), 'go_generate': FieldInfo(annotation=list[str], required=False, default=[], alias='go-generate', alias_priority=1), 'plugin': FieldInfo(annotation=Literal['go'], required=False, default='go', alias='plugin', alias_priority=1), 'source': FieldInfo(annotation=str, required=True, alias='source', alias_priority=1)}¶
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
-
plugin:
Literal
['go'
]¶
-
source:
str
¶