-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.go
24 lines (21 loc) · 880 Bytes
/
utils.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
* Copyright (c) 2022. by MERKATOR <merkator@merkator.pro>
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation;
* This application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
* Licensed under GNU General Public License 3.0 or later.
* @license GPL-3.0+ <http://spdx.org/licenses/GPL-3.0+>
*/
package rflink
import "strconv"
// strToUint16 parses a string directly into an uint16 with the specified base
func strToUint16(s string, base int) (uint16, error) {
u, err := strconv.ParseUint(s, base, 16)
if err != nil {
return 0, err
}
return uint16(u), nil
}