Skip to content

Conversation

Eric-Arellano
Copy link
Contributor

A simple "Hello world" project.

We use the popular directory structure of putting all binaries in cmd/ and library code in pkg/. 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).


func GreetSpanish(name string) string {
return fmt.Sprintf(
"¡Hola %s!\n\nEres muy única, así que te regalamos un UUID: %s",
Copy link
Contributor Author

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.

Comment on lines +8 to +10
func Generate() string {
return uuid.NewString()
}
Copy link
Contributor Author

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.

Comment on lines +40 to +49
- 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:
Copy link
Member

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?

Copy link
Contributor Author

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO

Copy link
Contributor Author

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

Copy link
Member

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?

Copy link
Contributor Author

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

@Eric-Arellano Eric-Arellano merged commit 5d2bcaf into pantsbuild:main Nov 5, 2021
@Eric-Arellano Eric-Arellano deleted the init branch November 5, 2021 21:55
```

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
Copy link

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?

Copy link
Contributor Author

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",
Copy link

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?

Copy link
Contributor Author

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.
Copy link
Member

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"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants