go_library

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

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

Go to latest
Published: Mar 5, 2017 License: Apache-2.0 Imports: 9 Imported by: 0

README

go-library

常用的golang代码,包含通用异常捕获阻止程序终止运行

go get github.com/cplusgo/go-library
package main

import (
    "fmt"
    "github.com/cplusgo/go-library"
)

type SampleWorker struct {

}

func (this *SampleWorker) Try() {
    fmt.Println("我在执行")
    fmt.Println("准备抛出异常")
    panic("抛出异常")
}

func (this *SampleWorker) Catch(err interface{})  {
    fmt.Println("异常已经被捕获")
}

func main()  {
    worker := &SampleWorker{}
    go_library.Run(worker)
    fmt.Println("虽然有异常,我还在执行")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64

func Base64(str string) string

func GetStructName

func GetStructName(data interface{}) string

func HasAttr

func HasAttr(data interface{}, attrName string) bool

func HasMethod

func HasMethod(data interface{}, methodName string) bool

func IsStruct

func IsStruct(data interface{}) bool

func MD5

func MD5(origin string) string

func MakeSign

func MakeSign(params map[string]string) string

func MapToXMLString

func MapToXMLString(data map[string]string) string

func MapToXMLStringRe

func MapToXMLStringRe()

func Run

func Run(worker TryCatchWorker)

func TimeMd5

func TimeMd5() string

func ToURLParamsSortByKey

func ToURLParamsSortByKey(params map[string]string) string

func UnixSeconds

func UnixSeconds() int64

Types

type TryCatchWorker

type TryCatchWorker interface {
	Try()
	Catch(err interface{})
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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