Skip to content

Commit 86656d7

Browse files
committed
Merge branch 'master' into before-callback
2 parents 63dd3f0 + f02120a commit 86656d7

16 files changed

+143
-242
lines changed

CHANGELOG.md

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

10+
## [1.18.2] - 2025-05-08
11+
### Fixed
12+
- The exported Version string incorrectly containing "-dev".
13+
1014
## [1.18.1] - 2025-03-03
1115
### Changed
1216
- Dot graph generation's internal implementation was changed so that

param.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,15 @@ func newParamList(ctype reflect.Type, c containerStore) (paramList, error) {
123123

124124
pl := paramList{
125125
ctype: ctype,
126-
Params: make([]param, 0, numArgs),
126+
Params: make([]param, numArgs),
127127
}
128128

129129
for i := 0; i < numArgs; i++ {
130130
p, err := newParam(ctype.In(i), c)
131131
if err != nil {
132132
return pl, newErrInvalidInput(fmt.Sprintf("bad argument %d", i+1), err)
133133
}
134-
pl.Params = append(pl.Params, p)
134+
pl.Params[i] = p
135135
}
136136

137137
return pl, nil

provide.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -450,14 +450,17 @@ func (s *Scope) provide(ctor interface{}, opts provideOptions) (err error) {
450450
// we start making changes to it as we may need to
451451
// undo them upon encountering errors.
452452
allScopes := s.appendSubscopes(nil)
453-
for _, s := range allScopes {
454-
s := s
455-
s.gh.Snapshot()
456-
defer func() {
457-
if err != nil {
458-
s.gh.Rollback()
453+
454+
defer func(allSc []*Scope) {
455+
if err != nil {
456+
for _, sc := range allSc {
457+
sc.gh.Rollback()
459458
}
460-
}()
459+
}
460+
}(allScopes)
461+
462+
for _, sc := range allScopes {
463+
sc.gh.Snapshot()
461464
}
462465

463466
n, err := newConstructorNode(

testdata/dig_as_two.dot

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
digraph {
22
rankdir=RL;
33
graph [compound=true];
4-
5-
subgraph cluster_0 {
6-
label = "go.uber.org/dig_test";
7-
constructor_0 [shape=plaintext label="TestVisualize.func4.1"];
8-
9-
"io.Reader" [label=<io.Reader>];
10-
"io.Writer" [label=<io.Writer>];
11-
12-
}
13-
14-
15-
4+
subgraph cluster_0 {
5+
label = "go.uber.org/dig_test";
6+
constructor_0 [shape=plaintext label="TestVisualize.func4.1"];
7+
"io.Reader" [label=<io.Reader>];
8+
"io.Writer" [label=<io.Writer>];
9+
}
1610
}

testdata/empty.dot

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
digraph {
22
rankdir=RL;
33
graph [compound=true];
4-
5-
64
}

testdata/error.dot

Lines changed: 26 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,34 @@ digraph {
22
rankdir=RL;
33
graph [compound=true];
44
"[type=dig_test.t1 group=g1]" [shape=diamond label=<dig_test.t1<BR /><FONT POINT-SIZE="10">Group: g1</FONT>> color=red];
5-
"[type=dig_test.t1 group=g1]" -> "dig_test.t1[group=g1]0";
6-
5+
"[type=dig_test.t1 group=g1]" -> "dig_test.t1[group=g1]0";
76
"[type=dig_test.t2 group=g2]" [shape=diamond label=<dig_test.t2<BR /><FONT POINT-SIZE="10">Group: g2</FONT>> color=orange];
8-
"[type=dig_test.t2 group=g2]" -> "dig_test.t2[group=g2]0";
9-
"[type=dig_test.t2 group=g2]" -> "dig_test.t2[group=g2]2";
10-
11-
12-
subgraph cluster_0 {
13-
label = "go.uber.org/dig_test";
14-
constructor_0 [shape=plaintext label="TestVisualize.func7.1"];
15-
color=orange;
16-
"dig_test.t3[name=n3]" [label=<dig_test.t3<BR /><FONT POINT-SIZE="10">Name: n3</FONT>>];
17-
"dig_test.t2[group=g2]0" [label=<dig_test.t2<BR /><FONT POINT-SIZE="10">Group: g2</FONT>>];
18-
19-
}
20-
21-
22-
constructor_0 -> "[type=dig_test.t1 group=g1]" [ltail=cluster_0];
23-
24-
subgraph cluster_1 {
25-
label = "go.uber.org/dig_test";
26-
constructor_1 [shape=plaintext label="TestVisualize.func7.2"];
27-
color=orange;
28-
"dig_test.t4" [label=<dig_test.t4>];
29-
30-
}
31-
32-
constructor_1 -> "dig_test.t3[name=n3]" [ltail=cluster_1];
33-
34-
35-
constructor_1 -> "[type=dig_test.t2 group=g2]" [ltail=cluster_1];
36-
37-
subgraph cluster_2 {
38-
label = "go.uber.org/dig_test";
39-
constructor_2 [shape=plaintext label="TestVisualize.func7.4"];
40-
color=red;
41-
"dig_test.t1[group=g1]0" [label=<dig_test.t1<BR /><FONT POINT-SIZE="10">Group: g1</FONT>>];
42-
"dig_test.t2[group=g2]2" [label=<dig_test.t2<BR /><FONT POINT-SIZE="10">Group: g2</FONT>>];
43-
44-
}
45-
46-
7+
"[type=dig_test.t2 group=g2]" -> "dig_test.t2[group=g2]0";
8+
"[type=dig_test.t2 group=g2]" -> "dig_test.t2[group=g2]2";
9+
subgraph cluster_0 {
10+
label = "go.uber.org/dig_test";
11+
constructor_0 [shape=plaintext label="TestVisualize.func7.1"];
12+
color=orange;
13+
"dig_test.t3[name=n3]" [label=<dig_test.t3<BR /><FONT POINT-SIZE="10">Name: n3</FONT>>];
14+
"dig_test.t2[group=g2]0" [label=<dig_test.t2<BR /><FONT POINT-SIZE="10">Group: g2</FONT>>];
15+
}
16+
constructor_0 -> "[type=dig_test.t1 group=g1]" [ltail=cluster_0];
17+
subgraph cluster_1 {
18+
label = "go.uber.org/dig_test";
19+
constructor_1 [shape=plaintext label="TestVisualize.func7.2"];
20+
color=orange;
21+
"dig_test.t4" [label=<dig_test.t4>];
22+
}
23+
constructor_1 -> "dig_test.t3[name=n3]" [ltail=cluster_1];
24+
constructor_1 -> "[type=dig_test.t2 group=g2]" [ltail=cluster_1];
25+
subgraph cluster_2 {
26+
label = "go.uber.org/dig_test";
27+
constructor_2 [shape=plaintext label="TestVisualize.func7.4"];
28+
color=red;
29+
"dig_test.t1[group=g1]0" [label=<dig_test.t1<BR /><FONT POINT-SIZE="10">Group: g1</FONT>>];
30+
"dig_test.t2[group=g2]2" [label=<dig_test.t2<BR /><FONT POINT-SIZE="10">Group: g2</FONT>>];
31+
}
4732
"dig_test.t2[group=g2]0" [color=orange];
4833
"dig_test.t4" [color=orange];
4934
"dig_test.t1[group=g1]0" [color=red];
50-
5135
}

testdata/grouped.dot

Lines changed: 18 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,22 @@ digraph {
22
rankdir=RL;
33
graph [compound=true];
44
"[type=dig_test.t3 group=foo]" [shape=diamond label=<dig_test.t3<BR /><FONT POINT-SIZE="10">Group: foo</FONT>>];
5-
"[type=dig_test.t3 group=foo]" -> "dig_test.t3[group=foo]0";
6-
"[type=dig_test.t3 group=foo]" -> "dig_test.t3[group=foo]1";
7-
8-
9-
subgraph cluster_0 {
10-
label = "go.uber.org/dig_test";
11-
constructor_0 [shape=plaintext label="TestVisualize.func6.1"];
12-
13-
"dig_test.t3[group=foo]0" [label=<dig_test.t3<BR /><FONT POINT-SIZE="10">Group: foo</FONT>>];
14-
15-
}
16-
17-
18-
subgraph cluster_1 {
19-
label = "go.uber.org/dig_test";
20-
constructor_1 [shape=plaintext label="TestVisualize.func6.2"];
21-
22-
"dig_test.t3[group=foo]1" [label=<dig_test.t3<BR /><FONT POINT-SIZE="10">Group: foo</FONT>>];
23-
24-
}
25-
26-
27-
subgraph cluster_2 {
28-
label = "go.uber.org/dig_test";
29-
constructor_2 [shape=plaintext label="TestVisualize.func6.3"];
30-
31-
"dig_test.t2" [label=<dig_test.t2>];
32-
33-
}
34-
35-
36-
constructor_2 -> "[type=dig_test.t3 group=foo]" [ltail=cluster_2];
37-
38-
5+
"[type=dig_test.t3 group=foo]" -> "dig_test.t3[group=foo]0";
6+
"[type=dig_test.t3 group=foo]" -> "dig_test.t3[group=foo]1";
7+
subgraph cluster_0 {
8+
label = "go.uber.org/dig_test";
9+
constructor_0 [shape=plaintext label="TestVisualize.func6.1"];
10+
"dig_test.t3[group=foo]0" [label=<dig_test.t3<BR /><FONT POINT-SIZE="10">Group: foo</FONT>>];
11+
}
12+
subgraph cluster_1 {
13+
label = "go.uber.org/dig_test";
14+
constructor_1 [shape=plaintext label="TestVisualize.func6.2"];
15+
"dig_test.t3[group=foo]1" [label=<dig_test.t3<BR /><FONT POINT-SIZE="10">Group: foo</FONT>>];
16+
}
17+
subgraph cluster_2 {
18+
label = "go.uber.org/dig_test";
19+
constructor_2 [shape=plaintext label="TestVisualize.func6.3"];
20+
"dig_test.t2" [label=<dig_test.t2>];
21+
}
22+
constructor_2 -> "[type=dig_test.t3 group=foo]" [ltail=cluster_2];
3923
}

testdata/missing.dot

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,17 @@
11
digraph {
22
rankdir=RL;
33
graph [compound=true];
4-
5-
subgraph cluster_0 {
6-
label = "go.uber.org/dig_test";
7-
constructor_0 [shape=plaintext label="TestVisualize.func8.1"];
8-
color=orange;
9-
"dig_test.t4" [label=<dig_test.t4>];
10-
11-
}
12-
13-
constructor_0 -> "dig_test.t1" [ltail=cluster_0];
14-
15-
constructor_0 -> "dig_test.t2" [ltail=cluster_0];
16-
17-
constructor_0 -> "dig_test.t3" [ltail=cluster_0];
18-
19-
4+
subgraph cluster_0 {
5+
label = "go.uber.org/dig_test";
6+
constructor_0 [shape=plaintext label="TestVisualize.func8.1"];
7+
color=orange;
8+
"dig_test.t4" [label=<dig_test.t4>];
9+
}
10+
constructor_0 -> "dig_test.t1" [ltail=cluster_0];
11+
constructor_0 -> "dig_test.t2" [ltail=cluster_0];
12+
constructor_0 -> "dig_test.t3" [ltail=cluster_0];
2013
"dig_test.t4" [color=orange];
2114
"dig_test.t1" [color=red];
2215
"dig_test.t2" [color=red];
2316
"dig_test.t3" [color=red];
24-
2517
}

testdata/missingDep.dot

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
digraph {
22
rankdir=RL;
33
graph [compound=true];
4-
54
"dig_test.t1" [color=red];
6-
75
}

testdata/named.dot

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,16 @@
11
digraph {
22
rankdir=RL;
33
graph [compound=true];
4-
5-
subgraph cluster_0 {
6-
label = "go.uber.org/dig_test";
7-
constructor_0 [shape=plaintext label="TestVisualize.func3.1"];
8-
9-
"dig_test.t1[name=bar]" [label=<dig_test.t1<BR /><FONT POINT-SIZE="10">Name: bar</FONT>>];
10-
"dig_test.t2[name=baz]" [label=<dig_test.t2<BR /><FONT POINT-SIZE="10">Name: baz</FONT>>];
11-
12-
}
13-
14-
constructor_0 -> "dig_test.t3[name=foo]" [ltail=cluster_0];
15-
16-
17-
subgraph cluster_1 {
18-
label = "go.uber.org/dig_test";
19-
constructor_1 [shape=plaintext label="TestVisualize.func3.2"];
20-
21-
"dig_test.t3[name=foo]" [label=<dig_test.t3<BR /><FONT POINT-SIZE="10">Name: foo</FONT>>];
22-
23-
}
24-
25-
26-
4+
subgraph cluster_0 {
5+
label = "go.uber.org/dig_test";
6+
constructor_0 [shape=plaintext label="TestVisualize.func3.1"];
7+
"dig_test.t1[name=bar]" [label=<dig_test.t1<BR /><FONT POINT-SIZE="10">Name: bar</FONT>>];
8+
"dig_test.t2[name=baz]" [label=<dig_test.t2<BR /><FONT POINT-SIZE="10">Name: baz</FONT>>];
9+
}
10+
constructor_0 -> "dig_test.t3[name=foo]" [ltail=cluster_0];
11+
subgraph cluster_1 {
12+
label = "go.uber.org/dig_test";
13+
constructor_1 [shape=plaintext label="TestVisualize.func3.2"];
14+
"dig_test.t3[name=foo]" [label=<dig_test.t3<BR /><FONT POINT-SIZE="10">Name: foo</FONT>>];
15+
}
2716
}

0 commit comments

Comments
 (0)