golang
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Installation
dagger install github.com/purpleclay/daggerverse/golang@v0.1.0
Entrypoint
Return Type
Golang !
Arguments
Name | Type | Description |
---|---|---|
image | Container | a custom base image containing an installation of golang |
src | Directory ! | a path to a directory containing the source code |
Example
dagger -m github.com/purpleclay/daggerverse/golang@4675abf5a511c33f41b15028fcd9e2f6d961691d call \
--src DIR_PATH
func (m *myModule) example(src *Directory) *Golang {
return dag.
Golang(src)
}
@function
def example(src: dagger.Directory) -> dag.Golang:
return (
dag.golang(src)
)
@func()
example(src: Directory): Golang {
return dag
.golang(src)
}
Types
Golang 🔗
Golang dagger function
modVersion() 🔗
Echoes the version of go used by a target project
Return Type
String !
Example
dagger -m github.com/purpleclay/daggerverse/golang@4675abf5a511c33f41b15028fcd9e2f6d961691d call \
--src DIR_PATH mod-version
func (m *myModule) example(ctx context.Context, src *Directory) string {
return dag.
Golang(src).
ModVersion(ctx)
}
@function
async def example(src: dagger.Directory) -> str:
return await (
dag.golang(src)
.mod_version()
)
@func()
async example(src: Directory): Promise<string> {
return dag
.golang(src)
.modVersion()
}
build() 🔗
Build a static release binary without debug information or symbols
Return Type
Directory !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
main | String | - | the path to the main.go file of the project |
out | String | - | the name of the built binary |
os | String | - | the target operating system |
arch | String | - | the target architecture |
Example
dagger -m github.com/purpleclay/daggerverse/golang@4675abf5a511c33f41b15028fcd9e2f6d961691d call \
--src DIR_PATH build
func (m *myModule) example(src *Directory) *Directory {
return dag.
Golang(src).
Build()
}
@function
def example(src: dagger.Directory) -> dagger.Directory:
return (
dag.golang(src)
.build()
)
@func()
example(src: Directory): Directory {
return dag
.golang(src)
.build()
}
test() 🔗
Execute tests defined within the target project, ignores benchmarks by default
Return Type
Directory !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
short | Boolean | true | if only short running tests should be executed |
shuffle | Boolean | true | if the tests should be executed out of order |
run | String | - | run select tests only, defined using a regex |
skip | String | - | skip select tests, defined using a regex |
verbose | Boolean | - | log all output from tests even if there are successful |
Example
dagger -m github.com/purpleclay/daggerverse/golang@4675abf5a511c33f41b15028fcd9e2f6d961691d call \
--src DIR_PATH test
func (m *myModule) example(src *Directory) *Directory {
return dag.
Golang(src).
Test()
}
@function
def example(src: dagger.Directory) -> dagger.Directory:
return (
dag.golang(src)
.test()
)
@func()
example(src: Directory): Directory {
return dag
.golang(src)
.test()
}
bench() 🔗
Execute benchmarks defined within the target project, excludes all other tests
Return Type
Directory !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
memory | Boolean | true | print memory allocation statistics for benchmarks |
time | String | "5s" | the time.Duration each benchmark should run for |
Example
dagger -m github.com/purpleclay/daggerverse/golang@4675abf5a511c33f41b15028fcd9e2f6d961691d call \
--src DIR_PATH bench
func (m *myModule) example(src *Directory) *Directory {
return dag.
Golang(src).
Bench()
}
@function
def example(src: dagger.Directory) -> dagger.Directory:
return (
dag.golang(src)
.bench()
)
@func()
example(src: Directory): Directory {
return dag
.golang(src)
.bench()
}
vulncheck() 🔗
Scans the target project for vulnerabilities using govulncheck
Return Type
Directory !
Example
dagger -m github.com/purpleclay/daggerverse/golang@4675abf5a511c33f41b15028fcd9e2f6d961691d call \
--src DIR_PATH vulncheck
func (m *myModule) example(src *Directory) *Directory {
return dag.
Golang(src).
Vulncheck()
}
@function
def example(src: dagger.Directory) -> dagger.Directory:
return (
dag.golang(src)
.vulncheck()
)
@func()
example(src: Directory): Directory {
return dag
.golang(src)
.vulncheck()
}