Documentation
¶
Index ¶
- func DecodeBase64(msg string) (string, error)
- func EncodeBase64(msg string) string
- func Errorf(format string, v ...interface{})
- func GenHelp(options []Option, desc string) string
- func GetConf(filename string) (map[string][]string, error)
- func GetOptions(options []Option) (map[string]string, []string)
- func ListenAndHttp(network, addr, crt, key string, handler http.Handler)
- func MD5(src string) string
- func Now() int64
- func NowNano() uint64
- func Printf(format string, v ...interface{})
- func Random() float64
- func RandomString(length int) string
- func ReadLineN(filename string, n int) ([]string, error)
- func ServeHttp(cfg *ListenOptions, handler http.Handler)
- func Socket(port string) (net.Listener, error)
- func TLSSocket(port string, crt string, key string) (net.Listener, error)
- type Any_t
- type ListenOptions
- type Option
- type Pool_t
- type RangeLink_t
- func (this *RangeLink_t) Append(newNode *RangeNode_t)
- func (this *RangeLink_t) Converse(start int64, end int64) *RangeLink_t
- func (this *RangeLink_t) Front() *Range_t
- func (this *RangeLink_t) Mount(start int64, end int64)
- func (this *RangeLink_t) Pop()
- func (this *RangeLink_t) Push(newNode *RangeNode_t)
- func (this *RangeLink_t) ToArray() []Range_t
- type RangeNode_t
- type Range_t
- type Stream
- type Worker
- type WorkerGenerator
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeBase64 ¶ added in v0.1.7
func EncodeBase64 ¶
func GetConf ¶
读取配置文件
Example ¶
package main
import (
"fmt"
"github.com/watsonserve/goutils"
)
func main() {
// # test.conf
// # this is a config file
// foo = bar
// foos=1
// foos = 2
// null
//
conf, err := goutils.GetConf("test.conf")
if nil != err {
return
}
fmt.Println(conf)
}
Output: map[foo:[bar] foos:[1 2] null:[]]
Example ¶
package main
import (
"fmt"
"github.com/watsonserve/goutils"
)
func main() {
// # test.conf
// # this is a config file
// foo = bar
// foos=1
// foos = 2
// null
//
link := goutils.NewList(nil)
link.Mount(20, 80)
fmt.Println(link.ToArray())
}
Output:
func GetOptions ¶
parse commandline params
Example ¶
package main
import (
"fmt"
"github.com/watsonserve/goutils"
)
func main() {
options := []goutils.Option{
{
Opt: 'h',
Option: "help",
HasParams: false,
},
{
Opt: 'z',
Option: "gz",
HasParams: false,
},
{
Opt: 'C',
Option: "cc",
HasParams: true,
},
{
Opt: 'f',
Option: "file",
HasParams: true,
},
}
argMap, params := goutils.GetOptions(options)
fmt.Println(argMap)
fmt.Println(params)
}
Output:
func ListenAndHttp ¶ added in v0.1.8
func Printf ¶
func Printf(format string, v ...interface{})
Example ¶
package main
import (
"github.com/watsonserve/goutils"
)
func main() {
goutils.Printf("- %d -\n", 404)
}
Output:
func RandomString ¶
func ServeHttp ¶ added in v0.1.8
func ServeHttp(cfg *ListenOptions, handler http.Handler)
Types ¶
type ListenOptions ¶ added in v0.1.9
type Pool_t ¶ added in v0.1.3
type Pool_t struct {
// contains filtered or unexported fields
}
func NewPool ¶ added in v0.1.3
func NewPool(workerInit WorkerGenerator, size int) *Pool_t
type RangeLink_t ¶ added in v0.1.2
type RangeLink_t struct {
// contains filtered or unexported fields
}
func NewRangeLink ¶ added in v0.1.2
func NewRangeLink(arr []Range_t) *RangeLink_t
func (*RangeLink_t) Append ¶ added in v0.1.2
func (this *RangeLink_t) Append(newNode *RangeNode_t)
尾添加
func (*RangeLink_t) Converse ¶ added in v0.1.2
func (this *RangeLink_t) Converse(start int64, end int64) *RangeLink_t
取反
func (*RangeLink_t) Mount ¶ added in v0.1.2
func (this *RangeLink_t) Mount(start int64, end int64)
挂载
type RangeNode_t ¶ added in v0.1.2
type RangeNode_t struct {
Range_t
Next *RangeNode_t
}
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
func InitStream ¶
func InitStream(sock io.ReadWriteCloser) *Stream
type WorkerGenerator ¶ added in v0.1.4
Source Files
¶
Click to show internal directories.
Click to hide internal directories.