Bump go version to 1.21 #972

Closed
opened 2024-02-08 15:40:30 +00:00 by fyrchik · 3 comments
Owner

This task is an aggregator of changes and gopatches:

  • min/max
  • clear
  • improvements in generic type inference (there was a place in api-go with a kludge)
  • adopt slices package
  • adopt maps package
  • context.WithDeadlineCause could improve error reporting in logs and frostfs-cli
  • crypto/elliptic is deprecated, see if we are affected (frostfs-crypto)
  • multipathTCP for multinet library
  • sync.OnceFunc, sync.OnceValue, sync.OnceValues
This task is an aggregator of changes and gopatches: - [x] min/max - [ ] clear - [ ] improvements in generic type inference (there was a place in api-go with a kludge) - [x] adopt slices package - [ ] adopt maps package - [ ] context.WithDeadlineCause could improve error reporting in logs and frostfs-cli - [ ] crypto/elliptic is deprecated, see if we are affected (frostfs-crypto) - [ ] multipathTCP for multinet library - [ ] sync.OnceFunc, sync.OnceValue, sync.OnceValues
fyrchik added the
frostfs-node
label 2024-02-08 15:40:41 +00:00
Author
Owner

gopatch for min/max:

@@
var a, b expression
@@
-if a < b {
-	return a
-}
-return b
+return min(a, b)

@@
var a, b expression
@@
-if b > a {
-	return a
-}
-return b
+return min(a, b)

@@
var a, b expression
@@
-if a > b {
-	return a
-}
-return b
+return max(a, b)

@@
var a, b expression
@@
-if b < a {
-	return a
-}
-return b
+return max(a, b)

@@
var a, b expression
@@
-if a <= b {
-	return a
-}
-return b
+return min(a, b)

@@
var a, b expression
@@
-if b >= a {
-	return a
-}
-return b
+return min(a, b)

@@
var a, b expression
@@
-if a >= b {
-	return a
-}
-return b
+return max(a, b)

@@
var a, b expression
@@
-if b <= a {
-	return a
-}
-return b
+return max(a, b)


@@
var x, a, b expression
@@
-if a < b {
-	a = b
-}
+a = max(a, b)


@@
var x, a, b expression
@@
-if b > a {
-	a = b
-}
+a = max(a, b)


@@
var x, a, b expression
@@
-if a > b {
-	a = b
-}
+a = min(a, b)


@@
var x, a, b expression
@@
-if b < a {
-	a = b
-}
+a = min(a, b)


@@
var x, a, b expression
@@
-if a <= b {
-	a = b
-}
+a = max(a, b)


@@
var x, a, b expression
@@
-if b >= a {
-	a = b
-}
+a = max(a, b)


@@
var x, a, b expression
@@
-if a >= b {
-	a = b
-}
+a = min(a, b)


@@
var x, a, b expression
@@
-if b <= a {
-	a = b
-}
+a = min(a, b)
gopatch for min/max: ``` @@ var a, b expression @@ -if a < b { - return a -} -return b +return min(a, b) @@ var a, b expression @@ -if b > a { - return a -} -return b +return min(a, b) @@ var a, b expression @@ -if a > b { - return a -} -return b +return max(a, b) @@ var a, b expression @@ -if b < a { - return a -} -return b +return max(a, b) @@ var a, b expression @@ -if a <= b { - return a -} -return b +return min(a, b) @@ var a, b expression @@ -if b >= a { - return a -} -return b +return min(a, b) @@ var a, b expression @@ -if a >= b { - return a -} -return b +return max(a, b) @@ var a, b expression @@ -if b <= a { - return a -} -return b +return max(a, b) @@ var x, a, b expression @@ -if a < b { - a = b -} +a = max(a, b) @@ var x, a, b expression @@ -if b > a { - a = b -} +a = max(a, b) @@ var x, a, b expression @@ -if a > b { - a = b -} +a = min(a, b) @@ var x, a, b expression @@ -if b < a { - a = b -} +a = min(a, b) @@ var x, a, b expression @@ -if a <= b { - a = b -} +a = max(a, b) @@ var x, a, b expression @@ -if b >= a { - a = b -} +a = max(a, b) @@ var x, a, b expression @@ -if a >= b { - a = b -} +a = min(a, b) @@ var x, a, b expression @@ -if b <= a { - a = b -} +a = min(a, b) ```
fyrchik added
go
and removed
frostfs-node
labels 2024-02-08 15:58:17 +00:00
Author
Owner

Can be tricky, though

-       if d < 0 {
-               d = 0
-       }
+       d = max(d, 0)

Here the first zero is "lower boundary" and the second one it "the default value", it feels wrong to write max here.

Can be tricky, though ``` - if d < 0 { - d = 0 - } + d = max(d, 0) ``` Here the first zero is "lower boundary" and the second one it "the default value", it feels wrong to write `max` here.
fyrchik referenced this issue from a commit 2024-02-19 13:13:13 +00:00
fyrchik added this to the v0.40.0 milestone 2024-05-14 14:23:49 +00:00
Author
Owner

Lots of places where we could use sync.OnceFunc, but I have doubts they will become more readable.
From elliptic we use P256() for key generation, which is not deprecated.
I wasn't able to found place to use clear builtin or maps package.

Lots of places where we could use `sync.OnceFunc`, but I have doubts they will become more readable. From `elliptic` we use `P256()` for key generation, which is not deprecated. I wasn't able to found place to use `clear` builtin or `maps` package.
fyrchik added the
internal
label 2024-05-16 09:19:25 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: TrueCloudLab/frostfs-node#972
No description provided.