mirror of
https://github.com/go-gitea/gitea
synced 2025-01-15 04:04:26 +00:00
3270e7a443
* Update go-swagger * vendor
24 lines
448 B
Go
Vendored
24 lines
448 B
Go
Vendored
package codescan
|
|
|
|
import (
|
|
"go/ast"
|
|
"strconv"
|
|
"strings"
|
|
)
|
|
|
|
func getEnumBasicLitValue(basicLit *ast.BasicLit) interface{} {
|
|
switch basicLit.Kind.String() {
|
|
case "INT":
|
|
if result, err := strconv.ParseInt(basicLit.Value, 10, 64); err == nil {
|
|
return result
|
|
}
|
|
case "FLOAT":
|
|
if result, err := strconv.ParseFloat(basicLit.Value, 64); err == nil {
|
|
return result
|
|
}
|
|
default:
|
|
return strings.Trim(basicLit.Value, "\"")
|
|
}
|
|
return nil
|
|
}
|