Skip to content

Commit 3958e81

Browse files
authored
Merge branch 'uber-go:master' into dig_380
2 parents 23338b1 + 7709124 commit 3958e81

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1645
-569
lines changed

.github/workflows/fossa.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: FOSSA Analysis
22
on: push
33

4+
permissions:
5+
contents: read
6+
47
jobs:
58

69
build:

.github/workflows/go.yml

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,46 +7,56 @@ on:
77
pull_request:
88
branches: ['*']
99

10+
permissions:
11+
contents: read
12+
1013
jobs:
1114

1215
build:
13-
runs-on: ubuntu-latest
16+
runs-on: ${{ matrix.os }}
17+
name: Test (Go ${{ matrix.go }} / ${{ matrix.os }})
1418
strategy:
1519
matrix:
16-
go: ["1.18.x", "1.19.x"]
17-
include:
18-
- go: 1.19.x
19-
latest: true
20+
os: ["ubuntu-latest", "windows-latest"]
21+
go: ["1.23.x", "1.24.x"]
2022

2123
steps:
2224
- name: Setup Go
23-
uses: actions/setup-go@v2
25+
uses: actions/setup-go@v5
2426
with:
2527
go-version: ${{ matrix.go }}
2628

2729
- name: Checkout code
28-
uses: actions/checkout@v2
29-
30-
- name: Load cached dependencies
31-
uses: actions/cache@v1
32-
with:
33-
path: ~/go/pkg/mod
34-
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
35-
restore-keys: |
36-
${{ runner.os }}-go-
30+
uses: actions/checkout@v4
3731

3832
- name: Download Dependencies
39-
run: make install
40-
41-
- name: Lint
42-
if: matrix.latest
43-
run: make lint
33+
run: go mod download
4434

4535
- name: Test
4636
run: make cover
4737

4838
- name: Upload coverage to codecov.io
4939
uses: codecov/codecov-action@v1
5040

51-
- name: Benchmark
52-
run: make bench
41+
lint:
42+
name: Lint
43+
runs-on: ubuntu-latest
44+
45+
steps:
46+
- name: Checkout code
47+
uses: actions/checkout@v4
48+
49+
- name: Setup Go
50+
uses: actions/setup-go@v5
51+
with:
52+
go-version: 1.24.x
53+
cache: false # managed by golangci-lint
54+
55+
- uses: golangci/golangci-lint-action@v3
56+
name: Install golangci-lint
57+
with:
58+
version: latest
59+
args: --help # make lint will run the linter
60+
61+
- run: make lint
62+
name: Lint

.golangci.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
output:
2+
# Make output more digestible with quickfix in vim/emacs/etc.
3+
sort-results: true
4+
print-issued-lines: false
5+
6+
linters:
7+
# We'll track the golangci-lint default linters manually
8+
# instead of letting them change without our control.
9+
disable-all: true
10+
enable:
11+
# golangci-lint defaults:
12+
- gosimple
13+
- govet
14+
- ineffassign
15+
- staticcheck
16+
- unused
17+
18+
# Our own extras:
19+
- gofumpt
20+
- nolintlint # lints nolint directives
21+
- revive
22+
- errorlint
23+
24+
# License header check
25+
- goheader
26+
27+
linters-settings:
28+
govet:
29+
# These govet checks are disabled by default, but they're useful.
30+
enable:
31+
- niliness
32+
- reflectvaluecompare
33+
- sortslice
34+
- unusedwrite
35+
36+
goheader:
37+
values:
38+
const:
39+
COMPANY: 'Uber Technologies, Inc.'
40+
regexp:
41+
YEAR_RANGE: '\d{4}(-\d{4})?'
42+
template: |-
43+
Copyright (c) {{ YEAR_RANGE }} {{ COMPANY }}
44+
45+
Permission is hereby granted, free of charge, to any person obtaining a copy
46+
of this software and associated documentation files (the "Software"), to deal
47+
in the Software without restriction, including without limitation the rights
48+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
49+
copies of the Software, and to permit persons to whom the Software is
50+
furnished to do so, subject to the following conditions:
51+
52+
The above copyright notice and this permission notice shall be included in
53+
all copies or substantial portions of the Software.
54+
55+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
56+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
57+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
58+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
59+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
60+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
61+
THE SOFTWARE.
62+
63+
issues:
64+
# Print all issues reported by all linters.
65+
max-issues-per-linter: 0
66+
max-same-issues: 0
67+
68+
# Don't ignore some of the issues that golangci-lint considers okay.
69+
# This includes documenting all exported entities.
70+
exclude-use-default: false
71+
72+
exclude-rules:
73+
# Don't warn on unused parameters.
74+
# Parameter names are useful; replacing them with '_' is undesirable.
75+
- linters: [revive]
76+
text: 'unused-parameter: parameter \S+ seems to be unused, consider removing or renaming it as _'
77+
78+
# staticcheck already has smarter checks for empty blocks.
79+
# revive's empty-block linter has false positives.
80+
# For example, as of writing this, the following is not allowed.
81+
# for foo() { }
82+
- linters: [revive]
83+
text: 'empty-block: this block is empty, you can remove it'
84+
85+
# It's okay if internal packages and examples in docs/
86+
# don't have package comments.
87+
- linters: [revive]
88+
path: '.+/internal/.+|^internal/.+'
89+
text: 'should have a package comment'

CHANGELOG.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,70 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77
## Unreleased
88
- No changes yet.
99

10+
## [1.19.0] - 2025-05-13
11+
12+
### Added
13+
- `BeforeCallback`s can be registered using `WithProviderBeforeCallback` and
14+
`WithDecoratorBeforeCallback` to hook custom callbacks into Dig
15+
to be run before constructors or decorators are run.
16+
17+
### Changed
18+
- Dot graph generation now results in much more clean and organized dot files.
19+
20+
Thanks to @Groxx, @architagr, and @pgimalac for their contributions to this release.
21+
22+
[1.19.0]: https://github.com/uber-go/dig/compare/v1.18.2...v1.19.0
23+
24+
## [1.18.2] - 2025-05-08
25+
### Fixed
26+
- The exported Version string incorrectly containing "-dev".
27+
28+
[1.18.2]: https://github.com/uber-go/dig/compare/v1.18.1...v1.18.2
29+
30+
## [1.18.1] - 2025-03-03
31+
### Changed
32+
- Dot graph generation's internal implementation was changed so that
33+
Go linker can successfully perform dead code elimination for Go apps
34+
that use Dig.
35+
36+
Thanks to @pgimalac for their contribution to this releaase.
37+
38+
[1.18.1]: https://github.com/uber-go/dig/compare/v1.18.0...v1.18.1
39+
40+
## [1.18.0] - 2024-08-07
41+
### Added
42+
- Child scope constructors are now visualized via `Visualize`
43+
- `CallbackInfo` now includes constructor/decorator run time.
44+
45+
Thanks to @greeflas for their contribution to this release.
46+
47+
[1.18.0]: https://github.com/uber-go/dig/compare/v1.17.1...v1.18.0
48+
49+
## [1.17.1] - 2023-10-19
50+
### Added
51+
- Suggestions for value vs. pointer elements for slice and array types.
52+
53+
### Fixed
54+
- An issue where value group values were not getting decorated
55+
by decorators within the same module when using dig.Export(true).
56+
- A typo in docs.
57+
- An issue where false positives in cycle detection were occurring
58+
when providing to a child scope.
59+
60+
Thanks to @paullen and @lcarilla for their contributions to this release.
61+
62+
[1.17.1]: https://github.com/uber-go/dig/compare/v1.17.0...v1.17.1
63+
64+
## [1.17.0] - 2023-05-02
65+
### Added
66+
- Allow using `dig.As` with `dig.Group`.
67+
- Add `FillInvokeInfo` Option and `InvokeInfo` struct to help
68+
extract the types requested by an `Invoke` statement.
69+
- To get visibility into constructor and decorator calls, introduce
70+
`WithProviderCallback` and `WithDecoratorCallback` Options to provide callback functions.
71+
72+
[1.17.0]: https://github.com/uber-go/dig/compare/v1.16.1...v1.17.0
73+
1074
## [1.16.1] - 2023-01-10
1175
### Fixed
1276
- A panic when `DryRun` was used with `Decorate`.

Makefile

Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,24 @@
1-
export GOBIN ?= $(shell pwd)/bin
1+
# Directory containing the Makefile.
2+
PROJECT_ROOT = $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
23

3-
GOLINT = $(GOBIN)/golint
4-
STATICCHECK = $(GOBIN)/staticcheck
4+
export GOBIN ?= $(PROJECT_ROOT)/bin
5+
export PATH := $(GOBIN):$(PATH)
56

67
BENCH_FLAGS ?= -cpuprofile=cpu.pprof -memprofile=mem.pprof -benchmem
78

89
GO_FILES = $(shell \
910
find . '(' -path '*/.*' -o -path './vendor' ')' -prune \
1011
-o -name '*.go' -print | cut -b3-)
1112

12-
MODULES = . ./tools
13-
1413
.PHONY: all
1514
all: build lint test
1615

1716
.PHONY: build
1817
build:
1918
go build ./...
2019

21-
.PHONY: install
22-
install:
23-
$(foreach dir,$(MODULES),( \
24-
cd $(dir) && \
25-
go mod download) && \
26-
) true
27-
2820
.PHONY: lint
29-
lint: $(GOLINT) $(STATICCHECK)
30-
@rm -rf lint.log
31-
@echo "Checking formatting..."
32-
@gofmt -d -s $(GO_FILES) 2>&1 | tee lint.log
33-
@echo "Checking vet..."
34-
@go vet ./... 2>&1 | tee -a lint.log
35-
@echo "Checking lint..."
36-
@$(GOLINT) ./... 2>&1 | tee -a lint.log
37-
@echo "Checking staticcheck..."
38-
@$(STATICCHECK) ./... 2>&1 | tee -a lint.log
39-
@echo "Checking for unresolved FIXMEs..."
40-
@git grep -i fixme | grep -v -e Makefile | tee -a lint.log
41-
@echo "Checking for license headers..."
42-
@./check_license.sh | tee -a lint.log
43-
@[ ! -s lint.log ]
44-
45-
$(GOLINT): tools/go.mod
46-
cd tools && go install golang.org/x/lint/golint
47-
48-
$(STATICCHECK): tools/go.mod
49-
cd tools && go install honnef.co/go/tools/cmd/staticcheck
21+
lint: golangci-lint tidy-lint
5022

5123
.PHONY: test
5224
test:
@@ -64,4 +36,13 @@ bench:
6436

6537
.PHONY: tidy
6638
tidy:
67-
$(foreach dir,$(MODULES),(cd $(dir) && go mod tidy) &&) true
39+
go mod tidy
40+
41+
.PHONY: golangci-lint
42+
golangci-lint:
43+
golangci-lint run
44+
45+
.PHONY: tidy-lint
46+
tidy-lint:
47+
go mod tidy
48+
git diff --exit-code -- go.mod go.sum

0 commit comments

Comments
 (0)