parent
bf400e3ace
commit
cd08e0aa17
@ -1,5 +1,5 @@
|
||||
package go_library
|
||||
|
||||
func Version() string {
|
||||
return "v1.0.33"
|
||||
return "v1.0.34"
|
||||
}
|
||||
|
@ -1 +0,0 @@
|
||||
app_test.go
|
@ -1 +0,0 @@
|
||||
pinduoduo_test.go
|
@ -1,4 +1,4 @@
|
||||
package decimal
|
||||
package godecimal
|
||||
|
||||
import (
|
||||
"fmt"
|
@ -1,10 +1,9 @@
|
||||
package decimal
|
||||
package godecimal
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestName(t *testing.T) {
|
||||
fmt.Println(Decimal(2.3333))
|
||||
t.Log(Decimal(2.3333))
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package header
|
||||
package goheader
|
||||
|
||||
import (
|
||||
"encoding/json"
|
@ -1,14 +1,13 @@
|
||||
package gohttp
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestName(t *testing.T) {
|
||||
get, err := Get("https://api.dtapp.net/", nil)
|
||||
t.Logf("%+v\n", get)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
fmt.Printf("%#v\n", get)
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package mail
|
||||
package gomail
|
||||
|
||||
import (
|
||||
"fmt"
|
@ -1,4 +1,4 @@
|
||||
package request
|
||||
package gorequest
|
||||
|
||||
import (
|
||||
"errors"
|
@ -1,10 +1,9 @@
|
||||
package request
|
||||
package gorequest
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestExternalIp(t *testing.T) {
|
||||
fmt.Println(ExternalIp())
|
||||
t.Log(ExternalIp())
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package goround
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// FloatRound 截取小数位数
|
||||
func FloatRound(f float64, n int) float64 {
|
||||
format := "%." + strconv.Itoa(n) + "f"
|
||||
res, _ := strconv.ParseFloat(fmt.Sprintf(format, f), 64)
|
||||
return res
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package rsa
|
||||
package gorsa
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
@ -1,4 +1,4 @@
|
||||
package url
|
||||
package gourl
|
||||
|
||||
import (
|
||||
"io"
|
@ -1,4 +1,4 @@
|
||||
package url
|
||||
package gourl
|
||||
|
||||
import (
|
||||
"log"
|
@ -0,0 +1,50 @@
|
||||
package phpjson
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func Encode(v interface{}) (string, error) {
|
||||
bytes, err := json.Marshal(v)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(bytes), nil
|
||||
}
|
||||
|
||||
func MarshalToString(msg interface{}) (string, error) {
|
||||
j, e := json.Marshal(msg)
|
||||
if e != nil {
|
||||
return "", e
|
||||
}
|
||||
return string(j), nil
|
||||
}
|
||||
|
||||
func Implode(list interface{}, seq string) string {
|
||||
listValue := reflect.Indirect(reflect.ValueOf(list))
|
||||
if listValue.Kind() != reflect.Slice {
|
||||
return ""
|
||||
}
|
||||
count := listValue.Len()
|
||||
listStr := make([]string, 0, count)
|
||||
for i := 0; i < count; i++ {
|
||||
v := listValue.Index(i)
|
||||
if str, err := getValue(v); err == nil {
|
||||
listStr = append(listStr, str)
|
||||
}
|
||||
}
|
||||
return strings.Join(listStr, seq)
|
||||
}
|
||||
|
||||
func getValue(value reflect.Value) (res string, err error) {
|
||||
switch value.Kind() {
|
||||
case reflect.Ptr:
|
||||
res, err = getValue(value.Elem())
|
||||
default:
|
||||
res = fmt.Sprint(value.Interface())
|
||||
}
|
||||
return
|
||||
}
|
Loading…
Reference in new issue