mirror of
https://github.com/Open-Argon/argon-v3.git
synced 2025-12-06 08:56:07 +00:00
add functions and variables name
This commit is contained in:
30
src/to-argon.go
Normal file
30
src/to-argon.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func anyToArgon(x any, quote bool) string {
|
||||
switch x := x.(type) {
|
||||
case string:
|
||||
if !quote {
|
||||
return x
|
||||
}
|
||||
return strconv.Quote(x)
|
||||
case number:
|
||||
num, _ := x.Float64()
|
||||
if math.IsNaN(num) {
|
||||
return "NaN"
|
||||
} else if math.IsInf(num, 1) {
|
||||
return "infinity"
|
||||
} else if math.IsInf(num, -1) {
|
||||
return "-infinity"
|
||||
} else {
|
||||
return strconv.FormatFloat(num, 'f', -1, 64)
|
||||
}
|
||||
default:
|
||||
return fmt.Sprint(x)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user