File: util_numbers.go

package info (click to toggle)
golang-github-nicholas-fedor-shoutrrr 0.8.15-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,200 kB
  • sloc: sh: 49; makefile: 5
file content (15 lines) | stat: -rw-r--r-- 370 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
package util

import "strings"

const hex int = 16

// StripNumberPrefix returns a number string with any base prefix stripped and it's corresponding base.
// If no prefix was found, returns 0 to let strconv try to identify the base.
func StripNumberPrefix(input string) (string, int) {
	if strings.HasPrefix(input, "#") {
		return input[1:], hex
	}

	return input, 0
}