parent
bf400e3ace
commit
cd08e0aa17
@ -1,5 +1,5 @@
|
|||||||
package go_library
|
package go_library
|
||||||
|
|
||||||
func Version() string {
|
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 (
|
import (
|
||||||
"fmt"
|
"fmt"
|
@ -1,10 +1,9 @@
|
|||||||
package decimal
|
package godecimal
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestName(t *testing.T) {
|
func TestName(t *testing.T) {
|
||||||
fmt.Println(Decimal(2.3333))
|
t.Log(Decimal(2.3333))
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package header
|
package goheader
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
@ -1,14 +1,13 @@
|
|||||||
package gohttp
|
package gohttp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestName(t *testing.T) {
|
func TestName(t *testing.T) {
|
||||||
get, err := Get("https://api.dtapp.net/", nil)
|
get, err := Get("https://api.dtapp.net/", nil)
|
||||||
|
t.Logf("%+v\n", get)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Printf("%#v\n", get)
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package mail
|
package gomail
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
@ -1,4 +1,4 @@
|
|||||||
package request
|
package gorequest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
@ -1,10 +1,9 @@
|
|||||||
package request
|
package gorequest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestExternalIp(t *testing.T) {
|
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 (
|
import (
|
||||||
"crypto/rand"
|
"crypto/rand"
|
@ -1,4 +1,4 @@
|
|||||||
package url
|
package gourl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
@ -1,4 +1,4 @@
|
|||||||
package url
|
package gourl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"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