Documentation ¶
Index ¶
- func CheckRequiredFlags(cmd *cobra.Command) error
- func GetFlagB(cmd *cobra.Command, name string) bool
- func GetFlagI(cmd *cobra.Command, name string) int64
- func GetFlagS(cmd *cobra.Command, name string) string
- func GetFlagSArr(cmd *cobra.Command, name string) []string
- func GetFreeTcpPort() (int, error)
- func MakeCompletionCmd() *cobra.Command
- func MakeRandomStr(numBytes int) string
- func MustJson(obj interface{}) string
- func MustJsonIndent(obj interface{}, indent string) string
- func NewCleanup(cl func()) *cleanuper
- func NewCleanupErr(cl func() error) *cleanuper
- func NullableStr(val interface{}) string
- func PanicIfErr(err error)
- func PanicIfF(cond bool, msg string, args ...interface{})
- func StaticClock(sec int64) func() time.Time
- func ToNullStr(val string) sql.NullString
- func ToSnakeCase(in string, delim rune) string
- func ToSqlI64(val *int64) sql.NullInt64
- func Use(_ interface{})
- type AbsoluteTimeSec
- type AwsMockHandler
- type LockSession
- type MemorySink
- type SessionedMutex
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckRequiredFlags ¶
func GetFreeTcpPort ¶
func MakeRandomStr ¶
func MustJsonIndent ¶
func NewCleanup ¶
func NewCleanup(cl func()) *cleanuper
func NewCleanupErr ¶
func NewCleanupErr(cl func() error) *cleanuper
func NullableStr ¶
func NullableStr(val interface{}) string
func PanicIfErr ¶
func PanicIfErr(err error)
func StaticClock ¶
func ToNullStr ¶
func ToNullStr(val string) sql.NullString
func ToSnakeCase ¶
ToSnakeCase convert the given string to snake case following the Golang format: acronyms are converted to lower-case and preceded by an underscore.
Types ¶
type AbsoluteTimeSec ¶
type AbsoluteTimeSec int64
Time in milliseconds since the Unix epoch
func FromTimeSec ¶
func FromTimeSec(tm time.Time) AbsoluteTimeSec
func (AbsoluteTimeSec) ToTime ¶
func (at AbsoluteTimeSec) ToTime() time.Time
func (AbsoluteTimeSec) ToUnix ¶
func (at AbsoluteTimeSec) ToUnix() int64
type AwsMockHandler ¶
type AwsMockHandler struct {
// contains filtered or unexported fields
}
func NewAwsMockHandler ¶
func NewAwsMockHandler() *AwsMockHandler
Create an AWS mocker to use with the AWS services, it returns an instrumented aws.Config that can be used to create AWS services. You can add as many individual request handlers as you need, as long as handlers correspond to the func(context.Context, <arg>)(<res>, error) format. E.g.: func(context.Context, *ec2.TerminateInstancesInput)(*ec2.TerminateInstancesOutput, error)
You can also use a struct as the handler, in this case the AwsMockHandler will try to search for a method with a conforming signature.
Example ¶
am := NewAwsMockHandler() am.AddHandler(func(ctx context.Context, arg *ec2.TerminateInstancesInput) ( *ec2.TerminateInstancesOutput, error) { if arg.InstanceIds[0] != "i-123" { panic("BadInstanceId") } return &ec2.TerminateInstancesOutput{}, nil }) ec := ec2.New(am.AwsConfig()) _, _ = ec.TerminateInstancesRequest(&ec2.TerminateInstancesInput{ InstanceIds: []string{"i-123"}, }).Send(context.Background())
Output:
func (*AwsMockHandler) AddHandler ¶
func (a *AwsMockHandler) AddHandler(handlerObject interface{})
func (*AwsMockHandler) AwsConfig ¶
func (a *AwsMockHandler) AwsConfig() aws.Config
type LockSession ¶
type LockSession struct {
// contains filtered or unexported fields
}
type MemorySink ¶
MemorySink implements zap.Sink by writing all messages to a buffer.
func NewMemorySinkLogger ¶
func NewMemorySinkLogger() (*MemorySink, *zap.Logger)
func (*MemorySink) Close ¶
func (s *MemorySink) Close() error
func (*MemorySink) Sync ¶
func (s *MemorySink) Sync() error
type SessionedMutex ¶
type SessionedMutex struct {
// contains filtered or unexported fields
}
A mutex that yields a 'lock session' supporting idempotent unlock
func (*SessionedMutex) Lock ¶
func (s *SessionedMutex) Lock() *LockSession
func (*SessionedMutex) ReadLock ¶
func (s *SessionedMutex) ReadLock() *LockSession