goutils

package module
v0.0.0-...-f03f038 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2016 License: Apache-2.0 Imports: 21 Imported by: 12

README

utils

Golang工具箱

  • 将Jsonp转化为Json
    • JsonpToJson modify jsonp string to json string
    • Example: forbar({a:"1",b:2}) to {"a":"1","b":2}
JsonpToJson(json string) string
  • 获取工作路径
GetWDPath() string
  • 判断目录是否存在
IsDirExists(path string) bool
  • 判断文件是否存在
IsFileExists(path string) bool
  • 判断字符串是否为数字字符串
IsStringNum(a string) bool
  • 将xml转化为map[string]string
XML2mapstr(xmldoc string) map[string]string
  • 将字符串转化成hash
MakeHash(s string) string

Documentation

Overview

Package config provides for parse config file.

Index

Constants

View Source
const (
	BUF0 = 0
	BUF1 = 1
)

Variables

This section is empty.

Functions

func Contains

func Contains(obj interface{}, target interface{}) (bool, error)

判断obj是否在Slice/Array/Map中

func DeepCopy

func DeepCopy(dst, src interface{}) error

对象的深度拷贝

func GetKVInRelaPath

func GetKVInRelaPath(path string) map[string]string

获取绝对路径或相对路径中的参数,返回参数字典 /Book/ShowBookList.aspx?tclassid=3&page=1

func GetSetting

func GetSetting(settings map[string]string, key string) (string, bool)

获取配置文件信息

func GetWDPath

func GetWDPath() string

The GetWDPath gets the work directory path.

func IsDirExists

func IsDirExists(path string) bool

判断目录是否存在 The IsDirExists judges path is directory or not.

func IsFileExists

func IsFileExists(path string) bool

判断文件是否存在 The IsFileExists judges path is file or not.

func IsStringNum

func IsStringNum(a string) bool

判断字符串是否为数字字符串 The IsNum judges string is number or not.

func JsonpToJson

func JsonpToJson(json string) string

将Jsonp转化为Json JsonpToJson modify jsonp string to json string Example: forbar({a:"1",b:2}) to {"a":"1","b":2}

func MakeHash

func MakeHash(s string) string

将字符串转化成hash string to hash

func MapDictSortToStr

func MapDictSortToStr(dict map[string]string) (ret string)

func Md5

func Md5(str string) (ret string)

md5加密

func PutError

func PutError(err error)

func XML2mapstr

func XML2mapstr(xmldoc string) map[string]string

将xml转化为map[string]string simple xml to string support utf8

Types

type Config

type Config struct {
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig() *Config

func (*Config) Clear

func (self *Config) Clear()

func (*Config) GlobalContent

func (self *Config) GlobalContent() map[string]string

func (*Config) GlobalGet

func (self *Config) GlobalGet(key string) string

func (*Config) GlobalGetDeadline

func (self *Config) GlobalGetDeadline(key string) time.Time

func (*Config) GlobalGetDuration

func (self *Config) GlobalGetDuration(key string) time.Duration

func (*Config) GlobalGetInt

func (self *Config) GlobalGetInt(key string) int

func (*Config) GlobalGetInt64

func (self *Config) GlobalGetInt64(key string) int64

func (*Config) GlobalGetSlice

func (self *Config) GlobalGetSlice(key string, separator string) []string

func (*Config) GlobalGetSliceInt

func (self *Config) GlobalGetSliceInt(key string, separator string) []int

func (*Config) GlobalHas

func (self *Config) GlobalHas(key string) bool

func (*Config) GlobalSet

func (self *Config) GlobalSet(key string, value string)

func (*Config) HasSection

func (self *Config) HasSection(section string) bool

func (*Config) Load

func (self *Config) Load(configFile string) *Config

Load reads config file and returns an initialized Config.

func (*Config) LoadString

func (self *Config) LoadString(s string) error

func (*Config) Save

func (self *Config) Save(configFile string) error

Save writes config content to a config file.

func (*Config) SectionContent

func (self *Config) SectionContent(section string) map[string]string

func (*Config) SectionContents

func (self *Config) SectionContents() map[string]map[string]string

func (*Config) SectionGet

func (self *Config) SectionGet(section string, key string) string

func (*Config) SectionGetDuration

func (self *Config) SectionGetDuration(section string, key string) time.Duration

func (*Config) SectionGetInt

func (self *Config) SectionGetInt(section string, key string) int

func (*Config) SectionGetSlice

func (self *Config) SectionGetSlice(section string, key string, separator string) []string

func (*Config) SectionHas

func (self *Config) SectionHas(section string, key string) bool

func (*Config) SectionSet

func (self *Config) SectionSet(section string, key string, value string)

func (*Config) Sections

func (self *Config) Sections() []string

func (*Config) String

func (self *Config) String() string

func (*Config) StringWithMeta

func (self *Config) StringWithMeta() string

type DLoad

type DLoad struct {
	// contains filtered or unexported fields
}

func NewDLoad

func NewDLoad() *DLoad

func (*DLoad) Get

func (self *DLoad) Get() interface{}

获取配置文件中的map

func (*DLoad) Load

func (self *DLoad) Load(filename string, fn func(string) (interface{}, error)) error

动态加载配置文件æ¹法

type GoroutinePool

type GoroutinePool struct {
	Queue  chan func() error
	Number int
	Total  int
	// contains filtered or unexported fields
}

func (*GoroutinePool) AddTask

func (self *GoroutinePool) AddTask(task func() error)

添加任务

func (*GoroutinePool) Init

func (self *GoroutinePool) Init(number int, total int)

初始化

func (*GoroutinePool) SetFinishCallback

func (self *GoroutinePool) SetFinishCallback(callback func())

设置结束回调

func (*GoroutinePool) Start

func (self *GoroutinePool) Start()

开门接客

func (*GoroutinePool) Stop

func (self *GoroutinePool) Stop()

关门送客

type HandleInterface

type HandleInterface interface {
	Prepare(w http.ResponseWriter, r *http.Request, web *Web)
	Get(w http.ResponseWriter, r *http.Request, web *Web)
	Put(w http.ResponseWriter, r *http.Request, web *Web)
	Post(w http.ResponseWriter, r *http.Request, web *Web)
	Options(w http.ResponseWriter, r *http.Request, web *Web)
	Head(w http.ResponseWriter, r *http.Request, web *Web)
	Delete(w http.ResponseWriter, r *http.Request, web *Web)
	Connect(w http.ResponseWriter, r *http.Request, web *Web)
	Finish(w http.ResponseWriter, r *http.Request, web *Web)
	Closed() bool
}

type Web

type Web struct {
	//配置信息
	Settings map[string]string
}

全局控制对象

func NewWeb

func NewWeb(setting map[string]string) *Web

func (*Web) Go

func (self *Web) Go(handler HandleInterface) http.HandlerFunc

type WebHandler

type WebHandler struct {
	// contains filtered or unexported fields
}

所有http处理类都继承此类

func (*WebHandler) Closed

func (self *WebHandler) Closed() bool

func (*WebHandler) Connect

func (self *WebHandler) Connect(w http.ResponseWriter, r *http.Request, web *Web)

func (*WebHandler) Delete

func (self *WebHandler) Delete(w http.ResponseWriter, r *http.Request, web *Web)

func (*WebHandler) Finish

func (self *WebHandler) Finish(w http.ResponseWriter, r *http.Request, web *Web)

func (*WebHandler) Get

func (self *WebHandler) Get(w http.ResponseWriter, r *http.Request, web *Web)

func (*WebHandler) Head

func (self *WebHandler) Head(w http.ResponseWriter, r *http.Request, web *Web)

func (*WebHandler) Options

func (self *WebHandler) Options(w http.ResponseWriter, r *http.Request, web *Web)

func (*WebHandler) Post

func (self *WebHandler) Post(w http.ResponseWriter, r *http.Request, web *Web)

func (*WebHandler) Prepare

func (self *WebHandler) Prepare(w http.ResponseWriter, r *http.Request, web *Web)

func (*WebHandler) Put

func (self *WebHandler) Put(w http.ResponseWriter, r *http.Request, web *Web)

func (*WebHandler) StopRun

func (self *WebHandler) StopRun()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL