-
Notifications
You must be signed in to change notification settings - Fork 15
Set up minimal Go project #2
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
Conversation
|
||
func GreetSpanish(name string) string { | ||
return fmt.Sprintf( | ||
"¡Hola %s!\n\nEres muy única, así que te regalamos un UUID: %s", |
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.
Roughly translates to:
You're very unique, so here's a UUID for you:
Note that it's única
instead of único
, meaning it applies to women. Gender-neutral variants like único/a
or únic@
felt clunky, so I went with this.
func Generate() string { | ||
return uuid.NewString() | ||
} |
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.
A very silly function, but the point of the demo is to keep it simple.
- name: Lint and compile | ||
run: ./pants lint check '::' | ||
- name: Test | ||
run: ./pants test '::' | ||
- name: Package / Run | ||
run: | | ||
# We also smoke test that our release process will work by running `package`. | ||
./pants package :: | ||
./pants run cmd/greeter_en: | ||
./pants run cmd/greeter_es: |
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.
Maybe link to https://www.pantsbuild.org/docs/using-pants-in-ci somewhere in here?
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.
On line 4 at the top of this file already
|
||
An example repository to demonstrate Pants's experimental Golang support. | ||
|
||
See [] for some unique benefits Pants brings to Golang repositories, and see |
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.
TODO
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.
Yep, waiting for the blog to have a stable link. Chicken and egg
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.
Mm. Maybe just the http://blog.pantsbuild.org in the meantime then?
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.
This repo isn't publicized yet, and planning on doing the blog on Monday. Will fix then a couple minutes before we publicize the blog
``` | ||
|
||
Most goals take arguments to run on. To run on a single directory, use the directory name with | ||
`:` at the end. To recursively run on a directory and all its subdirectories, add `::` to the |
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.
Maybe mention that we are revisiting the dir spec syntax in 2.9?
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.
Based on discussion this week, it's no longer a firm commitment that we'll fix this in 2.9
# You can optionally set the field `output_path="greeter_en"`, for example, for the binary's name | ||
# to be different when running `./pants package`. | ||
go_binary( | ||
name="bin", |
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.
The output is going to be ./dist/cmd.greeter_en/bin
. Go users expect the binary name to be the name of the diectory, this greeter_en
. Maybe add output_path
or change the name
?
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.
Good idea. We lose a guarantee that the name is globally unique, but seems reasonable to change
|
||
Note: for now, Pants only supports repositories using a single `go.mod`. Please comment on | ||
[#13114](https://github.com/pantsbuild/pants/issues/13114) if you need support for greater | ||
than one `go.mod` so that we can prioritize adding support. |
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.
Greater than one sounds strange to me in this context.. "more than one"?
A simple "Hello world" project.
We use the popular directory structure of putting all binaries in
cmd/
and library code inpkg/
. To keep the example simple, the binaries are simply hello world in English and Spanish.Demos internal and external tests, but not benchmarks and examples (even though these are supported).