mirror of
https://github.com/usememos/memos.git
synced 2024-12-25 12:23:09 +03:00
chore: fix id converter
This commit is contained in:
parent
2b7d7c95a5
commit
480c53d7a2
@ -2,10 +2,11 @@ package v2
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/usememos/memos/internal/util"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -38,9 +39,9 @@ func GetInboxID(name string) (int32, error) {
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
id, err := strconv.Atoi(tokens[0])
|
||||
id, err := util.ConvertStringToInt32(tokens[0])
|
||||
if err != nil {
|
||||
return 0, errors.Errorf("invalid inbox ID %q", tokens[0])
|
||||
}
|
||||
return int32(id), nil
|
||||
return id, nil
|
||||
}
|
||||
|
@ -12,11 +12,11 @@ import (
|
||||
|
||||
// ConvertStringToInt32 converts a string to int32.
|
||||
func ConvertStringToInt32(src string) (int32, error) {
|
||||
i, err := strconv.Atoi(src)
|
||||
parsed, err := strconv.ParseInt(src, 10, 32)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return int32(i), nil
|
||||
return int32(parsed), nil
|
||||
}
|
||||
|
||||
// HasPrefixes returns true if the string s has any of the given prefixes.
|
||||
|
Loading…
Reference in New Issue
Block a user