Debian Codegraph @

pkg/util/number.go

raw symbols SCIP
1 package utilscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/util`/
2
3 import "stringsscip-go gomod github.com/golang/go/src . strings/"
4
5 // hex is the base used for hexadecimal number parsing.
6 const hexscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/util`/hex. int = 16
7
8 // StripNumberPrefix removes hexadecimal prefixes from number strings.
9 //
10 // It recognizes the following prefixes:
11 // - "#" (e.g., "#FF" becomes "FF")
12 // - "0x" or "0X" (e.g., "0xFF" becomes "FF")
13 //
14 // Parameters:
15 // - input: The number string that may contain a base prefix.
16 //
17 // Returns:
18 // - The input string with any recognized prefix removed.
19 // - The base (16 for hex prefixes, 0 if no prefix was found).
20 // A return value of 0 indicates that strconv should attempt to identify the base.
21 func StripNumberPrefixscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/util`/StripNumberPrefix().(input string) (string, int) {
22 if stringsscip-go gomod github.com/golang/go/src . strings/.HasPrefixscip-go gomod github.com/golang/go/src . strings/HasPrefix().(input, "#") {
23 return input[1:], hexscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/util`/hex.
24 }
25
26 if stringsscip-go gomod github.com/golang/go/src . strings/.HasPrefixscip-go gomod github.com/golang/go/src . strings/HasPrefix().(input, "0x") || stringsscip-go gomod github.com/golang/go/src . strings/.HasPrefixscip-go gomod github.com/golang/go/src . strings/HasPrefix().(input, "0X") {
27 return input[2:], hexscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/util`/hex.
28 }
29
30 return input, 0
31 }