-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
General maintenance from go1.21 & 1.22 changes (#47)
- Loading branch information
Dean Karn
authored
Feb 14, 2024
1 parent
67dfc10
commit d5715da
Showing
15 changed files
with
428 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,4 @@ | |
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
//go:build go1.21 | ||
|
||
package mathext | ||
|
||
import ( | ||
constraintsext "github.com/go-playground/pkg/v5/constraints" | ||
) | ||
|
||
// Max returns the larger value. | ||
// | ||
// NOTE: this function does not check for difference in floats of 0/zero vs -0/negative zero using Signbit. | ||
// | ||
// Deprecated: use the new std library `max` instead. | ||
func Max[N constraintsext.Number](x, y N) N { | ||
return max(x, y) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
//go:build go1.21 | ||
|
||
package mathext | ||
|
||
import ( | ||
constraintsext "github.com/go-playground/pkg/v5/constraints" | ||
) | ||
|
||
// Min returns the smaller value. | ||
// | ||
// NOTE: this function does not check for difference in floats of 0/zero vs -0/negative zero using Signbit. | ||
// | ||
// Deprecated: use the new std library `max` instead. | ||
func Min[N constraintsext.Number](x, y N) N { | ||
return min(x, y) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
//go:build !go1.21 | ||
// +build !go1.21 | ||
|
||
package unsafeext | ||
|
||
import ( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//go:build go1.21 | ||
|
||
package unsafeext | ||
|
||
import ( | ||
"unsafe" | ||
) | ||
|
||
// BytesToString converts an array of bytes into a string without allocating. | ||
// The byte slice passed to this function is not to be used after this call as it's unsafe; you have been warned. | ||
func BytesToString(b []byte) string { | ||
return unsafe.String(unsafe.SliceData(b), len(b)) | ||
} | ||
|
||
// StringToBytes converts an existing string into an []byte without allocating. | ||
// The string passed to these functions is not to be used again after this call as it's unsafe; you have been warned. | ||
func StringToBytes(s string) (b []byte) { | ||
d := unsafe.StringData(s) | ||
b = unsafe.Slice(d, len(s)) | ||
return | ||
} |
Oops, something went wrong.