Documentation
¶
Overview ¶
Package util defines the common utilities including string and time.
Index ¶
- Constants
- Variables
- func CalculateContentCrc32(data io.Reader, size int64) (string, error)
- func CalculateContentCrc32FromFile(file *os.File, offset, size int64) (string, error)
- func CalculateContentCrc32c(data io.Reader, size int64) (string, error)
- func CalculateContentCrc32cFromFile(fileName string) (string, error)
- func CalculateContentCrc32cFromStream(reader io.Reader) (string, error)
- func CalculateContentMD5(data io.Reader, size int64) (string, error)
- func Equal(expected, actual interface{}) bool
- func FormatISO8601Date(timestamp_second int64) string
- func FormatRFC822Date(timestamp_second int64) string
- func GetMimeMap() map[string]string
- func HmacSha256Hex(key, str_to_sign string) string
- func Int32PtrToString(p *int32) string
- func LoadMimeMap()
- func NewMockHTTPClient(options ...MockRoundTripperOption) *http.Client
- func NewRequestId() string
- func NewUUID() string
- func NowUTCNanoSeconds() int64
- func NowUTCSeconds() int64
- func ParseISO8601Date(time_string string) (time.Time, error)
- func ParseRFC822Date(time_string string) (time.Time, error)
- func PtrBool(v bool) *bool
- func PtrFloat32(v float32) *float32
- func PtrFloat64(v float64) *float64
- func PtrInt(v int) *int
- func PtrInt32(v int32) *int32
- func PtrInt64(v int64) *int64
- func PtrString(v string) *string
- func StringValue(p *string) string
- func UriEncode(uri string, encodeSlash bool) string
- type MockRoundTripper
- type MockRoundTripperOption
- func AddHeaders(kv map[string]string) MockRoundTripperOption
- func AppendHTTPClientDoError(err []error) MockRoundTripperOption
- func AppendRespBody(respBody []string) MockRoundTripperOption
- func AppendStatusCode(statusCode []int) MockRoundTripperOption
- func AppendStatusMsg(statusMsg []string) MockRoundTripperOption
- func SetHTTPClientDoError(err error) MockRoundTripperOption
- func SetRequestTime(value time.Duration) MockRoundTripperOption
- func SetRespBody(respBody string) MockRoundTripperOption
- func SetStatusCode(statusCode int) MockRoundTripperOption
- func SetStatusMsg(statusMsg string) MockRoundTripperOption
Constants ¶
View Source
const ( RFC822Format = "Mon, 02 Jan 2006 15:04:05 MST" ISO8601Format = "2006-01-02T15:04:05Z" )
Variables ¶
View Source
var ( RoundTripperOpts403 = []MockRoundTripperOption{SetStatusCode(http.StatusForbidden), SetStatusMsg("403 Forbidden")} RoundTripperOpts404 = []MockRoundTripperOption{SetStatusCode(http.StatusNotFound), SetStatusMsg("404 NOT Found")} RoundTripperOpts408 = []MockRoundTripperOption{SetStatusCode(http.StatusRequestTimeout), SetStatusMsg(http.StatusText(http.StatusRequestTimeout))} RoundTripperOpts500 = []MockRoundTripperOption{SetStatusCode(http.StatusInternalServerError), SetStatusMsg(http.StatusText(http.StatusInternalServerError))} )
View Source
var DefaultMimeMap map[string]string
Functions ¶
func CalculateContentCrc32 ¶ added in v0.9.263
func CalculateContentCrc32FromFile ¶ added in v0.9.263
func CalculateContentCrc32c ¶ added in v0.9.231
func CalculateContentCrc32cFromFile ¶ added in v0.9.231
func CalculateContentCrc32cFromStream ¶ added in v0.9.231
func FormatISO8601Date ¶
func FormatRFC822Date ¶
func GetMimeMap ¶ added in v0.9.139
func HmacSha256Hex ¶
func Int32PtrToString ¶ added in v0.9.263
func LoadMimeMap ¶ added in v0.9.139
func LoadMimeMap()
func NewMockHTTPClient ¶ added in v0.9.257
func NewMockHTTPClient(options ...MockRoundTripperOption) *http.Client
func NewRequestId ¶
func NewRequestId() string
func NowUTCNanoSeconds ¶
func NowUTCNanoSeconds() int64
func NowUTCSeconds ¶
func NowUTCSeconds() int64
func PtrFloat32 ¶ added in v0.9.259
func PtrFloat64 ¶ added in v0.9.259
func StringValue ¶ added in v0.9.259
Types ¶
type MockRoundTripper ¶ added in v0.9.257
type MockRoundTripperOption ¶ added in v0.9.257
type MockRoundTripperOption func(*MockRoundTripper)
func AddHeaders ¶ added in v0.9.257
func AddHeaders(kv map[string]string) MockRoundTripperOption
func AppendHTTPClientDoError ¶ added in v0.9.263
func AppendHTTPClientDoError(err []error) MockRoundTripperOption
func AppendRespBody ¶ added in v0.9.257
func AppendRespBody(respBody []string) MockRoundTripperOption
func AppendStatusCode ¶ added in v0.9.263
func AppendStatusCode(statusCode []int) MockRoundTripperOption
func AppendStatusMsg ¶ added in v0.9.263
func AppendStatusMsg(statusMsg []string) MockRoundTripperOption
func SetHTTPClientDoError ¶ added in v0.9.257
func SetHTTPClientDoError(err error) MockRoundTripperOption
func SetRequestTime ¶ added in v0.9.257
func SetRequestTime(value time.Duration) MockRoundTripperOption
func SetRespBody ¶ added in v0.9.257
func SetRespBody(respBody string) MockRoundTripperOption
func SetStatusCode ¶ added in v0.9.257
func SetStatusCode(statusCode int) MockRoundTripperOption
func SetStatusMsg ¶ added in v0.9.257
func SetStatusMsg(statusMsg string) MockRoundTripperOption
Click to show internal directories.
Click to hide internal directories.