@@ -4,28 +4,26 @@ An example repository to demonstrate Pants's experimental Golang support.
4
4
5
5
See the [ Golang blog post] ( https://blog.pantsbuild.org/golang-support-pants-28/ ) for some unique
6
6
benefits Pants brings to Golang repositories, and see
7
- [ pantsbuild.org/docs/go-overview] ( https://www.pantsbuild.org/v2.8/ docs/go-overview ) for more detailed
7
+ [ pantsbuild.org/docs/go-overview] ( https://www.pantsbuild.org/docs/go-overview ) for more detailed
8
8
documentation.
9
9
10
10
This is only one possible way of laying out your project with Pants. See
11
11
[ pantsbuild.org/docs/source-roots#examples] ( https://www.pantsbuild.org/docs/source-roots#examples )
12
12
for some other example layouts.
13
13
14
- Note: for now, Pants only supports repositories using a single ` go.mod ` . Please comment on
15
- [ #13114 ] ( https://github.com/pantsbuild/pants/issues/13114 ) if you need support for greater
16
- than one ` go.mod ` so that we can prioritize adding support.
17
-
18
14
# Running Pants
19
15
20
- You run Pants goals using the ` ./pants ` wrapper script, which will bootstrap the
21
- configured version of Pants if necessary.
16
+ You run Pants goals using the ` pants ` launcher binary, which will bootstrap the
17
+ version of Pants configured for this repo if necessary.
18
+
19
+ See [ here] ( https://www.pantsbuild.org/docs/installation ) for how to install the ` pants ` binary.
22
20
23
21
# Goals
24
22
25
23
Pants commands are called _ goals_ . You can get a list of goals with
26
24
27
25
```
28
- ./ pants help goals
26
+ pants help goals
29
27
```
30
28
31
29
Most goals take arguments to run on. To run on a single directory, use the directory name with
35
33
For example:
36
34
37
35
```
38
- ./ pants lint cmd: internal::
36
+ pants lint cmd: internal::
39
37
```
40
38
41
39
You can run on all changed files:
42
40
43
41
```
44
- ./ pants --changed-since=HEAD lint
42
+ pants --changed-since=HEAD lint
45
43
```
46
44
47
45
You can run on all changed files, and any of their "dependees":
48
46
49
47
```
50
- ./ pants --changed-since=HEAD --changed-dependees=transitive test
48
+ pants --changed-since=HEAD --changed-dependees=transitive test
51
49
```
52
50
53
51
# Example Goals
@@ -57,60 +55,60 @@ Try these out in this repo!
57
55
## Run Gofmt
58
56
59
57
```
60
- ./ pants fmt :: # Format all packages.
61
- ./ pants fmt cmd/greeter_en # Format only this package.
62
- ./ pants lint pkg/ :: # Check that all packages under `pkg` are formatted.
58
+ pants fmt :: # Format all packages.
59
+ pants fmt cmd/greeter_en: # Format only this package.
60
+ pants lint pkg:: # Check that all packages under `pkg` are formatted.
63
61
```
64
62
65
63
## Check compilation
66
64
67
65
```
68
- ./ pants check :: # Compile all packages.
69
- ./ pants check cmd/greeter_en # Compile only this package and its transitive dependencies.
66
+ pants check :: # Compile all packages.
67
+ pants check cmd/greeter_en: # Compile only this package and its transitive dependencies.
70
68
```
71
69
72
70
## Run tests
73
71
74
72
```
75
- ./ pants test :: # Run all tests in the repository.
76
- ./ pants test pkg/uuid # Run all the tests in this package.
77
- ./ pants test pkg/uuid -- -run TestGenerateUuid # Run just this one test.
73
+ pants test :: # Run all tests in the repository.
74
+ pants test pkg/uuid: # Run all the tests in this package.
75
+ pants test pkg/uuid: -- -run TestGenerateUuid # Run just this one test.
78
76
```
79
77
80
78
## Create a binary file
81
79
82
80
Writes the result to the ` dist/ ` folder.
83
81
84
82
```
85
- ./ pants package cmd/greeter_en
86
- ./ pants package cmd/ :: # Create all binaries.
83
+ pants package cmd/greeter_en:
84
+ pants package cmd:: # Create all binaries.
87
85
```
88
86
89
87
## Run a binary
90
88
91
89
```
92
- ./ pants run cmd/greeter_en
93
- ./ pants run cmd/greeter_es -- --help
90
+ pants run cmd/greeter_en:
91
+ pants run cmd/greeter_es: -- --help
94
92
```
95
93
96
94
## Determine dependencies
97
95
98
96
```
99
- ./ pants dependencies cmd/greeter_en
100
- ./ pants dependencies --transitive cmd/greeter_en
97
+ pants dependencies cmd/greeter_en:
98
+ pants dependencies --transitive cmd/greeter_en:
101
99
```
102
100
103
101
## Determine dependees
104
102
105
103
That is, find what code depends on a particular package(s).
106
104
107
105
```
108
- ./ pants dependees pkg/uuid
109
- ./ pants dependees --transitive pkg/uuid
106
+ pants dependees pkg/uuid:
107
+ pants dependees --transitive pkg/uuid:
110
108
```
111
109
112
110
## Count lines of code
113
111
114
112
```
115
- ./ pants count-loc '**/*'
113
+ pants count-loc '**/*'
116
114
```
0 commit comments