Documentation ¶
Overview ¶
various utilities for go-lang.
Index ¶
- Constants
- func Check(e error)
- func DataUrl(b []byte, mimeType string) string
- func FormatApproxDuration(dur time.Duration, terms int) string
- func FormatDuration(dur time.Duration) string
- func FormatIsoUtc(t time.Time) string
- func InTimeRange(t, startInclusive, endExclusive time.Time) bool
- func ListenAndServeTLS(srv *http.Server, certFile, keyFile []byte) error
- func LoadZipData(path, url string) (*zip.Reader, error)
- func Marshal(i interface{}) string
- func MarshalIndent(i interface{}) string
- func NewToken(validity time.Duration, message, password string) string
- func ParseIsoUtc(t string) (time.Time, error)
- func PlatformInit()
- func Retry(msg string, bs RetryStrategyInstance, f func() (interface{}, error)) (v interface{}, err error)
- func RunOptionalSSLRedirector(port int, rf OptionalRedirectorFunc) error
- func RunSSLRedirector(port int, rf RedirectorFunc) error
- func RunWeb(handler http.Handler, port int, ssl SSLConfig, auth Authenticator) error
- func SleepRand(t time.Duration)
- func Timeout(f func() error, t time.Duration) (timedout bool, err error)
- type Authenticator
- type Authorizer
- type BufferReader
- type BufferReaderFact
- type DurationList
- type FileReaderFact
- type Filter
- type HttpAuth
- type HttpAuthMux
- func (a *HttpAuthMux) Add(user, password string)
- func (a *HttpAuthMux) Authorized(r *http.Request) bool
- func (s *HttpAuthMux) Handle(pattern string, handler http.Handler)
- func (s *HttpAuthMux) HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
- func (s *HttpAuthMux) ServeHTTP(w http.ResponseWriter, r *http.Request)
- type Json
- func (j *Json) AsArray() ([]interface{}, error)
- func (j *Json) AsBool() (bool, error)
- func (j *Json) AsFloat64() (float64, error)
- func (j *Json) AsInt() (int, error)
- func (j *Json) AsMap() (map[string]interface{}, error)
- func (j *Json) AsString() (string, error)
- func (j *Json) Float64Array() ([]float64, error)
- func (j *Json) Get(key string) *Json
- func (j *Json) GetIndex(index int) *Json
- func (j *Json) GetPath(branch ...string) *Json
- func (j *Json) MarshalJSON() ([]byte, error)
- func (j *Json) Set(key string, val interface{})
- func (j *Json) String() string
- func (j *Json) StringArray() ([]string, error)
- func (j *Json) UnmarshalJSON(b []byte) error
- func (j *Json) Unwrap() interface{}
- type KeyValueF
- type KeyValueI
- type KeyValueII
- type KeyValueListF
- type KeyValueListI
- type KeyValueListII
- type LowPass
- type NoRetryStrategy
- type NoRetryStrategyInstance
- type OptionalRedirector
- type OptionalRedirectorFunc
- type RateEstimator
- type ReadCloser
- type ReaderFactory
- type Redirector
- type RedirectorFunc
- type Replicator
- type RetryBackoffStrat
- type RetryBackoffStratInstance
- type RetryStrategy
- type RetryStrategyInstance
- type SSLConfig
- type TestJson
- type Tester
- type TimeList
- type Token
- type Tool
- type WorkQueue
- type WorkSubmitter
Constants ¶
View Source
const IsoFormat = "2006-01-02T15:04:05.000Z"
View Source
const SCRIPT = `` /* 913-byte string literal not displayed */
View Source
const (
Version = "1.0"
)
Variables ¶
This section is empty.
Functions ¶
func FormatApproxDuration ¶
only leading terms
func FormatDuration ¶
format duration using integers only
func InTimeRange ¶
func ListenAndServeTLS ¶
adapted from go's net/http package, modified to work with bytes in memory instead of files on disk
func MarshalIndent ¶
func MarshalIndent(i interface{}) string
func ParseIsoUtc ¶
parses a time as iso 8601 with IsoFormat
func Retry ¶
func Retry(msg string, bs RetryStrategyInstance, f func() (interface{}, error)) (v interface{}, err error)
retries something, generically
func RunOptionalSSLRedirector ¶
func RunOptionalSSLRedirector(port int, rf OptionalRedirectorFunc) error
func RunSSLRedirector ¶
func RunSSLRedirector(port int, rf RedirectorFunc) error
redirects http to https; rf can be nil
Types ¶
type Authenticator ¶
type Authenticator func(w http.ResponseWriter, r *http.Request) bool
returns whether request is authenticated or not, and if not, optionally uses w to aid authentication
type Authorizer ¶
type BufferReader ¶
func (BufferReader) Close ¶
func (b BufferReader) Close() error
type BufferReaderFact ¶
type BufferReaderFact struct {
Buffer []byte
}
func (BufferReaderFact) CreateReader ¶
func (b BufferReaderFact) CreateReader() (io.ReadCloser, error)
func (BufferReaderFact) Len ¶
func (b BufferReaderFact) Len() int
type DurationList ¶
func (DurationList) Len ¶
func (r DurationList) Len() int
func (DurationList) Less ¶
func (r DurationList) Less(i, j int) bool
func (DurationList) Swap ¶
func (r DurationList) Swap(i, j int)
type FileReaderFact ¶
func NewFileReaderFact ¶
func NewFileReaderFact(path string) (*FileReaderFact, error)
func (FileReaderFact) CreateReader ¶
func (rf FileReaderFact) CreateReader() (io.ReadCloser, error)
func (FileReaderFact) Len ¶
func (rf FileReaderFact) Len() int
type Filter ¶
func NewLowPass ¶
type HttpAuth ¶
type HttpAuth struct {
// contains filtered or unexported fields
}
func NewHttpAuth ¶
func NewHttpAuth(realm string, handler http.Handler, auths ...Authorizer) *HttpAuth
type HttpAuthMux ¶
type HttpAuthMux struct {
// contains filtered or unexported fields
}
func NewHttpAuthMux ¶
func NewHttpAuthMux(realm string) *HttpAuthMux
func (*HttpAuthMux) Add ¶
func (a *HttpAuthMux) Add(user, password string)
func (*HttpAuthMux) Authorized ¶
func (a *HttpAuthMux) Authorized(r *http.Request) bool
func (*HttpAuthMux) HandleFunc ¶
func (s *HttpAuthMux) HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
func (*HttpAuthMux) ServeHTTP ¶
func (s *HttpAuthMux) ServeHTTP(w http.ResponseWriter, r *http.Request)
type Json ¶
type Json struct {
// contains filtered or unexported fields
}
func (*Json) Float64Array ¶
func (*Json) MarshalJSON ¶
func (*Json) StringArray ¶
func (*Json) UnmarshalJSON ¶
type KeyValueII ¶
type KeyValueListF ¶
type KeyValueListF []KeyValueF
func (KeyValueListF) Len ¶
func (k KeyValueListF) Len() int
func (KeyValueListF) Less ¶
func (k KeyValueListF) Less(i, j int) bool
func (KeyValueListF) Swap ¶
func (k KeyValueListF) Swap(i, j int)
type KeyValueListI ¶
type KeyValueListI []KeyValueI
func (KeyValueListI) Len ¶
func (k KeyValueListI) Len() int
func (KeyValueListI) Less ¶
func (k KeyValueListI) Less(i, j int) bool
func (KeyValueListI) Swap ¶
func (k KeyValueListI) Swap(i, j int)
type KeyValueListII ¶
type KeyValueListII []KeyValueII
func (KeyValueListII) Len ¶
func (k KeyValueListII) Len() int
func (KeyValueListII) Less ¶
func (k KeyValueListII) Less(i, j int) bool
func (KeyValueListII) Swap ¶
func (k KeyValueListII) Swap(i, j int)
type NoRetryStrategy ¶
type NoRetryStrategy struct { }
func (NoRetryStrategy) NewInstance ¶
func (NoRetryStrategy) NewInstance() RetryStrategyInstance
type NoRetryStrategyInstance ¶
type NoRetryStrategyInstance struct { }
func (NoRetryStrategyInstance) Retry ¶
func (NoRetryStrategyInstance) Retry() bool
type OptionalRedirector ¶
type OptionalRedirector struct {
Transformer OptionalRedirectorFunc
}
func (OptionalRedirector) ServeHTTP ¶
func (f OptionalRedirector) ServeHTTP(w http.ResponseWriter, r *http.Request)
type OptionalRedirectorFunc ¶
type RateEstimator ¶
type RateEstimator struct {
// contains filtered or unexported fields
}
func NewRateEstimator ¶
func NewRateEstimator(tc time.Duration) *RateEstimator
func (*RateEstimator) Count ¶
func (re *RateEstimator) Count() int
func (*RateEstimator) Rate ¶
func (re *RateEstimator) Rate() float64
type ReadCloser ¶
func (ReadCloser) Close ¶
func (r ReadCloser) Close() error
type ReaderFactory ¶
type ReaderFactory interface { CreateReader() (io.ReadCloser, error) Len() int }
func NewSingleReaderFact ¶
func NewSingleReaderFact(r io.Reader, length int) ReaderFactory
type Redirector ¶
type Redirector struct {
Transformer RedirectorFunc
}
func (Redirector) ServeHTTP ¶
func (f Redirector) ServeHTTP(w http.ResponseWriter, r *http.Request)
type RedirectorFunc ¶
if returned string is length zero, don't use
type Replicator ¶
type Replicator struct { }
func (Replicator) Name ¶
func (Replicator) Name() string
func (Replicator) Run ¶
func (r Replicator) Run(args []string)
type RetryBackoffStrat ¶
func (RetryBackoffStrat) NewInstance ¶
func (r RetryBackoffStrat) NewInstance() RetryStrategyInstance
type RetryBackoffStratInstance ¶
type RetryBackoffStratInstance struct {
// contains filtered or unexported fields
}
func (*RetryBackoffStratInstance) Retry ¶
func (r *RetryBackoffStratInstance) Retry() bool
type RetryStrategy ¶
type RetryStrategy interface {
NewInstance() RetryStrategyInstance
}
e.g., can combine retry logic and backoff in time together, or any other strategy
type RetryStrategyInstance ¶
type RetryStrategyInstance interface { // returns whether or not to retry, backing off in time if it likes Retry() bool }
type SSLConfig ¶
type SSLConfig func() (cert interface{}, key interface{})
returns either cert/key files or bytes, or nulls if ssl not needed
type Token ¶
type WorkQueue ¶
type WorkQueue interface { WorkSubmitter // close queue and wait for all functions to execute Wait() }
func NewWorkQueue ¶
type WorkSubmitter ¶
type WorkSubmitter interface {
// submit a function to queue
Submit(f func())
}
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
aws utilities.
|
aws utilities. |
ddb
code for accessing dynamo db.
|
code for accessing dynamo db. |
s3
code for accessing s3.
|
code for accessing s3. |
code for elastic mapreduce (streaming).
|
code for elastic mapreduce (streaming). |
runs a tool forever
|
runs a tool forever |
work with git
|
work with git |
math code.
|
math code. |
blas
interface to Basic Linear Algebra Subprograms (blas).
|
interface to Basic Linear Algebra Subprograms (blas). |
la
linear algebra routines.
|
linear algebra routines. |
lapack
interface to Linear Algebra PACKage (lapack).
|
interface to Linear Algebra PACKage (lapack). |
model
modelling routines.
|
modelling routines. |
model/cancer
use modelling code on well-known prostate cancer data, check we get same results.
|
use modelling code on well-known prostate cancer data, check we get same results. |
model/logistic
logistic modelling example.
|
logistic modelling example. |
stats
various statistical routines.
|
various statistical routines. |
logging for the purposes of analysis later on.
|
logging for the purposes of analysis later on. |
parallel boosting
|
parallel boosting |
rate-limited reader.
|
rate-limited reader. |
idempotently prepends bin directory to current PATH and prints; e.g., export PATH=`go run src/github.com/xoba/goutil/setpath/setpath.go`
|
idempotently prepends bin directory to current PATH and prints; e.g., export PATH=`go run src/github.com/xoba/goutil/setpath/setpath.go` |
simple smtp client.
|
simple smtp client. |
manages main executable as agglomeration of tools.
|
manages main executable as agglomeration of tools. |
Click to show internal directories.
Click to hide internal directories.