Skip to content

Instantly share code, notes, and snippets.

@jinuljt
jinuljt / gofloat2int.go
Last active August 29, 2015 14:25
go float 转换 int
/*
由于float精度的问题。在现实世界中遇到下面的问题。
```
f := 4.02
i := int(f * 100.0)
fmt.Println("i = ", i)
```
> i = 401
*/
@jinuljt
jinuljt / forms.go
Last active August 29, 2015 14:25
go form validate
package forms
import "github.com/gorilla/schema"
import "github.com/go-validator/validator"
var decoder = schema.NewDecoder()
func Validate(
dst interface{},
values map[string][]string) (bool, map[string][]error) {
@jinuljt
jinuljt / devtools.md
Last active December 7, 2015 16:47
技术/工具栈
@jinuljt
jinuljt / securepost.go
Last active December 3, 2020 03:28
微信退款接口使用商户证书请求golang实现
import (
"bytes"
"crypto/tls"
"crypto/x509"
"io/ioutil"
"net/http"
)
wechatCertPath = "/path/to/wechat/cert.pem"
wechatKeyPath = "/path/to/wechat/key.pem"
import fcntl
import time
import sys
lock = file('singleapp.lock', "w+")
try:
fcntl.lockf(lock, fcntl.LOCK_EX|fcntl.LOCK_NB)
except Exception, e:
print "kill me before start again"