mirror of
https://gitee.com/johng/gf
synced 2026-06-06 02:25:47 +08:00
comment update for gtype
This commit is contained in:
@ -7,9 +7,7 @@ import (
|
||||
func main() {
|
||||
s := ghttp.GetServer()
|
||||
s.BindHandler("/log/error", func(r *ghttp.Request) {
|
||||
if j := r.GetJson(); j != nil {
|
||||
r.Response.Write(j.Get("test"))
|
||||
}
|
||||
panic("OMG")
|
||||
})
|
||||
s.SetErrorLogEnabled(true)
|
||||
s.SetPort(8199)
|
||||
|
||||
@ -1,13 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/text/gstr"
|
||||
"github.com/gogf/gf/net/ghttp"
|
||||
)
|
||||
|
||||
func main() {
|
||||
a := "aaaaa_post"
|
||||
b := "aaaaa_"
|
||||
c := gstr.TrimLeftStr(a, b)
|
||||
fmt.Println(c)
|
||||
s := ghttp.GetServer()
|
||||
s.BindHandler("/log/path", func(r *ghttp.Request) {
|
||||
r.Response.Writeln("请到/tmp/gf.log目录查看日志")
|
||||
})
|
||||
s.SetLogPath("/tmp/gf.log")
|
||||
s.SetAccessLogEnabled(true)
|
||||
s.SetErrorLogEnabled(true)
|
||||
s.SetPort(8199)
|
||||
s.Run()
|
||||
}
|
||||
|
||||
@ -12,6 +12,7 @@ import (
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
// Bool is a struct for concurrent-safe operation for type bool.
|
||||
type Bool struct {
|
||||
value int32
|
||||
}
|
||||
@ -21,7 +22,7 @@ var (
|
||||
bytesFalse = []byte("false")
|
||||
)
|
||||
|
||||
// NewBool returns a concurrent-safe object for bool type,
|
||||
// NewBool creates and returns a concurrent-safe object for bool type,
|
||||
// with given initial value <value>.
|
||||
func NewBool(value ...bool) *Bool {
|
||||
t := &Bool{}
|
||||
@ -50,7 +51,7 @@ func (v *Bool) Set(value bool) (old bool) {
|
||||
return
|
||||
}
|
||||
|
||||
// Val atomically loads t.valueue.
|
||||
// Val atomically loads and returns t.valueue.
|
||||
func (v *Bool) Val() bool {
|
||||
return atomic.LoadInt32(&v.value) > 0
|
||||
}
|
||||
|
||||
@ -12,11 +12,12 @@ import (
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
// Byte is a struct for concurrent-safe operation for type byte.
|
||||
type Byte struct {
|
||||
value int32
|
||||
}
|
||||
|
||||
// NewByte returns a concurrent-safe object for byte type,
|
||||
// NewByte creates and returns a concurrent-safe object for byte type,
|
||||
// with given initial value <value>.
|
||||
func NewByte(value ...byte) *Byte {
|
||||
if len(value) > 0 {
|
||||
@ -37,7 +38,7 @@ func (v *Byte) Set(value byte) (old byte) {
|
||||
return byte(atomic.SwapInt32(&v.value, int32(value)))
|
||||
}
|
||||
|
||||
// Val atomically loads t.value.
|
||||
// Val atomically loads and returns t.value.
|
||||
func (v *Byte) Val() byte {
|
||||
return byte(atomic.LoadInt32(&v.value))
|
||||
}
|
||||
|
||||
@ -13,11 +13,12 @@ import (
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
// Bytes is a struct for concurrent-safe operation for type []byte.
|
||||
type Bytes struct {
|
||||
value atomic.Value
|
||||
}
|
||||
|
||||
// NewBytes returns a concurrent-safe object for []byte type,
|
||||
// NewBytes creates and returns a concurrent-safe object for []byte type,
|
||||
// with given initial value <value>.
|
||||
func NewBytes(value ...[]byte) *Bytes {
|
||||
t := &Bytes{}
|
||||
@ -40,7 +41,7 @@ func (v *Bytes) Set(value []byte) (old []byte) {
|
||||
return
|
||||
}
|
||||
|
||||
// Val atomically loads t.value.
|
||||
// Val atomically loads and returns t.value.
|
||||
func (v *Bytes) Val() []byte {
|
||||
if s := v.value.Load(); s != nil {
|
||||
return s.([]byte)
|
||||
|
||||
@ -14,11 +14,12 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// Float32 is a struct for concurrent-safe operation for type float32.
|
||||
type Float32 struct {
|
||||
value uint32
|
||||
}
|
||||
|
||||
// NewFloat32 returns a concurrent-safe object for float32 type,
|
||||
// NewFloat32 creates and returns a concurrent-safe object for float32 type,
|
||||
// with given initial value <value>.
|
||||
func NewFloat32(value ...float32) *Float32 {
|
||||
if len(value) > 0 {
|
||||
@ -39,7 +40,7 @@ func (v *Float32) Set(value float32) (old float32) {
|
||||
return math.Float32frombits(atomic.SwapUint32(&v.value, math.Float32bits(value)))
|
||||
}
|
||||
|
||||
// Val atomically loads t.value.
|
||||
// Val atomically loads and returns t.value.
|
||||
func (v *Float32) Val() float32 {
|
||||
return math.Float32frombits(atomic.LoadUint32(&v.value))
|
||||
}
|
||||
|
||||
@ -14,11 +14,12 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// Float64 is a struct for concurrent-safe operation for type float64.
|
||||
type Float64 struct {
|
||||
value uint64
|
||||
}
|
||||
|
||||
// NewFloat64 returns a concurrent-safe object for float64 type,
|
||||
// NewFloat64 creates and returns a concurrent-safe object for float64 type,
|
||||
// with given initial value <value>.
|
||||
func NewFloat64(value ...float64) *Float64 {
|
||||
if len(value) > 0 {
|
||||
@ -39,7 +40,7 @@ func (v *Float64) Set(value float64) (old float64) {
|
||||
return math.Float64frombits(atomic.SwapUint64(&v.value, math.Float64bits(value)))
|
||||
}
|
||||
|
||||
// Val atomically loads t.value.
|
||||
// Val atomically loads and returns t.value.
|
||||
func (v *Float64) Val() float64 {
|
||||
return math.Float64frombits(atomic.LoadUint64(&v.value))
|
||||
}
|
||||
|
||||
@ -12,11 +12,12 @@ import (
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
// Int is a struct for concurrent-safe operation for type int.
|
||||
type Int struct {
|
||||
value int64
|
||||
}
|
||||
|
||||
// NewInt returns a concurrent-safe object for int type,
|
||||
// NewInt creates and returns a concurrent-safe object for int type,
|
||||
// with given initial value <value>.
|
||||
func NewInt(value ...int) *Int {
|
||||
if len(value) > 0 {
|
||||
@ -37,7 +38,7 @@ func (v *Int) Set(value int) (old int) {
|
||||
return int(atomic.SwapInt64(&v.value, int64(value)))
|
||||
}
|
||||
|
||||
// Val atomically loads t.value.
|
||||
// Val atomically loads and returns t.value.
|
||||
func (v *Int) Val() int {
|
||||
return int(atomic.LoadInt64(&v.value))
|
||||
}
|
||||
|
||||
@ -12,11 +12,12 @@ import (
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
// Int32 is a struct for concurrent-safe operation for type int32.
|
||||
type Int32 struct {
|
||||
value int32
|
||||
}
|
||||
|
||||
// NewInt32 returns a concurrent-safe object for int32 type,
|
||||
// NewInt32 creates and returns a concurrent-safe object for int32 type,
|
||||
// with given initial value <value>.
|
||||
func NewInt32(value ...int32) *Int32 {
|
||||
if len(value) > 0 {
|
||||
@ -37,7 +38,7 @@ func (v *Int32) Set(value int32) (old int32) {
|
||||
return atomic.SwapInt32(&v.value, value)
|
||||
}
|
||||
|
||||
// Val atomically loads t.value.
|
||||
// Val atomically loads and returns t.value.
|
||||
func (v *Int32) Val() int32 {
|
||||
return atomic.LoadInt32(&v.value)
|
||||
}
|
||||
|
||||
@ -12,11 +12,12 @@ import (
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
// Int64 is a struct for concurrent-safe operation for type int64.
|
||||
type Int64 struct {
|
||||
value int64
|
||||
}
|
||||
|
||||
// NewInt64 returns a concurrent-safe object for int64 type,
|
||||
// NewInt64 creates and returns a concurrent-safe object for int64 type,
|
||||
// with given initial value <value>.
|
||||
func NewInt64(value ...int64) *Int64 {
|
||||
if len(value) > 0 {
|
||||
@ -37,7 +38,7 @@ func (v *Int64) Set(value int64) (old int64) {
|
||||
return atomic.SwapInt64(&v.value, value)
|
||||
}
|
||||
|
||||
// Val atomically loads t.value.
|
||||
// Val atomically loads and returns t.value.
|
||||
func (v *Int64) Val() int64 {
|
||||
return atomic.LoadInt64(&v.value)
|
||||
}
|
||||
|
||||
@ -12,11 +12,12 @@ import (
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
// Interface is a struct for concurrent-safe operation for type interface{}.
|
||||
type Interface struct {
|
||||
value atomic.Value
|
||||
}
|
||||
|
||||
// NewInterface returns a concurrent-safe object for interface{} type,
|
||||
// NewInterface creates and returns a concurrent-safe object for interface{} type,
|
||||
// with given initial value <value>.
|
||||
func NewInterface(value ...interface{}) *Interface {
|
||||
t := &Interface{}
|
||||
@ -39,7 +40,7 @@ func (v *Interface) Set(value interface{}) (old interface{}) {
|
||||
return
|
||||
}
|
||||
|
||||
// Val atomically loads t.value.
|
||||
// Val atomically loads and returns t.value.
|
||||
func (v *Interface) Val() interface{} {
|
||||
return v.value.Load()
|
||||
}
|
||||
|
||||
@ -12,11 +12,12 @@ import (
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
// String is a struct for concurrent-safe operation for type string.
|
||||
type String struct {
|
||||
value atomic.Value
|
||||
}
|
||||
|
||||
// NewString returns a concurrent-safe object for string type,
|
||||
// NewString creates and returns a concurrent-safe object for string type,
|
||||
// with given initial value <value>.
|
||||
func NewString(value ...string) *String {
|
||||
t := &String{}
|
||||
@ -38,7 +39,7 @@ func (v *String) Set(value string) (old string) {
|
||||
return
|
||||
}
|
||||
|
||||
// Val atomically loads t.value.
|
||||
// Val atomically loads and returns t.value.
|
||||
func (v *String) Val() string {
|
||||
s := v.value.Load()
|
||||
if s != nil {
|
||||
|
||||
@ -12,11 +12,12 @@ import (
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
// Uint is a struct for concurrent-safe operation for type uint.
|
||||
type Uint struct {
|
||||
value uint64
|
||||
}
|
||||
|
||||
// NewUint returns a concurrent-safe object for uint type,
|
||||
// NewUint creates and returns a concurrent-safe object for uint type,
|
||||
// with given initial value <value>.
|
||||
func NewUint(value ...uint) *Uint {
|
||||
if len(value) > 0 {
|
||||
@ -37,7 +38,7 @@ func (v *Uint) Set(value uint) (old uint) {
|
||||
return uint(atomic.SwapUint64(&v.value, uint64(value)))
|
||||
}
|
||||
|
||||
// Val atomically loads t.value.
|
||||
// Val atomically loads and returns t.value.
|
||||
func (v *Uint) Val() uint {
|
||||
return uint(atomic.LoadUint64(&v.value))
|
||||
}
|
||||
|
||||
@ -12,11 +12,12 @@ import (
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
// Uint32 is a struct for concurrent-safe operation for type uint32.
|
||||
type Uint32 struct {
|
||||
value uint32
|
||||
}
|
||||
|
||||
// NewUint32 returns a concurrent-safe object for uint32 type,
|
||||
// NewUint32 creates and returns a concurrent-safe object for uint32 type,
|
||||
// with given initial value <value>.
|
||||
func NewUint32(value ...uint32) *Uint32 {
|
||||
if len(value) > 0 {
|
||||
@ -37,7 +38,7 @@ func (v *Uint32) Set(value uint32) (old uint32) {
|
||||
return atomic.SwapUint32(&v.value, value)
|
||||
}
|
||||
|
||||
// Val atomically loads t.value.
|
||||
// Val atomically loads and returns t.value.
|
||||
func (v *Uint32) Val() uint32 {
|
||||
return atomic.LoadUint32(&v.value)
|
||||
}
|
||||
|
||||
@ -12,11 +12,12 @@ import (
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
// Uint64 is a struct for concurrent-safe operation for type uint64.
|
||||
type Uint64 struct {
|
||||
value uint64
|
||||
}
|
||||
|
||||
// NewUint64 returns a concurrent-safe object for uint64 type,
|
||||
// NewUint64 creates and returns a concurrent-safe object for uint64 type,
|
||||
// with given initial value <value>.
|
||||
func NewUint64(value ...uint64) *Uint64 {
|
||||
if len(value) > 0 {
|
||||
@ -37,7 +38,7 @@ func (v *Uint64) Set(value uint64) (old uint64) {
|
||||
return atomic.SwapUint64(&v.value, value)
|
||||
}
|
||||
|
||||
// Val atomically loads t.value.
|
||||
// Val atomically loads and returns t.value.
|
||||
func (v *Uint64) Val() uint64 {
|
||||
return atomic.LoadUint64(&v.value)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user