Documentation ¶
Overview ¶
copied from github.com/elastic/beats
Index ¶
- Constants
- Variables
- func AddTags(ms MapStr, tags []string) error
- func AutoGetAddress(addr string) string
- func ByteSize(bytes uint64) string
- func BytesToUint32(b []byte) (v uint32)
- func BytesToUint64(b []byte) (v uint64)
- func CheckInstanceLock(p string)
- func ClearInstanceLock()
- func ContainStr(s, substr string) bool
- func CopyFile(src, dst string) (w int64, err error)
- func CreateFile(dir string, name string) (string, error)
- func DeepCopy(value interface{}) interface{}
- func FileAppendContentWithByte(file string, content []byte) (int, error)
- func FileAppendNewLine(file string, content string) (int, error)
- func FileAppendNewLineWithByte(file string, content []byte) (int, error)
- func FileExists(path string) bool
- func FileGetContent(file string) ([]byte, error)
- func FileMTime(file string) (int64, error)
- func FilePutContent(file string, content string) (int, error)
- func FilePutContentWithByte(file string, content []byte) (int, error)
- func FileSize(file string) (int64, error)
- func FilterDirName(name string) bool
- func FormatTime(date *time.Time) string
- func FormatUrlForFilter(url []byte) []byte
- func GetAvailablePort(ip string, port int) int
- func GetHost(url string) string
- func GetIncrementID(bucket string) string
- func GetRootUrl(source *URL) string
- func GetRuntimeErrorMessage(r runtime.Error) string
- func GetUUID() string
- func GetUrlPathFolderWithoutFile(url []byte) []byte
- func GetValidAddress(addr string) string
- func HttpGet(resource string) (msg []byte, err error)
- func HttpPostJSON(url string, cookie string, postStr string) []byte
- func Invoke(any interface{}, name string, args ...interface{})
- func IsExist(path string) bool
- func IsFile(file string) bool
- func IsValidTLD(tld string) bool
- func JoinPath(filenames ...string) string
- func MergeFields(ms, fields MapStr, underRoot bool) error
- func MergeSpace(in string) (out string)
- func NoWordBreak(in string) string
- func Post(url string, values url.Values) []byte
- func RandomPickName() string
- func ReadAllLines(file string) []string
- func Readln(r *bufio.Reader) (string, error)
- func Rename(file string, to string) error
- func StringToUTF16(s string) []uint16
- func SubString(str string, begin, length int) (substr string)
- func SubStringWithSuffix(str string, length int, suffix string) string
- func TestListenPort(ip string, port int) bool
- func TestPort(port int) bool
- func ToBytes(s string) (uint64, error)
- func ToInt(str string) (int, error)
- func ToJson(in interface{}, indent bool) string
- func ToMegabytes(s string) (uint64, error)
- func Uint32toBytes(b []byte, v uint32)
- func Uint64toBytes(b []byte, v uint64)
- func UnicodeIndex(str, substr string) int
- func Unlink(file string) error
- func XSSHandle(src string) string
- type EventMetadata
- type FileRepos
- type MapStr
- func (m MapStr) Clone() MapStr
- func (m MapStr) CopyFieldsTo(to MapStr, key string) error
- func (m MapStr) Delete(key string) error
- func (m MapStr) GetValue(key string) (interface{}, error)
- func (m MapStr) HasKey(key string) (bool, error)
- func (m MapStr) Put(key string, value interface{}) (interface{}, error)
- func (m MapStr) String() string
- func (m MapStr) StringToPrint() string
- func (m MapStr) Update(d MapStr)
- type Repository
- type Result
- type StringSet
Constants ¶
const ( BYTE = 1.0 KILOBYTE = 1024 * BYTE MEGABYTE = 1024 * KILOBYTE GIGABYTE = 1024 * MEGABYTE TERABYTE = 1024 * GIGABYTE )
const ( EventMetadataKey = "_event_metadata" FieldsKey = "fields" TagsKey = "tags" )
Event metadata constants. These keys are used within libbeat to identify metadata stored in an event.
Variables ¶
var ( // ErrKeyNotFound indicates that the specified key was not found. ErrKeyNotFound = errors.New("key not found") )
Functions ¶
func AddTags ¶
AddTags appends a tag to the tags field of ms. If the tags field does not exist then it will be created. If the tags field exists and is not a []string then an error will be returned. It does not deduplicate the list of tags.
func AutoGetAddress ¶
* get valid address to listen, if the specify port is not available, auto choose the next one
func ByteSize ¶
ByteSize returns a human-readable byte string of the form 10M, 12.5K, and so forth. The following units are available:
T: Terabyte G: Gigabyte M: Megabyte K: Kilobyte B: Byte
The unit that results in the smallest number greater than or equal to 1 is always chosen.
func BytesToUint32 ¶
func BytesToUint64 ¶
func CheckInstanceLock ¶
func CheckInstanceLock(p string)
func ClearInstanceLock ¶
func ClearInstanceLock()
func ContainStr ¶
func FileExists ¶
func FilePutContent ¶
put string to file
func FilePutContentWithByte ¶
put string to file
func FilterDirName ¶
FilterDirName guess the file or directory is or contains Go source files.
func FormatTime ¶
func GetAvailablePort ¶
* get valid port to listen, if the specify port is not available, auto choose the next one
func GetIncrementID ¶
func GetRuntimeErrorMessage ¶
func GetValidAddress ¶
* get valid address, input: :8001 -> output: 127.0.0.1:8001
func MergeFields ¶
MergeFields merges the top-level keys and values in each source map (it does not perform a deep merge). If the same key exists in both, the value in fields takes precedence. If underRoot is true then the contents of the fields MapStr is merged with the value of the 'fields' key in ms.
An error is returned if underRoot is true and the value of ms.fields is not a MapStr.
func NoWordBreak ¶
func RandomPickName ¶
func RandomPickName() string
func ReadAllLines ¶
func StringToUTF16 ¶
func TestListenPort ¶
func ToMegabytes ¶
ToMegabytes parses a string formatted by ByteSize as megabytes.
func Uint32toBytes ¶
func Uint64toBytes ¶
func UnicodeIndex ¶
Types ¶
type EventMetadata ¶
type EventMetadata struct { Fields MapStr FieldsUnderRoot bool `config:"fields_under_root"` Tags []string }
EventMetadata contains fields and tags that can be added to an event via configuration.
type FileRepos ¶
type FileRepos []Repository
type MapStr ¶
type MapStr map[string]interface{}
MapStr is a map[string]interface{} wrapper with utility methods for common map operations like converting to JSON.
func MapStrUnion ¶
MapStrUnion creates a new MapStr containing the union of the key-value pairs of the two maps. If the same key is present in both, the key-value pairs from dict2 overwrite the ones from dict1.
func (MapStr) Clone ¶
Clone returns a copy of the MapStr. It recursively makes copies of inner maps.
func (MapStr) CopyFieldsTo ¶
CopyFieldsTo copies the field specified by key to the given map. It will overwrite the key if it exists. An error is returned if the key does not exist in the source map.
func (MapStr) GetValue ¶
GetValue gets a value from the map. If the key does not exist then an error is returned.
func (MapStr) HasKey ¶
HasKey returns true if the key exist. If an error occurs then false is returned with a non-nil error.
func (MapStr) Put ¶
Put associates the specified value with the specified key. If the map previously contained a mapping for the key, the old value is replaced and returned. The key can be expressed in dot-notation (e.g. x.y) to put a value into a nested map.
If you need insert keys containing dots then you must use bracket notation to insert values (e.g. m[key] = value).
func (MapStr) StringToPrint ¶
StringToPrint returns the MapStr as pretty JSON.