mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-25 11:05:45 +00:00
util/truncate: support []byte as well (#11614)
There are no mutations to the input, so we can support both ~string and ~[]byte just fine. Updates #cleanup Signed-off-by: Joe Tsai <joetsai@digital-static.net>
This commit is contained in:
parent
98cf71cd73
commit
4bbac72868
@ -9,7 +9,7 @@
|
|||||||
// bytes. If s exceeds this length, it is truncated at a point ≤ n so that the
|
// bytes. If s exceeds this length, it is truncated at a point ≤ n so that the
|
||||||
// result does not end in a partial UTF-8 encoding. If s is less than or equal
|
// result does not end in a partial UTF-8 encoding. If s is less than or equal
|
||||||
// to this length, it is returned unmodified.
|
// to this length, it is returned unmodified.
|
||||||
func String(s string, n int) string {
|
func String[String ~string | ~[]byte](s String, n int) String {
|
||||||
if n >= len(s) {
|
if n >= len(s) {
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user