-
Notifications
You must be signed in to change notification settings - Fork 25
Tidy up README.md
#290
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
base: master
Are you sure you want to change the base?
Tidy up README.md
#290
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,43 @@ | ||
| # Go Rules | ||
| This repo provides Golang build rules for the [Please](https://please.build) build system. | ||
|
|
||
| # Basic usage | ||
| This repo provides [Go](https://go.dev/) build rules for the [Please](https://please.build) build system. | ||
|
|
||
| Go is especially suited to writing command line tools and utilities. Binaries can be run with `plz run`, or used | ||
| as tools for [custom rules](https://please.build/codelabs/genrule/#0). | ||
|
|
||
| # Installation | ||
|
|
||
| First, add the plugin to your Please repo. In `plugins/BUILD`: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It isn't strictly required that it be |
||
|
|
||
| First add the plugin to your project. In `plugins/BUILD`: | ||
| ```python | ||
| plugin_repo( | ||
| name = "go", | ||
| revision="vx.x.x", | ||
| revision = "vx.x.x", # A go-rules version | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where should the reader find which version to use? |
||
| ) | ||
| ``` | ||
|
|
||
| Then add the plugin config: | ||
| Next, define a version of Go for the plugin to use. In `third_party/go/BUILD`: | ||
|
|
||
| ```python | ||
| subinclude("///go//build_defs:go") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we recommend ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. The phases of |
||
|
|
||
| go_toolchain( | ||
| name = "toolchain", | ||
| version = "1.x.x", # A Go version (see https://go.dev/dl/) | ||
| ) | ||
| ``` | ||
|
|
||
| Finally, configure the plugin in `.plzconfig`: | ||
|
|
||
| ```ini | ||
| [Plugin "go"] | ||
| Target = //plugins:go | ||
| GoTool = //third_party/go:toolchain|go | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to add Stdlib here? |
||
| ImportPath = github.com/example/repo | ||
| ``` | ||
|
|
||
| You can then compile and test go Packages like so: | ||
| # Basic usage | ||
|
|
||
| ```python | ||
| subinclude("///go//build_defs:go") | ||
|
|
||
|
|
@@ -41,15 +60,27 @@ go_test( | |
| ) | ||
| ``` | ||
|
|
||
| You can define third party code using `go_get`: | ||
| Compile binaries with `go_binary`: | ||
|
|
||
| ```python | ||
| subinclude("///go//build_defs:go") | ||
|
|
||
| go_binary( | ||
| name = "bin", | ||
| srcs = ["main.go"], | ||
| ) | ||
| ``` | ||
|
|
||
| Introduce dependencies on third-party Go modules with `go_repo`: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Worth a reference to puku here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Worth doing, but |
||
|
|
||
| ```python | ||
| subinclude("///go//build_defs:go") | ||
|
|
||
| # We can give direct modules a name, and install list so we can reference them nicely as :testify | ||
| go_repo( | ||
| name = "testify", | ||
| module = "github.com/stretchr/testify", | ||
| version="v1.8.2", | ||
| version = "v1.8.2", | ||
| # We add the subset of packages we actually depend on here | ||
| install = [ | ||
| "assert", | ||
|
|
@@ -63,18 +94,3 @@ go_repo(module = "github.com/pmezard/go-difflib", version="v1.0.0") | |
| go_repo(module = "github.com/stretchr/objx", version="v0.5.0") | ||
| go_repo(module = "gopkg.in/yaml.v3", version="v3.0.1") | ||
| ``` | ||
|
|
||
| To compile a binary, you can use `go_binary()`: | ||
| ```python | ||
| subinclude("///go//build_defs:go") | ||
|
|
||
| go_binary( | ||
| name = "bin", | ||
| srcs = ["main.go"], | ||
| ) | ||
| ``` | ||
|
|
||
| Go is especially well suited to writing command line tools and utilities. Binaries can be ran with `plz run`, or used | ||
| as a tool for other [custom rules](https://please.build/codelabs/genrule/#0). | ||
|
|
||
| **WARNING: From Go 1.20, Golang no longer ships the precompiled standard library and thus you MUST use `go_toolchain` or `go_system_toolchain`.** | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just recommend using
plz init plugin gohere? (and maybe leave the manual process as an appendix)