save
This commit is contained in:
parent
ef6a02719b
commit
50cb269954
@ -1,9 +1,9 @@
|
|||||||
package q5
|
package q5
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"errors"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ToInt converts a value to an integer.
|
// ToInt converts a value to an integer.
|
||||||
@ -11,6 +11,11 @@ func ToInt32[T string | int | int32 | int64 | float32 | float64](value T) int32
|
|||||||
return int32(ToInt64(value))
|
return int32(ToInt64(value))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ToInt converts a value to an integer.
|
||||||
|
func ToInt[T string | int32 | int64 | float32 | float64](value T) int {
|
||||||
|
return int(ToInt64(value))
|
||||||
|
}
|
||||||
|
|
||||||
// ToInt64 converts a value to an int64.
|
// ToInt64 converts a value to an int64.
|
||||||
func ToInt64[T string | int | int32 | int64 | float32 | float64](value T) int64 {
|
func ToInt64[T string | int | int32 | int64 | float32 | float64](value T) int64 {
|
||||||
var x interface{} = value
|
var x interface{} = value
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package q5
|
package q5
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
net_url "net/url"
|
net_url "net/url"
|
||||||
"io/ioutil"
|
|
||||||
"errors"
|
|
||||||
//"strings"
|
//"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ func HttpGetEx(url string, params map[string]string,
|
|||||||
panic("http.NewRequest error")
|
panic("http.NewRequest error")
|
||||||
}
|
}
|
||||||
if initFunc != nil {
|
if initFunc != nil {
|
||||||
initFunc(func (opt int32, key string, val string) {
|
initFunc(func(opt int32, key string, val string) {
|
||||||
internalSetOpt(client, request, opt, key, val)
|
internalSetOpt(client, request, opt, key, val)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
16
mysql.go
16
mysql.go
@ -1,8 +1,8 @@
|
|||||||
package q5
|
package q5
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"fmt"
|
||||||
_ "github.com/go-sql-driver/mysql"
|
_ "github.com/go-sql-driver/mysql"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ type Mysql struct {
|
|||||||
db *sql.DB
|
db *sql.DB
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this* Mysql) init(host string, port int32, user string, passwd string, database string) {
|
func (this *Mysql) init(host string, port int32, user string, passwd string, database string) {
|
||||||
this.host = host
|
this.host = host
|
||||||
this.port = port
|
this.port = port
|
||||||
this.user = user
|
this.user = user
|
||||||
@ -23,7 +23,7 @@ func (this* Mysql) init(host string, port int32, user string, passwd string, dat
|
|||||||
this.database = database
|
this.database = database
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this* Mysql) Open() error {
|
func (this *Mysql) Open() error {
|
||||||
connStr := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8",
|
connStr := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8",
|
||||||
this.user,
|
this.user,
|
||||||
this.passwd,
|
this.passwd,
|
||||||
@ -35,26 +35,26 @@ func (this* Mysql) Open() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this* Mysql) Close() {
|
func (this *Mysql) Close() {
|
||||||
if this.db != nil {
|
if this.db != nil {
|
||||||
this.db.Close()
|
this.db.Close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this* Mysql) Ping() error {
|
func (this *Mysql) Ping() error {
|
||||||
return this.db.Ping()
|
return this.db.Ping()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this* Mysql) Query(query string, args ...interface{}) (*sql.Rows, error) {
|
func (this *Mysql) Query(query string, args ...interface{}) (*sql.Rows, error) {
|
||||||
rows, err := this.db.Query(query, args...)
|
rows, err := this.db.Query(query, args...)
|
||||||
return rows, err
|
return rows, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this* Mysql) QueryRow(query string, args ...interface{}) *sql.Row {
|
func (this *Mysql) QueryRow(query string, args ...interface{}) *sql.Row {
|
||||||
return this.db.QueryRow(query, args...)
|
return this.db.QueryRow(query, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this* Mysql) Exec(query string, args ...interface{}) (sql.Result, error) {
|
func (this *Mysql) Exec(query string, args ...interface{}) (sql.Result, error) {
|
||||||
result, err := this.db.Exec(query, args...)
|
result, err := this.db.Exec(query, args...)
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
6
redis.go
6
redis.go
@ -11,14 +11,14 @@ type Redis struct {
|
|||||||
conn *redis.Conn
|
conn *redis.Conn
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this* Redis) Init(host string, port int32, passwd string) {
|
func (this *Redis) Init(host string, port int32, passwd string) {
|
||||||
this.host = host
|
this.host = host
|
||||||
this.port = port
|
this.port = port
|
||||||
this.passwd = passwd
|
this.passwd = passwd
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this* Redis) Open() {
|
func (this *Redis) Open() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this* Redis) Close() {
|
func (this *Redis) Close() {
|
||||||
}
|
}
|
||||||
|
12
strutils.go
12
strutils.go
@ -1,13 +1,13 @@
|
|||||||
package q5
|
package q5
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
|
||||||
"strings"
|
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
|
"encoding/base64"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"encoding/base64"
|
|
||||||
"hash/crc32"
|
"hash/crc32"
|
||||||
|
"io"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -82,16 +82,16 @@ func ConvertUpperCamelCase(name string) string {
|
|||||||
preIs_ := false
|
preIs_ := false
|
||||||
for i := 0; i < len(name); i++ {
|
for i := 0; i < len(name); i++ {
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
newName += strings.ToUpper(name[i:i +1])
|
newName += strings.ToUpper(name[i : i+1])
|
||||||
preIs_ = name[i] == '_'
|
preIs_ = name[i] == '_'
|
||||||
} else {
|
} else {
|
||||||
if preIs_ {
|
if preIs_ {
|
||||||
if name[i] != '_' {
|
if name[i] != '_' {
|
||||||
newName += strings.ToUpper(name[i:i +1])
|
newName += strings.ToUpper(name[i : i+1])
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if name[i] != '_' {
|
if name[i] != '_' {
|
||||||
newName += name[i:i +1]
|
newName += name[i : i+1]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
preIs_ = name[i] == '_'
|
preIs_ = name[i] == '_'
|
||||||
|
2
types.go
2
types.go
@ -1,6 +1,6 @@
|
|||||||
package q5
|
package q5
|
||||||
|
|
||||||
type TimerCb func (int32, *Args)
|
type TimerCb func(int32, *Args)
|
||||||
type Args []interface{}
|
type Args []interface{}
|
||||||
|
|
||||||
type Module interface {
|
type Module interface {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user