@@ -252,10 +252,10 @@ func TestClientInvalidURI(t *testing.T) {
252252 t .Parallel ()
253253
254254 ln := fasthttputil .NewInmemoryListener ()
255- requests := int64 ( 0 )
255+ var requests atomic. Int64
256256 s := & Server {
257257 Handler : func (_ * RequestCtx ) {
258- atomic . AddInt64 ( & requests , 1 )
258+ requests . Add ( 1 )
259259 },
260260 }
261261 go s .Serve (ln ) //nolint:errcheck
@@ -275,7 +275,7 @@ func TestClientInvalidURI(t *testing.T) {
275275 if err == nil {
276276 t .Fatal ("expected error (missing required Host header in request)" )
277277 }
278- if n := atomic . LoadInt64 ( & requests ); n != 0 {
278+ if n := requests . Load ( ); n != 0 {
279279 t .Fatalf ("0 requests expected, got %d" , n )
280280 }
281281}
@@ -1470,12 +1470,12 @@ func TestHostClientMaxConnDuration(t *testing.T) {
14701470
14711471 ln := fasthttputil .NewInmemoryListener ()
14721472
1473- connectionCloseCount := uint32 ( 0 )
1473+ var connectionCloseCount atomic. Uint32
14741474 s := & Server {
14751475 Handler : func (ctx * RequestCtx ) {
14761476 ctx .WriteString ("abcd" ) //nolint:errcheck
14771477 if ctx .Request .ConnectionClose () {
1478- atomic . AddUint32 ( & connectionCloseCount , 1 )
1478+ connectionCloseCount . Add ( 1 )
14791479 }
14801480 },
14811481 }
@@ -1518,7 +1518,7 @@ func TestHostClientMaxConnDuration(t *testing.T) {
15181518 t .Fatalf ("timeout" )
15191519 }
15201520
1521- if connectionCloseCount == 0 {
1521+ if connectionCloseCount . Load () == 0 {
15221522 t .Fatalf ("expecting at least one 'Connection: close' request header" )
15231523 }
15241524}
@@ -2936,7 +2936,7 @@ func TestHostClientMaxConnWaitTimeoutError(t *testing.T) {
29362936 MaxConnWaitTimeout : 10 * time .Millisecond ,
29372937 }
29382938
2939- var errNoFreeConnsCount uint32
2939+ var errNoFreeConnsCount atomic. Uint32
29402940 for i := 0 ; i < 5 ; i ++ {
29412941 wg .Add (1 )
29422942 go func () {
@@ -2952,7 +2952,7 @@ func TestHostClientMaxConnWaitTimeoutError(t *testing.T) {
29522952 if err != ErrNoFreeConns {
29532953 t .Errorf ("unexpected error: %v. Expecting %v" , err , ErrNoFreeConns )
29542954 }
2955- atomic . AddUint32 ( & errNoFreeConnsCount , 1 )
2955+ errNoFreeConnsCount . Add ( 1 )
29562956 } else {
29572957 if resp .StatusCode () != StatusOK {
29582958 t .Errorf ("unexpected status code %d. Expecting %d" , resp .StatusCode (), StatusOK )
@@ -2976,8 +2976,8 @@ func TestHostClientMaxConnWaitTimeoutError(t *testing.T) {
29762976 if c .connsWait .len () > 0 {
29772977 t .Errorf ("connsWait has %v items remaining" , c .connsWait .len ())
29782978 }
2979- if errNoFreeConnsCount == 0 {
2980- t .Errorf ("unexpected errorCount: %d. Expecting > 0" , errNoFreeConnsCount )
2979+ if count := errNoFreeConnsCount . Load (); count == 0 {
2980+ t .Errorf ("unexpected errorCount: %d. Expecting > 0" , count )
29812981 }
29822982 if err := ln .Close (); err != nil {
29832983 t .Fatalf ("unexpected error: %v" , err )
@@ -3033,7 +3033,7 @@ func TestHostClientMaxConnWaitTimeoutWithEarlierDeadline(t *testing.T) {
30333033 MaxConnWaitTimeout : maxConnWaitTimeout ,
30343034 }
30353035
3036- var errTimeoutCount uint32
3036+ var errTimeoutCount atomic. Uint32
30373037 for i := 0 ; i < 5 ; i ++ {
30383038 wg .Add (1 )
30393039 go func () {
@@ -3049,7 +3049,7 @@ func TestHostClientMaxConnWaitTimeoutWithEarlierDeadline(t *testing.T) {
30493049 if err != ErrTimeout {
30503050 t .Errorf ("unexpected error: %v. Expecting %v" , err , ErrTimeout )
30513051 }
3052- atomic . AddUint32 ( & errTimeoutCount , 1 )
3052+ errTimeoutCount . Add ( 1 )
30533053 } else {
30543054 if resp .StatusCode () != StatusOK {
30553055 t .Errorf ("unexpected status code %d. Expecting %d" , resp .StatusCode (), StatusOK )
@@ -3077,8 +3077,8 @@ func TestHostClientMaxConnWaitTimeoutWithEarlierDeadline(t *testing.T) {
30773077 w .mu .Unlock ()
30783078 }
30793079 c .connsLock .Unlock ()
3080- if errTimeoutCount == 0 {
3081- t .Errorf ("unexpected errTimeoutCount: %d. Expecting > 0" , errTimeoutCount )
3080+ if count := errTimeoutCount . Load (); count == 0 {
3081+ t .Errorf ("unexpected errTimeoutCount: %d. Expecting > 0" , count )
30823082 }
30833083 if err := ln .Close (); err != nil {
30843084 t .Fatalf ("unexpected error: %v" , err )
0 commit comments