Skip to content

Commit b877342

Browse files
committed
Use pointer of atomic.Int32
By running [email protected], the return value of `makeAtomic` function is specified. After that, golangci-lint shows an error like `return copies lock value: sync/atomic.Int32 contains sync/atomic.noCopy`. This happens because atomic values should not be copied. So I made a change using them as pointers.
1 parent 5952c76 commit b877342

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

pkg/gui/presentation/branches_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ import (
1616
"github.com/xo/terminfo"
1717
)
1818

19-
func makeAtomic(v int32) (result atomic.Int32) {
19+
func makeAtomic(v int32) *atomic.Int32 {
20+
var result atomic.Int32
2021
result.Store(v)
21-
return result
22+
return &result
2223
}
2324

2425
func Test_getBranchDisplayStrings(t *testing.T) {
@@ -109,7 +110,7 @@ func Test_getBranchDisplayStrings(t *testing.T) {
109110
branch: &models.Branch{
110111
Name: "branch_name",
111112
Recency: "1m",
112-
BehindBaseBranch: makeAtomic(2),
113+
BehindBaseBranch: *makeAtomic(2),
113114
},
114115
itemOperation: types.ItemOperationNone,
115116
fullDescription: false,
@@ -126,7 +127,7 @@ func Test_getBranchDisplayStrings(t *testing.T) {
126127
UpstreamRemote: "origin",
127128
AheadForPull: "0",
128129
BehindForPull: "0",
129-
BehindBaseBranch: makeAtomic(2),
130+
BehindBaseBranch: *makeAtomic(2),
130131
},
131132
itemOperation: types.ItemOperationNone,
132133
fullDescription: false,
@@ -143,7 +144,7 @@ func Test_getBranchDisplayStrings(t *testing.T) {
143144
UpstreamRemote: "origin",
144145
AheadForPull: "3",
145146
BehindForPull: "5",
146-
BehindBaseBranch: makeAtomic(2),
147+
BehindBaseBranch: *makeAtomic(2),
147148
},
148149
itemOperation: types.ItemOperationNone,
149150
fullDescription: false,
@@ -247,7 +248,7 @@ func Test_getBranchDisplayStrings(t *testing.T) {
247248
UpstreamRemote: "origin",
248249
AheadForPull: "3",
249250
BehindForPull: "5",
250-
BehindBaseBranch: makeAtomic(4),
251+
BehindBaseBranch: *makeAtomic(4),
251252
},
252253
itemOperation: types.ItemOperationNone,
253254
fullDescription: false,

0 commit comments

Comments
 (0)