diff --git a/vendor/github.com/StackExchange/wmi/LICENSE b/vendor/github.com/StackExchange/wmi/LICENSE
deleted file mode 100644
index ae80b67..0000000
--- a/vendor/github.com/StackExchange/wmi/LICENSE
+++ /dev/null
@@ -1,20 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) 2013 Stack Exchange
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
-the Software, and to permit persons to whom the Software is furnished to do so,
-subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
-FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
-COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/github.com/StackExchange/wmi/README.md b/vendor/github.com/StackExchange/wmi/README.md
deleted file mode 100644
index 426d1a4..0000000
--- a/vendor/github.com/StackExchange/wmi/README.md
+++ /dev/null
@@ -1,6 +0,0 @@
-wmi
-===
-
-Package wmi provides a WQL interface to Windows WMI.
-
-Note: It interfaces with WMI on the local machine, therefore it only runs on Windows.
diff --git a/vendor/github.com/StackExchange/wmi/swbemservices.go b/vendor/github.com/StackExchange/wmi/swbemservices.go
deleted file mode 100644
index 9765a53..0000000
--- a/vendor/github.com/StackExchange/wmi/swbemservices.go
+++ /dev/null
@@ -1,260 +0,0 @@
-// +build windows
-
-package wmi
-
-import (
- "fmt"
- "reflect"
- "runtime"
- "sync"
-
- "github.com/go-ole/go-ole"
- "github.com/go-ole/go-ole/oleutil"
-)
-
-// SWbemServices is used to access wmi. See https://msdn.microsoft.com/en-us/library/aa393719(v=vs.85).aspx
-type SWbemServices struct {
- //TODO: track namespace. Not sure if we can re connect to a different namespace using the same instance
- cWMIClient *Client //This could also be an embedded struct, but then we would need to branch on Client vs SWbemServices in the Query method
- sWbemLocatorIUnknown *ole.IUnknown
- sWbemLocatorIDispatch *ole.IDispatch
- queries chan *queryRequest
- closeError chan error
- lQueryorClose sync.Mutex
-}
-
-type queryRequest struct {
- query string
- dst interface{}
- args []interface{}
- finished chan error
-}
-
-// InitializeSWbemServices will return a new SWbemServices object that can be used to query WMI
-func InitializeSWbemServices(c *Client, connectServerArgs ...interface{}) (*SWbemServices, error) {
- //fmt.Println("InitializeSWbemServices: Starting")
- //TODO: implement connectServerArgs as optional argument for init with connectServer call
- s := new(SWbemServices)
- s.cWMIClient = c
- s.queries = make(chan *queryRequest)
- initError := make(chan error)
- go s.process(initError)
-
- err, ok := <-initError
- if ok {
- return nil, err //Send error to caller
- }
- //fmt.Println("InitializeSWbemServices: Finished")
- return s, nil
-}
-
-// Close will clear and release all of the SWbemServices resources
-func (s *SWbemServices) Close() error {
- s.lQueryorClose.Lock()
- if s == nil || s.sWbemLocatorIDispatch == nil {
- s.lQueryorClose.Unlock()
- return fmt.Errorf("SWbemServices is not Initialized")
- }
- if s.queries == nil {
- s.lQueryorClose.Unlock()
- return fmt.Errorf("SWbemServices has been closed")
- }
- //fmt.Println("Close: sending close request")
- var result error
- ce := make(chan error)
- s.closeError = ce //Race condition if multiple callers to close. May need to lock here
- close(s.queries) //Tell background to shut things down
- s.lQueryorClose.Unlock()
- err, ok := <-ce
- if ok {
- result = err
- }
- //fmt.Println("Close: finished")
- return result
-}
-
-func (s *SWbemServices) process(initError chan error) {
- //fmt.Println("process: starting background thread initialization")
- //All OLE/WMI calls must happen on the same initialized thead, so lock this goroutine
- runtime.LockOSThread()
- defer runtime.LockOSThread()
-
- err := ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
- if err != nil {
- oleCode := err.(*ole.OleError).Code()
- if oleCode != ole.S_OK && oleCode != S_FALSE {
- initError <- fmt.Errorf("ole.CoInitializeEx error: %v", err)
- return
- }
- }
- defer ole.CoUninitialize()
-
- unknown, err := oleutil.CreateObject("WbemScripting.SWbemLocator")
- if err != nil {
- initError <- fmt.Errorf("CreateObject SWbemLocator error: %v", err)
- return
- } else if unknown == nil {
- initError <- ErrNilCreateObject
- return
- }
- defer unknown.Release()
- s.sWbemLocatorIUnknown = unknown
-
- dispatch, err := s.sWbemLocatorIUnknown.QueryInterface(ole.IID_IDispatch)
- if err != nil {
- initError <- fmt.Errorf("SWbemLocator QueryInterface error: %v", err)
- return
- }
- defer dispatch.Release()
- s.sWbemLocatorIDispatch = dispatch
-
- // we can't do the ConnectServer call outside the loop unless we find a way to track and re-init the connectServerArgs
- //fmt.Println("process: initialized. closing initError")
- close(initError)
- //fmt.Println("process: waiting for queries")
- for q := range s.queries {
- //fmt.Printf("process: new query: len(query)=%d\n", len(q.query))
- errQuery := s.queryBackground(q)
- //fmt.Println("process: s.queryBackground finished")
- if errQuery != nil {
- q.finished <- errQuery
- }
- close(q.finished)
- }
- //fmt.Println("process: queries channel closed")
- s.queries = nil //set channel to nil so we know it is closed
- //TODO: I think the Release/Clear calls can panic if things are in a bad state.
- //TODO: May need to recover from panics and send error to method caller instead.
- close(s.closeError)
-}
-
-// Query runs the WQL query using a SWbemServices instance and appends the values to dst.
-//
-// dst must have type *[]S or *[]*S, for some struct type S. Fields selected in
-// the query must have the same name in dst. Supported types are all signed and
-// unsigned integers, time.Time, string, bool, or a pointer to one of those.
-// Array types are not supported.
-//
-// By default, the local machine and default namespace are used. These can be
-// changed using connectServerArgs. See
-// http://msdn.microsoft.com/en-us/library/aa393720.aspx for details.
-func (s *SWbemServices) Query(query string, dst interface{}, connectServerArgs ...interface{}) error {
- s.lQueryorClose.Lock()
- if s == nil || s.sWbemLocatorIDispatch == nil {
- s.lQueryorClose.Unlock()
- return fmt.Errorf("SWbemServices is not Initialized")
- }
- if s.queries == nil {
- s.lQueryorClose.Unlock()
- return fmt.Errorf("SWbemServices has been closed")
- }
-
- //fmt.Println("Query: Sending query request")
- qr := queryRequest{
- query: query,
- dst: dst,
- args: connectServerArgs,
- finished: make(chan error),
- }
- s.queries <- &qr
- s.lQueryorClose.Unlock()
- err, ok := <-qr.finished
- if ok {
- //fmt.Println("Query: Finished with error")
- return err //Send error to caller
- }
- //fmt.Println("Query: Finished")
- return nil
-}
-
-func (s *SWbemServices) queryBackground(q *queryRequest) error {
- if s == nil || s.sWbemLocatorIDispatch == nil {
- return fmt.Errorf("SWbemServices is not Initialized")
- }
- wmi := s.sWbemLocatorIDispatch //Should just rename in the code, but this will help as we break things apart
- //fmt.Println("queryBackground: Starting")
-
- dv := reflect.ValueOf(q.dst)
- if dv.Kind() != reflect.Ptr || dv.IsNil() {
- return ErrInvalidEntityType
- }
- dv = dv.Elem()
- mat, elemType := checkMultiArg(dv)
- if mat == multiArgTypeInvalid {
- return ErrInvalidEntityType
- }
-
- // service is a SWbemServices
- serviceRaw, err := oleutil.CallMethod(wmi, "ConnectServer", q.args...)
- if err != nil {
- return err
- }
- service := serviceRaw.ToIDispatch()
- defer serviceRaw.Clear()
-
- // result is a SWBemObjectSet
- resultRaw, err := oleutil.CallMethod(service, "ExecQuery", q.query)
- if err != nil {
- return err
- }
- result := resultRaw.ToIDispatch()
- defer resultRaw.Clear()
-
- count, err := oleInt64(result, "Count")
- if err != nil {
- return err
- }
-
- enumProperty, err := result.GetProperty("_NewEnum")
- if err != nil {
- return err
- }
- defer enumProperty.Clear()
-
- enum, err := enumProperty.ToIUnknown().IEnumVARIANT(ole.IID_IEnumVariant)
- if err != nil {
- return err
- }
- if enum == nil {
- return fmt.Errorf("can't get IEnumVARIANT, enum is nil")
- }
- defer enum.Release()
-
- // Initialize a slice with Count capacity
- dv.Set(reflect.MakeSlice(dv.Type(), 0, int(count)))
-
- var errFieldMismatch error
- for itemRaw, length, err := enum.Next(1); length > 0; itemRaw, length, err = enum.Next(1) {
- if err != nil {
- return err
- }
-
- err := func() error {
- // item is a SWbemObject, but really a Win32_Process
- item := itemRaw.ToIDispatch()
- defer item.Release()
-
- ev := reflect.New(elemType)
- if err = s.cWMIClient.loadEntity(ev.Interface(), item); err != nil {
- if _, ok := err.(*ErrFieldMismatch); ok {
- // We continue loading entities even in the face of field mismatch errors.
- // If we encounter any other error, that other error is returned. Otherwise,
- // an ErrFieldMismatch is returned.
- errFieldMismatch = err
- } else {
- return err
- }
- }
- if mat != multiArgTypeStructPtr {
- ev = ev.Elem()
- }
- dv.Set(reflect.Append(dv, ev))
- return nil
- }()
- if err != nil {
- return err
- }
- }
- //fmt.Println("queryBackground: Finished")
- return errFieldMismatch
-}
diff --git a/vendor/github.com/StackExchange/wmi/wmi.go b/vendor/github.com/StackExchange/wmi/wmi.go
deleted file mode 100644
index a951b12..0000000
--- a/vendor/github.com/StackExchange/wmi/wmi.go
+++ /dev/null
@@ -1,486 +0,0 @@
-// +build windows
-
-/*
-Package wmi provides a WQL interface for WMI on Windows.
-
-Example code to print names of running processes:
-
- type Win32_Process struct {
- Name string
- }
-
- func main() {
- var dst []Win32_Process
- q := wmi.CreateQuery(&dst, "")
- err := wmi.Query(q, &dst)
- if err != nil {
- log.Fatal(err)
- }
- for i, v := range dst {
- println(i, v.Name)
- }
- }
-
-*/
-package wmi
-
-import (
- "bytes"
- "errors"
- "fmt"
- "log"
- "os"
- "reflect"
- "runtime"
- "strconv"
- "strings"
- "sync"
- "time"
-
- "github.com/go-ole/go-ole"
- "github.com/go-ole/go-ole/oleutil"
-)
-
-var l = log.New(os.Stdout, "", log.LstdFlags)
-
-var (
- ErrInvalidEntityType = errors.New("wmi: invalid entity type")
- // ErrNilCreateObject is the error returned if CreateObject returns nil even
- // if the error was nil.
- ErrNilCreateObject = errors.New("wmi: create object returned nil")
- lock sync.Mutex
-)
-
-// S_FALSE is returned by CoInitializeEx if it was already called on this thread.
-const S_FALSE = 0x00000001
-
-// QueryNamespace invokes Query with the given namespace on the local machine.
-func QueryNamespace(query string, dst interface{}, namespace string) error {
- return Query(query, dst, nil, namespace)
-}
-
-// Query runs the WQL query and appends the values to dst.
-//
-// dst must have type *[]S or *[]*S, for some struct type S. Fields selected in
-// the query must have the same name in dst. Supported types are all signed and
-// unsigned integers, time.Time, string, bool, or a pointer to one of those.
-// Array types are not supported.
-//
-// By default, the local machine and default namespace are used. These can be
-// changed using connectServerArgs. See
-// http://msdn.microsoft.com/en-us/library/aa393720.aspx for details.
-//
-// Query is a wrapper around DefaultClient.Query.
-func Query(query string, dst interface{}, connectServerArgs ...interface{}) error {
- if DefaultClient.SWbemServicesClient == nil {
- return DefaultClient.Query(query, dst, connectServerArgs...)
- }
- return DefaultClient.SWbemServicesClient.Query(query, dst, connectServerArgs...)
-}
-
-// A Client is an WMI query client.
-//
-// Its zero value (DefaultClient) is a usable client.
-type Client struct {
- // NonePtrZero specifies if nil values for fields which aren't pointers
- // should be returned as the field types zero value.
- //
- // Setting this to true allows stucts without pointer fields to be used
- // without the risk failure should a nil value returned from WMI.
- NonePtrZero bool
-
- // PtrNil specifies if nil values for pointer fields should be returned
- // as nil.
- //
- // Setting this to true will set pointer fields to nil where WMI
- // returned nil, otherwise the types zero value will be returned.
- PtrNil bool
-
- // AllowMissingFields specifies that struct fields not present in the
- // query result should not result in an error.
- //
- // Setting this to true allows custom queries to be used with full
- // struct definitions instead of having to define multiple structs.
- AllowMissingFields bool
-
- // SWbemServiceClient is an optional SWbemServices object that can be
- // initialized and then reused across multiple queries. If it is null
- // then the method will initialize a new temporary client each time.
- SWbemServicesClient *SWbemServices
-}
-
-// DefaultClient is the default Client and is used by Query, QueryNamespace
-var DefaultClient = &Client{}
-
-// Query runs the WQL query and appends the values to dst.
-//
-// dst must have type *[]S or *[]*S, for some struct type S. Fields selected in
-// the query must have the same name in dst. Supported types are all signed and
-// unsigned integers, time.Time, string, bool, or a pointer to one of those.
-// Array types are not supported.
-//
-// By default, the local machine and default namespace are used. These can be
-// changed using connectServerArgs. See
-// http://msdn.microsoft.com/en-us/library/aa393720.aspx for details.
-func (c *Client) Query(query string, dst interface{}, connectServerArgs ...interface{}) error {
- dv := reflect.ValueOf(dst)
- if dv.Kind() != reflect.Ptr || dv.IsNil() {
- return ErrInvalidEntityType
- }
- dv = dv.Elem()
- mat, elemType := checkMultiArg(dv)
- if mat == multiArgTypeInvalid {
- return ErrInvalidEntityType
- }
-
- lock.Lock()
- defer lock.Unlock()
- runtime.LockOSThread()
- defer runtime.UnlockOSThread()
-
- err := ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
- if err != nil {
- oleCode := err.(*ole.OleError).Code()
- if oleCode != ole.S_OK && oleCode != S_FALSE {
- return err
- }
- }
- defer ole.CoUninitialize()
-
- unknown, err := oleutil.CreateObject("WbemScripting.SWbemLocator")
- if err != nil {
- return err
- } else if unknown == nil {
- return ErrNilCreateObject
- }
- defer unknown.Release()
-
- wmi, err := unknown.QueryInterface(ole.IID_IDispatch)
- if err != nil {
- return err
- }
- defer wmi.Release()
-
- // service is a SWbemServices
- serviceRaw, err := oleutil.CallMethod(wmi, "ConnectServer", connectServerArgs...)
- if err != nil {
- return err
- }
- service := serviceRaw.ToIDispatch()
- defer serviceRaw.Clear()
-
- // result is a SWBemObjectSet
- resultRaw, err := oleutil.CallMethod(service, "ExecQuery", query)
- if err != nil {
- return err
- }
- result := resultRaw.ToIDispatch()
- defer resultRaw.Clear()
-
- count, err := oleInt64(result, "Count")
- if err != nil {
- return err
- }
-
- enumProperty, err := result.GetProperty("_NewEnum")
- if err != nil {
- return err
- }
- defer enumProperty.Clear()
-
- enum, err := enumProperty.ToIUnknown().IEnumVARIANT(ole.IID_IEnumVariant)
- if err != nil {
- return err
- }
- if enum == nil {
- return fmt.Errorf("can't get IEnumVARIANT, enum is nil")
- }
- defer enum.Release()
-
- // Initialize a slice with Count capacity
- dv.Set(reflect.MakeSlice(dv.Type(), 0, int(count)))
-
- var errFieldMismatch error
- for itemRaw, length, err := enum.Next(1); length > 0; itemRaw, length, err = enum.Next(1) {
- if err != nil {
- return err
- }
-
- err := func() error {
- // item is a SWbemObject, but really a Win32_Process
- item := itemRaw.ToIDispatch()
- defer item.Release()
-
- ev := reflect.New(elemType)
- if err = c.loadEntity(ev.Interface(), item); err != nil {
- if _, ok := err.(*ErrFieldMismatch); ok {
- // We continue loading entities even in the face of field mismatch errors.
- // If we encounter any other error, that other error is returned. Otherwise,
- // an ErrFieldMismatch is returned.
- errFieldMismatch = err
- } else {
- return err
- }
- }
- if mat != multiArgTypeStructPtr {
- ev = ev.Elem()
- }
- dv.Set(reflect.Append(dv, ev))
- return nil
- }()
- if err != nil {
- return err
- }
- }
- return errFieldMismatch
-}
-
-// ErrFieldMismatch is returned when a field is to be loaded into a different
-// type than the one it was stored from, or when a field is missing or
-// unexported in the destination struct.
-// StructType is the type of the struct pointed to by the destination argument.
-type ErrFieldMismatch struct {
- StructType reflect.Type
- FieldName string
- Reason string
-}
-
-func (e *ErrFieldMismatch) Error() string {
- return fmt.Sprintf("wmi: cannot load field %q into a %q: %s",
- e.FieldName, e.StructType, e.Reason)
-}
-
-var timeType = reflect.TypeOf(time.Time{})
-
-// loadEntity loads a SWbemObject into a struct pointer.
-func (c *Client) loadEntity(dst interface{}, src *ole.IDispatch) (errFieldMismatch error) {
- v := reflect.ValueOf(dst).Elem()
- for i := 0; i < v.NumField(); i++ {
- f := v.Field(i)
- of := f
- isPtr := f.Kind() == reflect.Ptr
- if isPtr {
- ptr := reflect.New(f.Type().Elem())
- f.Set(ptr)
- f = f.Elem()
- }
- n := v.Type().Field(i).Name
- if !f.CanSet() {
- return &ErrFieldMismatch{
- StructType: of.Type(),
- FieldName: n,
- Reason: "CanSet() is false",
- }
- }
- prop, err := oleutil.GetProperty(src, n)
- if err != nil {
- if !c.AllowMissingFields {
- errFieldMismatch = &ErrFieldMismatch{
- StructType: of.Type(),
- FieldName: n,
- Reason: "no such struct field",
- }
- }
- continue
- }
- defer prop.Clear()
-
- switch val := prop.Value().(type) {
- case int8, int16, int32, int64, int:
- v := reflect.ValueOf(val).Int()
- switch f.Kind() {
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- f.SetInt(v)
- case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
- f.SetUint(uint64(v))
- default:
- return &ErrFieldMismatch{
- StructType: of.Type(),
- FieldName: n,
- Reason: "not an integer class",
- }
- }
- case uint8, uint16, uint32, uint64:
- v := reflect.ValueOf(val).Uint()
- switch f.Kind() {
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- f.SetInt(int64(v))
- case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
- f.SetUint(v)
- default:
- return &ErrFieldMismatch{
- StructType: of.Type(),
- FieldName: n,
- Reason: "not an integer class",
- }
- }
- case string:
- switch f.Kind() {
- case reflect.String:
- f.SetString(val)
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- iv, err := strconv.ParseInt(val, 10, 64)
- if err != nil {
- return err
- }
- f.SetInt(iv)
- case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
- uv, err := strconv.ParseUint(val, 10, 64)
- if err != nil {
- return err
- }
- f.SetUint(uv)
- case reflect.Struct:
- switch f.Type() {
- case timeType:
- if len(val) == 25 {
- mins, err := strconv.Atoi(val[22:])
- if err != nil {
- return err
- }
- val = val[:22] + fmt.Sprintf("%02d%02d", mins/60, mins%60)
- }
- t, err := time.Parse("20060102150405.000000-0700", val)
- if err != nil {
- return err
- }
- f.Set(reflect.ValueOf(t))
- }
- }
- case bool:
- switch f.Kind() {
- case reflect.Bool:
- f.SetBool(val)
- default:
- return &ErrFieldMismatch{
- StructType: of.Type(),
- FieldName: n,
- Reason: "not a bool",
- }
- }
- case float32:
- switch f.Kind() {
- case reflect.Float32:
- f.SetFloat(float64(val))
- default:
- return &ErrFieldMismatch{
- StructType: of.Type(),
- FieldName: n,
- Reason: "not a Float32",
- }
- }
- default:
- if f.Kind() == reflect.Slice {
- switch f.Type().Elem().Kind() {
- case reflect.String:
- safeArray := prop.ToArray()
- if safeArray != nil {
- arr := safeArray.ToValueArray()
- fArr := reflect.MakeSlice(f.Type(), len(arr), len(arr))
- for i, v := range arr {
- s := fArr.Index(i)
- s.SetString(v.(string))
- }
- f.Set(fArr)
- }
- case reflect.Uint8:
- safeArray := prop.ToArray()
- if safeArray != nil {
- arr := safeArray.ToValueArray()
- fArr := reflect.MakeSlice(f.Type(), len(arr), len(arr))
- for i, v := range arr {
- s := fArr.Index(i)
- s.SetUint(reflect.ValueOf(v).Uint())
- }
- f.Set(fArr)
- }
- default:
- return &ErrFieldMismatch{
- StructType: of.Type(),
- FieldName: n,
- Reason: fmt.Sprintf("unsupported slice type (%T)", val),
- }
- }
- } else {
- typeof := reflect.TypeOf(val)
- if typeof == nil && (isPtr || c.NonePtrZero) {
- if (isPtr && c.PtrNil) || (!isPtr && c.NonePtrZero) {
- of.Set(reflect.Zero(of.Type()))
- }
- break
- }
- return &ErrFieldMismatch{
- StructType: of.Type(),
- FieldName: n,
- Reason: fmt.Sprintf("unsupported type (%T)", val),
- }
- }
- }
- }
- return errFieldMismatch
-}
-
-type multiArgType int
-
-const (
- multiArgTypeInvalid multiArgType = iota
- multiArgTypeStruct
- multiArgTypeStructPtr
-)
-
-// checkMultiArg checks that v has type []S, []*S for some struct type S.
-//
-// It returns what category the slice's elements are, and the reflect.Type
-// that represents S.
-func checkMultiArg(v reflect.Value) (m multiArgType, elemType reflect.Type) {
- if v.Kind() != reflect.Slice {
- return multiArgTypeInvalid, nil
- }
- elemType = v.Type().Elem()
- switch elemType.Kind() {
- case reflect.Struct:
- return multiArgTypeStruct, elemType
- case reflect.Ptr:
- elemType = elemType.Elem()
- if elemType.Kind() == reflect.Struct {
- return multiArgTypeStructPtr, elemType
- }
- }
- return multiArgTypeInvalid, nil
-}
-
-func oleInt64(item *ole.IDispatch, prop string) (int64, error) {
- v, err := oleutil.GetProperty(item, prop)
- if err != nil {
- return 0, err
- }
- defer v.Clear()
-
- i := int64(v.Val)
- return i, nil
-}
-
-// CreateQuery returns a WQL query string that queries all columns of src. where
-// is an optional string that is appended to the query, to be used with WHERE
-// clauses. In such a case, the "WHERE" string should appear at the beginning.
-func CreateQuery(src interface{}, where string) string {
- var b bytes.Buffer
- b.WriteString("SELECT ")
- s := reflect.Indirect(reflect.ValueOf(src))
- t := s.Type()
- if s.Kind() == reflect.Slice {
- t = t.Elem()
- }
- if t.Kind() != reflect.Struct {
- return ""
- }
- var fields []string
- for i := 0; i < t.NumField(); i++ {
- fields = append(fields, t.Field(i).Name)
- }
- b.WriteString(strings.Join(fields, ", "))
- b.WriteString(" FROM ")
- b.WriteString(t.Name())
- b.WriteString(" " + where)
- return b.String()
-}
diff --git a/vendor/github.com/cjbassi/drawille-go/LICENSE.md b/vendor/github.com/cjbassi/drawille-go/LICENSE.md
deleted file mode 100644
index 58777e3..0000000
--- a/vendor/github.com/cjbassi/drawille-go/LICENSE.md
+++ /dev/null
@@ -1,661 +0,0 @@
-GNU AFFERO GENERAL PUBLIC LICENSE
- Version 3, 19 November 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU Affero General Public License is a free, copyleft license for
-software and other kinds of works, specifically designed to ensure
-cooperation with the community in the case of network server software.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-our General Public Licenses are intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- Developers that use our General Public Licenses protect your rights
-with two steps: (1) assert copyright on the software, and (2) offer
-you this License which gives you legal permission to copy, distribute
-and/or modify the software.
-
- A secondary benefit of defending all users' freedom is that
-improvements made in alternate versions of the program, if they
-receive widespread use, become available for other developers to
-incorporate. Many developers of free software are heartened and
-encouraged by the resulting cooperation. However, in the case of
-software used on network servers, this result may fail to come about.
-The GNU General Public License permits making a modified version and
-letting the public access it on a server without ever releasing its
-source code to the public.
-
- The GNU Affero General Public License is designed specifically to
-ensure that, in such cases, the modified source code becomes available
-to the community. It requires the operator of a network server to
-provide the source code of the modified version running there to the
-users of that server. Therefore, public use of a modified version, on
-a publicly accessible server, gives the public access to the source
-code of the modified version.
-
- An older license, called the Affero General Public License and
-published by Affero, was designed to accomplish similar goals. This is
-a different license, not a version of the Affero GPL, but Affero has
-released a new version of the Affero GPL which permits relicensing under
-this license.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU Affero General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Remote Network Interaction; Use with the GNU General Public License.
-
- Notwithstanding any other provision of this License, if you modify the
-Program, your modified version must prominently offer all users
-interacting with it remotely through a computer network (if your version
-supports such interaction) an opportunity to receive the Corresponding
-Source of your version by providing access to the Corresponding Source
-from a network server at no charge, through some standard or customary
-means of facilitating copying of software. This Corresponding Source
-shall include the Corresponding Source for any work covered by version 3
-of the GNU General Public License that is incorporated pursuant to the
-following paragraph.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the work with which it is combined will remain governed by version
-3 of the GNU General Public License.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU Affero General Public License from time to time. Such new versions
-will be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU Affero General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU Affero General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU Affero General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-
- Copyright (C)
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-
-Also add information on how to contact you by electronic and paper mail.
-
- If your software can interact with users remotely through a computer
-network, you should also make sure that it provides a way for users to
-get its source. For example, if your program is a web application, its
-interface could display a "Source" link that leads users to an archive
-of the code. There are many ways you could offer source, and different
-solutions will be better for different programs; see section 13 for the
-specific requirements.
-
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU AGPL, see
-.
diff --git a/vendor/github.com/cjbassi/drawille-go/README.md b/vendor/github.com/cjbassi/drawille-go/README.md
deleted file mode 100644
index b2ea77c..0000000
--- a/vendor/github.com/cjbassi/drawille-go/README.md
+++ /dev/null
@@ -1,24 +0,0 @@
-GO-DRAWILLE
-===========
-Drawing in the terminal with Unicode Braille characters.
-A [go](https://golang.org) port of [asciimoo's](https://github.com/asciimoo) [drawille](https://github.com/asciimoo/drawille)
-
-### LICENSE
-
-```
-drawille-go is free software: you can redistribute it and/or modify
-it under the terms of the GNU Affero General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-drawille-go is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU Affero General Public License for more details.
-
-You should have received a copy of the GNU Affero General Public License
-along with drawille-go. If not, see < http://www.gnu.org/licenses/ >.
-
-(C) 2014 by Adam Tauber,
-(C) 2014 by Jacob Hughes,
-```
diff --git a/vendor/github.com/cjbassi/drawille-go/drawille.go b/vendor/github.com/cjbassi/drawille-go/drawille.go
deleted file mode 100644
index 601d1dc..0000000
--- a/vendor/github.com/cjbassi/drawille-go/drawille.go
+++ /dev/null
@@ -1,275 +0,0 @@
-package drawille
-
-//import "code.google.com/p/goncurses"
-import "math"
-
-var pixel_map = [4][2]int{
- {0x1, 0x8},
- {0x2, 0x10},
- {0x4, 0x20},
- {0x40, 0x80}}
-
-// Braille chars start at 0x2800
-var braille_char_offset = 0x2800
-
-func getPixel(y, x int) int {
- var cy, cx int
- if y >= 0 {
- cy = y % 4
- } else {
- cy = 3 + ((y + 1) % 4)
- }
- if x >= 0 {
- cx = x % 2
- } else {
- cx = 1 + ((x + 1) % 2)
- }
- return pixel_map[cy][cx]
-}
-
-type Canvas struct {
- LineEnding string
- chars map[int]map[int]int
-}
-
-// Make a new canvas
-func NewCanvas() Canvas {
- c := Canvas{LineEnding: "\n"}
- c.Clear()
- return c
-}
-
-func (c Canvas) MaxY() int {
- max := 0
- for k, _ := range c.chars {
- if k > max {
- max = k
- }
- }
- return max * 4
-}
-
-func (c Canvas) MinY() int {
- min := 0
- for k, _ := range c.chars {
- if k < min {
- min = k
- }
- }
- return min * 4
-}
-
-func (c Canvas) MaxX() int {
- max := 0
- for _, v := range c.chars {
- for k, _ := range v {
- if k > max {
- max = k
- }
- }
- }
- return max * 2
-}
-
-func (c Canvas) MinX() int {
- min := 0
- for _, v := range c.chars {
- for k, _ := range v {
- if k < min {
- min = k
- }
- }
- }
- return min * 2
-}
-
-// Clear all pixels
-func (c *Canvas) Clear() {
- c.chars = make(map[int]map[int]int)
-}
-
-// Convert x,y to cols, rows
-func (c Canvas) get_pos(x, y int) (int, int) {
- return (x / 2), (y / 4)
-}
-
-// Set a pixel of c
-func (c *Canvas) Set(x, y int) {
- px, py := c.get_pos(x, y)
- if m := c.chars[py]; m == nil {
- c.chars[py] = make(map[int]int)
- }
- val := c.chars[py][px]
- mapv := getPixel(y, x)
- c.chars[py][px] = val | mapv
-}
-
-// Unset a pixel of c
-func (c *Canvas) UnSet(x, y int) {
- px, py := c.get_pos(x, y)
- x, y = int(math.Abs(float64(x))), int(math.Abs(float64(y)))
- if m := c.chars[py]; m == nil {
- c.chars[py] = make(map[int]int)
- }
- c.chars[py][px] = c.chars[py][px] &^ getPixel(y, x)
-}
-
-// Toggle a point
-func (c *Canvas) Toggle(x, y int) {
- px, py := c.get_pos(x, y)
- if (c.chars[py][px] & getPixel(y, x)) != 0 {
- c.UnSet(x, y)
- } else {
- c.Set(x, y)
- }
-}
-
-// Set text to the given coordinates
-func (c *Canvas) SetText(x, y int, text string) {
- x, y = x/2, y/4
- if m := c.chars[y]; m == nil {
- c.chars[y] = make(map[int]int)
- }
- for i, char := range text {
- c.chars[y][x+i] = int(char) - braille_char_offset
- }
-}
-
-// Get pixel at the given coordinates
-func (c Canvas) Get(x, y int) bool {
- dot_index := pixel_map[y%4][x%2]
- x, y = x/2, y/4
- char := c.chars[y][x]
- return (char & dot_index) != 0
-}
-
-// Get character at the given screen coordinates
-func (c Canvas) GetScreenCharacter(x, y int) rune {
- return rune(c.chars[y][x] + braille_char_offset)
-}
-
-// Get character for the given pixel
-func (c Canvas) GetCharacter(x, y int) rune {
- return c.GetScreenCharacter(x/4, y/4)
-}
-
-// Retrieve the rows from a given view
-func (c Canvas) Rows(minX, minY, maxX, maxY int) []string {
- minrow, maxrow := minY/4, (maxY)/4
- mincol, maxcol := minX/2, (maxX)/2
-
- ret := make([]string, 0)
- for rownum := minrow; rownum < (maxrow + 1); rownum = rownum + 1 {
- row := ""
- for x := mincol; x < (maxcol + 1); x = x + 1 {
- char := c.chars[rownum][x]
- row += string(rune(char + braille_char_offset))
- }
- ret = append(ret, row)
- }
- return ret
-}
-
-// Retrieve a string representation of the frame at the given parameters
-func (c Canvas) Frame(minX, minY, maxX, maxY int) string {
- var ret string
- for _, row := range c.Rows(minX, minY, maxX, maxY) {
- ret += row
- ret += c.LineEnding
- }
- return ret
-}
-
-func (c Canvas) String() string {
- return c.Frame(c.MinX(), c.MinY(), c.MaxX(), c.MaxY())
-}
-
-type Point struct {
- X, Y int
-}
-
-// Line returns []Point where each Point is a dot in the line
-func Line(x1, y1, x2, y2 int) []Point {
- xdiff := abs(x1 - x2)
- ydiff := abs(y2 - y1)
-
- var xdir, ydir int
- if x1 <= x2 {
- xdir = 1
- } else {
- xdir = -1
- }
- if y1 <= y2 {
- ydir = 1
- } else {
- ydir = -1
- }
-
- r := max(xdiff, ydiff)
-
- points := make([]Point, r+1)
-
- for i := 0; i <= r; i++ {
- x, y := x1, y1
- if ydiff != 0 {
- y += (i * ydiff) / (r * ydir)
- }
- if xdiff != 0 {
- x += (i * xdiff) / (r * xdir)
- }
- points[i] = Point{x, y}
- }
-
- return points
-}
-
-// DrawLine draws a line onto the Canvas
-func (c *Canvas) DrawLine(x1, y1, x2, y2 int) {
- for _, p := range Line(x1, y1, x2, y2) {
- c.Set(p.X, p.Y)
- }
-}
-
-func (c *Canvas) DrawPolygon(center_x, center_y, sides, radius float64) {
- degree := 360 / sides
- for n := 0; n < int(sides); n = n + 1 {
- a := float64(n) * degree
- b := float64(n+1) * degree
-
- x1 := int(center_x + (math.Cos(radians(a)) * (radius/2 + 1)))
- y1 := int(center_y + (math.Sin(radians(a)) * (radius/2 + 1)))
- x2 := int(center_x + (math.Cos(radians(b)) * (radius/2 + 1)))
- y2 := int(center_y + (math.Sin(radians(b)) * (radius/2 + 1)))
-
- c.DrawLine(x1, y1, x2, y2)
- }
-}
-
-func radians(d float64) float64 {
- return d * (math.Pi / 180)
-}
-
-func round(x float64) int {
- return int(x + 0.5)
-}
-
-func min(x, y int) int {
- if x < y {
- return x
- }
- return y
-}
-
-func max(x, y int) int {
- if x > y {
- return x
- }
- return y
-}
-
-func abs(x int) int {
- if x < 0 {
- return x * -1
- }
- return x
-}
diff --git a/vendor/github.com/cjbassi/termui/Gopkg.lock b/vendor/github.com/cjbassi/termui/Gopkg.lock
deleted file mode 100644
index 389639a..0000000
--- a/vendor/github.com/cjbassi/termui/Gopkg.lock
+++ /dev/null
@@ -1,27 +0,0 @@
-# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
-
-
-[[projects]]
- branch = "master"
- name = "github.com/cjbassi/drawille-go"
- packages = ["."]
- revision = "ad535d0f92cd951308cdb80675e05c62c6b8b296"
-
-[[projects]]
- name = "github.com/mattn/go-runewidth"
- packages = ["."]
- revision = "9e777a8366cce605130a531d2cd6363d07ad7317"
- version = "v0.0.2"
-
-[[projects]]
- branch = "master"
- name = "github.com/nsf/termbox-go"
- packages = ["."]
- revision = "3e24a7b6661e09b87a9f49d693034219f81602fa"
-
-[solve-meta]
- analyzer-name = "dep"
- analyzer-version = 1
- inputs-digest = "f1dfdd9839e126df79e5c328aef4af3ea9ff34e5a3b26c26eb289496f4f5bf98"
- solver-name = "gps-cdcl"
- solver-version = 1
diff --git a/vendor/github.com/cjbassi/termui/Gopkg.toml b/vendor/github.com/cjbassi/termui/Gopkg.toml
deleted file mode 100644
index 248bc27..0000000
--- a/vendor/github.com/cjbassi/termui/Gopkg.toml
+++ /dev/null
@@ -1,38 +0,0 @@
-# Gopkg.toml example
-#
-# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
-# for detailed Gopkg.toml documentation.
-#
-# required = ["github.com/user/thing/cmd/thing"]
-# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
-#
-# [[constraint]]
-# name = "github.com/user/project"
-# version = "1.0.0"
-#
-# [[constraint]]
-# name = "github.com/user/project2"
-# branch = "dev"
-# source = "github.com/myfork/project2"
-#
-# [[override]]
-# name = "github.com/x/y"
-# version = "2.4.0"
-#
-# [prune]
-# non-go = false
-# go-tests = true
-# unused-packages = true
-
-
-[[constraint]]
- branch = "master"
- name = "github.com/cjbassi/drawille-go"
-
-[[constraint]]
- branch = "master"
- name = "github.com/nsf/termbox-go"
-
-[prune]
- go-tests = true
- unused-packages = true
diff --git a/vendor/github.com/cjbassi/termui/LICENSE b/vendor/github.com/cjbassi/termui/LICENSE
deleted file mode 100644
index dbbe355..0000000
--- a/vendor/github.com/cjbassi/termui/LICENSE
+++ /dev/null
@@ -1,661 +0,0 @@
- GNU AFFERO GENERAL PUBLIC LICENSE
- Version 3, 19 November 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU Affero General Public License is a free, copyleft license for
-software and other kinds of works, specifically designed to ensure
-cooperation with the community in the case of network server software.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-our General Public Licenses are intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- Developers that use our General Public Licenses protect your rights
-with two steps: (1) assert copyright on the software, and (2) offer
-you this License which gives you legal permission to copy, distribute
-and/or modify the software.
-
- A secondary benefit of defending all users' freedom is that
-improvements made in alternate versions of the program, if they
-receive widespread use, become available for other developers to
-incorporate. Many developers of free software are heartened and
-encouraged by the resulting cooperation. However, in the case of
-software used on network servers, this result may fail to come about.
-The GNU General Public License permits making a modified version and
-letting the public access it on a server without ever releasing its
-source code to the public.
-
- The GNU Affero General Public License is designed specifically to
-ensure that, in such cases, the modified source code becomes available
-to the community. It requires the operator of a network server to
-provide the source code of the modified version running there to the
-users of that server. Therefore, public use of a modified version, on
-a publicly accessible server, gives the public access to the source
-code of the modified version.
-
- An older license, called the Affero General Public License and
-published by Affero, was designed to accomplish similar goals. This is
-a different license, not a version of the Affero GPL, but Affero has
-released a new version of the Affero GPL which permits relicensing under
-this license.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU Affero General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Remote Network Interaction; Use with the GNU General Public License.
-
- Notwithstanding any other provision of this License, if you modify the
-Program, your modified version must prominently offer all users
-interacting with it remotely through a computer network (if your version
-supports such interaction) an opportunity to receive the Corresponding
-Source of your version by providing access to the Corresponding Source
-from a network server at no charge, through some standard or customary
-means of facilitating copying of software. This Corresponding Source
-shall include the Corresponding Source for any work covered by version 3
-of the GNU General Public License that is incorporated pursuant to the
-following paragraph.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the work with which it is combined will remain governed by version
-3 of the GNU General Public License.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU Affero General Public License from time to time. Such new versions
-will be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU Affero General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU Affero General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU Affero General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-
- Copyright (C)
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-
-Also add information on how to contact you by electronic and paper mail.
-
- If your software can interact with users remotely through a computer
-network, you should also make sure that it provides a way for users to
-get its source. For example, if your program is a web application, its
-interface could display a "Source" link that leads users to an archive
-of the code. There are many ways you could offer source, and different
-solutions will be better for different programs; see section 13 for the
-specific requirements.
-
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU AGPL, see
-.
diff --git a/vendor/github.com/cjbassi/termui/README.md b/vendor/github.com/cjbassi/termui/README.md
deleted file mode 100644
index 6ac814c..0000000
--- a/vendor/github.com/cjbassi/termui/README.md
+++ /dev/null
@@ -1,21 +0,0 @@
-# termui
-
-A fork of [termui](https://github.com/gizak/termui) with a lot of code cleanup and (frequently asked for) improvements.
-
-You can see an implementation/example usage of this library [here](https://github.com/cjbassi/gotop).
-
-Some usage improvements include:
-* better event/key-combo names
-* more convenient event handling function
-* 256 colors
-* better grid system
-* linegraph uses [drawille-go](https://github.com/exrook/drawille-go)
- * no longer have to choose between dot mode and braille mode; uses a superior braille mode
-* table supports mouse and keyboard navigation
-* table is scrollable
-* more powerful table column width sizing
-* visual improvements to linegraph and table
-
-TODO:
-* readd widgets that were removed like the list and bargraph
-* focusable widgets
diff --git a/vendor/github.com/cjbassi/termui/block.go b/vendor/github.com/cjbassi/termui/block.go
deleted file mode 100644
index 4695f25..0000000
--- a/vendor/github.com/cjbassi/termui/block.go
+++ /dev/null
@@ -1,100 +0,0 @@
-package termui
-
-import (
- "image"
-)
-
-// Block is a base struct for all other upper level widgets.
-type Block struct {
- Grid image.Rectangle
- X int // largest X value in the inner square
- Y int // largest Y value in the inner square
- XOffset int // the X position of the widget on the terminal
- YOffset int // the Y position of the widget on the terminal
- Label string
- BorderFg Color
- BorderBg Color
- LabelFg Color
- LabelBg Color
- Fg Color
- Bg Color
-}
-
-// NewBlock returns a *Block which inherits styles from the current theme.
-func NewBlock() *Block {
- return &Block{
- Fg: Theme.Fg,
- Bg: Theme.Bg,
- BorderFg: Theme.BorderFg,
- BorderBg: Theme.BorderBg,
- LabelFg: Theme.LabelFg,
- LabelBg: Theme.LabelBg,
- }
-}
-
-func (self *Block) drawBorder(buf *Buffer) {
- x := self.X + 1
- y := self.Y + 1
-
- // draw lines
- buf.Merge(NewFilledBuffer(0, 0, x, 1, Cell{HORIZONTAL_LINE, self.BorderFg, self.BorderBg}))
- buf.Merge(NewFilledBuffer(0, y, x, y+1, Cell{HORIZONTAL_LINE, self.BorderFg, self.BorderBg}))
- buf.Merge(NewFilledBuffer(0, 0, 1, y+1, Cell{VERTICAL_LINE, self.BorderFg, self.BorderBg}))
- buf.Merge(NewFilledBuffer(x, 0, x+1, y+1, Cell{VERTICAL_LINE, self.BorderFg, self.BorderBg}))
-
- // draw corners
- buf.SetCell(0, 0, Cell{TOP_LEFT, self.BorderFg, self.BorderBg})
- buf.SetCell(x, 0, Cell{TOP_RIGHT, self.BorderFg, self.BorderBg})
- buf.SetCell(0, y, Cell{BOTTOM_LEFT, self.BorderFg, self.BorderBg})
- buf.SetCell(x, y, Cell{BOTTOM_RIGHT, self.BorderFg, self.BorderBg})
-}
-
-func (self *Block) drawLabel(buf *Buffer) {
- r := MaxString(self.Label, (self.X-3)-1)
- buf.SetString(3, 0, r, self.LabelFg, self.LabelBg)
- if self.Label == "" {
- return
- }
- c := Cell{' ', self.Fg, self.Bg}
- buf.SetCell(2, 0, c)
- if len(self.Label)+3 < self.X {
- buf.SetCell(len(self.Label)+3, 0, c)
- } else {
- buf.SetCell(self.X-1, 0, c)
- }
-}
-
-// Resize computes Height, Width, XOffset, and YOffset given terminal dimensions.
-func (self *Block) Resize(termWidth, termHeight, termCols, termRows int) {
- self.X = int((float64(self.Grid.Dx())/float64(termCols))*float64(termWidth)) - 2
- self.Y = int((float64(self.Grid.Dy())/float64(termRows))*float64(termHeight)) - 2
- self.XOffset = int((float64(self.Grid.Min.X) / float64(termCols)) * float64(termWidth))
- self.YOffset = int((float64(self.Grid.Min.Y) / float64(termRows)) * float64(termHeight))
-}
-
-// SetGrid create a rectangle representing the block's dimensions in the grid.
-func (self *Block) SetGrid(c0, r0, c1, r1 int) {
- self.Grid = image.Rect(c0, r0, c1, r1)
-}
-
-// GetXOffset implements Bufferer interface.
-func (self *Block) GetXOffset() int {
- return self.XOffset
-}
-
-// GetYOffset implements Bufferer interface.
-func (self *Block) GetYOffset() int {
- return self.YOffset
-}
-
-// Buffer implements Bufferer interface and draws background, border, and borderlabel.
-func (self *Block) Buffer() *Buffer {
- buf := NewBuffer()
- buf.SetAreaXY(self.X+2, self.Y+2)
- buf.Fill(Cell{' ', ColorDefault, self.Bg})
-
- self.drawBorder(buf)
- self.drawLabel(buf)
-
- return buf
-}
diff --git a/vendor/github.com/cjbassi/termui/block_common.go b/vendor/github.com/cjbassi/termui/block_common.go
deleted file mode 100644
index aeef1c8..0000000
--- a/vendor/github.com/cjbassi/termui/block_common.go
+++ /dev/null
@@ -1,18 +0,0 @@
-// +build !windows
-
-package termui
-
-const (
- TOP_RIGHT = '┐'
- VERTICAL_LINE = '│'
- HORIZONTAL_LINE = '─'
- TOP_LEFT = '┌'
- BOTTOM_RIGHT = '┘'
- BOTTOM_LEFT = '└'
- VERTICAL_LEFT = '┤'
- VERTICAL_RIGHT = '├'
- HORIZONTAL_DOWN = '┬'
- HORIZONTAL_UP = '┴'
- QUOTA_LEFT = '«'
- QUOTA_RIGHT = '»'
-)
diff --git a/vendor/github.com/cjbassi/termui/block_windows.go b/vendor/github.com/cjbassi/termui/block_windows.go
deleted file mode 100644
index af0307f..0000000
--- a/vendor/github.com/cjbassi/termui/block_windows.go
+++ /dev/null
@@ -1,18 +0,0 @@
-// +build windows
-
-package termui
-
-const (
- TOP_RIGHT = '+'
- VERTICAL_LINE = '|'
- HORIZONTAL_LINE = '-'
- TOP_LEFT = '+'
- BOTTOM_RIGHT = '+'
- BOTTOM_LEFT = '+'
- VERTICAL_LEFT = '+'
- VERTICAL_RIGHT = '+'
- HORIZONTAL_DOWN = '+'
- HORIZONTAL_UP = '+'
- QUOTA_LEFT = '<'
- QUOTA_RIGHT = '>'
-)
diff --git a/vendor/github.com/cjbassi/termui/buffer.go b/vendor/github.com/cjbassi/termui/buffer.go
deleted file mode 100644
index 9faabaf..0000000
--- a/vendor/github.com/cjbassi/termui/buffer.go
+++ /dev/null
@@ -1,99 +0,0 @@
-package termui
-
-import (
- "image"
-)
-
-// Cell is a rune with assigned Fg and Bg.
-type Cell struct {
- Ch rune
- Fg Color
- Bg Color
-}
-
-// Buffer is a renderable rectangle cell data container.
-type Buffer struct {
- Area image.Rectangle // selected drawing area
- CellMap map[image.Point]Cell
-}
-
-// NewCell returne a new Cell given all necessary fields.
-func NewCell(ch rune, Fg, Bg Color) Cell {
- return Cell{ch, Fg, Bg}
-}
-
-// NewBuffer returns a new empty Buffer.
-func NewBuffer() *Buffer {
- return &Buffer{
- CellMap: make(map[image.Point]Cell),
- Area: image.Rectangle{},
- }
-}
-
-// NewFilledBuffer returns a new Buffer filled with the given Cell.
-func NewFilledBuffer(x0, y0, x1, y1 int, c Cell) *Buffer {
- buf := NewBuffer()
- buf.Area.Min = image.Pt(x0, y0)
- buf.Area.Max = image.Pt(x1, y1)
- buf.Fill(c)
- return buf
-}
-
-// SetCell assigns a Cell to (x,y).
-func (self *Buffer) SetCell(x, y int, c Cell) {
- self.CellMap[image.Pt(x, y)] = c
-}
-
-// SetString assigns a string to a Buffer starting at (x,y).
-func (self *Buffer) SetString(x, y int, s string, fg, bg Color) {
- for i, char := range s {
- self.SetCell(x+i, y, Cell{char, fg, bg})
- }
-}
-
-// At returns the cell at (x,y).
-func (self *Buffer) At(x, y int) Cell {
- return self.CellMap[image.Pt(x, y)]
-}
-
-// SetArea assigns a new rect area to self.
-func (self *Buffer) SetArea(r image.Rectangle) {
- self.Area.Max = r.Max
- self.Area.Min = r.Min
-}
-
-// SetAreaXY sets the Buffer bounds from (0,0) to (x,y).
-func (self *Buffer) SetAreaXY(x, y int) {
- self.Area.Min.Y = 0
- self.Area.Min.X = 0
- self.Area.Max.Y = y
- self.Area.Max.X = x
-}
-
-// Merge merges the given buffers onto the current Buffer.
-func (self *Buffer) Merge(bs ...*Buffer) {
- for _, buf := range bs {
- for p, c := range buf.CellMap {
- self.SetCell(p.X, p.Y, c)
- }
- self.SetArea(self.Area.Union(buf.Area))
- }
-}
-
-// MergeWithOffset merges a Buffer onto another with an offset.
-func (self *Buffer) MergeWithOffset(buf *Buffer, xOffset, yOffset int) {
- for p, c := range buf.CellMap {
- self.SetCell(p.X+xOffset, p.Y+yOffset, c)
- }
- rect := image.Rect(xOffset, yOffset, buf.Area.Max.X+xOffset, buf.Area.Max.Y+yOffset)
- self.SetArea(self.Area.Union(rect))
-}
-
-// Fill fills the Buffer with a Cell.
-func (self *Buffer) Fill(c Cell) {
- for x := self.Area.Min.X; x < self.Area.Max.X; x++ {
- for y := self.Area.Min.Y; y < self.Area.Max.Y; y++ {
- self.SetCell(x, y, c)
- }
- }
-}
diff --git a/vendor/github.com/cjbassi/termui/colors.go b/vendor/github.com/cjbassi/termui/colors.go
deleted file mode 100644
index b0ef8ba..0000000
--- a/vendor/github.com/cjbassi/termui/colors.go
+++ /dev/null
@@ -1,46 +0,0 @@
-package termui
-
-// Color is an integer in the range -1 to 255.
-// -1 is clear, while 0-255 are xterm 256 colors.
-type Color int
-
-// ColorDefault = clear
-const ColorDefault = -1
-
-// Copied from termbox. Attributes that can be bitwise OR'ed with a color.
-const (
- AttrBold Color = 1 << (iota + 9)
- AttrUnderline
- AttrReverse
-)
-
-// A Colorscheme represents the current look-and-feel of the dashboard.
-type Colorscheme struct {
- Fg Color
- Bg Color
-
- LabelFg Color
- LabelBg Color
- BorderFg Color
- BorderBg Color
-
- Sparkline Color
- LineGraph Color
- TableCursor Color
- GaugeColor Color
-}
-
-var Theme = Colorscheme{
- Fg: 7,
- Bg: -1,
-
- LabelFg: 7,
- LabelBg: -1,
- BorderFg: 6,
- BorderBg: -1,
-
- Sparkline: 4,
- LineGraph: 0,
- TableCursor: 4,
- GaugeColor: 7,
-}
diff --git a/vendor/github.com/cjbassi/termui/events.go b/vendor/github.com/cjbassi/termui/events.go
deleted file mode 100644
index 3bc5459..0000000
--- a/vendor/github.com/cjbassi/termui/events.go
+++ /dev/null
@@ -1,204 +0,0 @@
-package termui
-
-import (
- "strconv"
-
- tb "github.com/nsf/termbox-go"
-)
-
-/*
-here's the list of events which you can assign handlers too using the `On` function:
- mouse events:
-
-
- keyboard events:
- any uppercase or lowercase letter or a set of two letters like j or jj or J or JJ
- etc
- etc
-
-
-
- > etc
- terminal events:
-
-*/
-
-var eventStream = EventStream{
- make(map[string]func(Event)),
- "",
- make(chan bool, 1),
- make(chan tb.Event),
-}
-
-type EventStream struct {
- eventHandlers map[string]func(Event)
- prevKey string // previous keypress
- stopLoop chan bool
- eventQueue chan tb.Event // list of events from termbox
-}
-
-// Event is a copy of termbox.Event that only contains the fields we need.
-type Event struct {
- Key string
- Width int
- Height int
- MouseX int
- MouseY int
-}
-
-// handleEvent calls the approriate callback function if there is one.
-func handleEvent(e tb.Event) {
- if e.Type == tb.EventError {
- panic(e.Err)
- }
-
- ne := convertTermboxEvent(e)
-
- if val, ok := eventStream.eventHandlers[ne.Key]; ok {
- val(ne)
- eventStream.prevKey = ""
- } else { // check if the last 2 keys form a key combo with a handler
- // if this is a keyboard event and the previous event was unhandled
- if e.Type == tb.EventKey && eventStream.prevKey != "" {
- combo := eventStream.prevKey + ne.Key
- if val, ok := eventStream.eventHandlers[combo]; ok {
- ne.Key = combo
- val(ne)
- eventStream.prevKey = ""
- } else {
- eventStream.prevKey = ne.Key
- }
- } else {
- eventStream.prevKey = ne.Key
- }
- }
-}
-
-// Loop gets events from termbox and passes them off to handleEvent.
-// Stops when StopLoop is called.
-func Loop() {
- go func() {
- for {
- eventStream.eventQueue <- tb.PollEvent()
- }
- }()
-
- for {
- select {
- case <-eventStream.stopLoop:
- return
- case e := <-eventStream.eventQueue:
- handleEvent(e)
- }
- }
-}
-
-// StopLoop stops the event loop.
-func StopLoop() {
- eventStream.stopLoop <- true
-}
-
-// On assigns event names to their handlers. Takes a string, strings, or a slice of strings, and a function.
-func On(things ...interface{}) {
- function := things[len(things)-1].(func(Event))
- for _, thing := range things {
- if value, ok := thing.(string); ok {
- eventStream.eventHandlers[value] = function
- }
- if value, ok := thing.([]string); ok {
- for _, name := range value {
- eventStream.eventHandlers[name] = function
- }
- }
- }
-}
-
-// convertTermboxKeyValue converts a termbox keyboard event to a more friendly string format.
-// Combines modifiers into the string instead of having them as additional fields in an event.
-func convertTermboxKeyValue(e tb.Event) string {
- k := string(e.Ch)
- pre := ""
- mod := ""
-
- if e.Mod == tb.ModAlt {
- mod = " 0xFFFF-12 {
- k = ""
- } else if e.Key > 0xFFFF-25 {
- ks := []string{"", "", "", "", "", "", "", "", "", ""}
- k = ks[0xFFFF-int(e.Key)-12]
- }
-
- if e.Key <= 0x7F {
- pre = ""},
- tb.KeyBackspace: {"", ""},
- tb.KeyTab: {"", ""},
- tb.KeyEnter: {"", ""},
- tb.KeyEsc: {"", ""},
- tb.KeyCtrlBackslash: {"C-", "\\"},
- tb.KeyCtrlSlash: {"C-", "/"},
- tb.KeySpace: {"", ""},
- tb.KeyCtrl8: {"C-", "8"},
- }
- if sk, ok := kmap[e.Key]; ok {
- pre = sk[0]
- k = sk[1]
- }
- }
- }
-
- if pre != "" {
- k += ">"
- }
-
- return pre + mod + k
-}
-
-func convertTermboxMouseValue(e tb.Event) string {
- switch e.Key {
- case tb.MouseLeft:
- return ""
- case tb.MouseMiddle:
- return ""
- case tb.MouseRight:
- return ""
- case tb.MouseWheelUp:
- return ""
- case tb.MouseWheelDown:
- return ""
- case tb.MouseRelease:
- return ""
- }
- return ""
-}
-
-// convertTermboxEvent turns a termbox event into a termui event.
-func convertTermboxEvent(e tb.Event) Event {
- var ne Event
-
- switch e.Type {
- case tb.EventKey:
- ne = Event{
- Key: convertTermboxKeyValue(e),
- }
- case tb.EventMouse:
- ne = Event{
- Key: convertTermboxMouseValue(e),
- MouseX: e.MouseX,
- MouseY: e.MouseY,
- }
- case tb.EventResize:
- ne = Event{
- Key: "",
- Width: e.Width,
- Height: e.Height,
- }
- }
-
- return ne
-}
diff --git a/vendor/github.com/cjbassi/termui/gauge.go b/vendor/github.com/cjbassi/termui/gauge.go
deleted file mode 100644
index a5b3b2a..0000000
--- a/vendor/github.com/cjbassi/termui/gauge.go
+++ /dev/null
@@ -1,51 +0,0 @@
-package termui
-
-import (
- "strconv"
-)
-
-// Gauge is a progress bar like widget.
-type Gauge struct {
- *Block
- Percent int
- GaugeColor Color
- Description string
-}
-
-// NewGauge return a new gauge with current theme.
-func NewGauge() *Gauge {
- return &Gauge{
- Block: NewBlock(),
- GaugeColor: Theme.GaugeColor,
- }
-}
-
-// Buffer implements Bufferer interface.
-func (self *Gauge) Buffer() *Buffer {
- buf := self.Block.Buffer()
-
- // plot bar
- width := self.Percent * self.X / 100
- for y := 1; y <= self.Y; y++ {
- for x := 1; x <= width; x++ {
- buf.SetCell(x, y, Cell{' ', self.GaugeColor, self.GaugeColor})
- }
- }
-
- // plot percentage
- s := strconv.Itoa(self.Percent) + "%" + self.Description
- s = MaxString(s, self.X)
- y := (self.Y + 1) / 2
- x := ((self.X - len(s)) + 1) / 2
- for i, char := range s {
- bg := self.Bg
- fg := self.Fg
- if x+i < width {
- fg = self.GaugeColor
- bg = AttrReverse
- }
- buf.SetCell(1+x+i, y, Cell{char, fg, bg})
- }
-
- return buf
-}
diff --git a/vendor/github.com/cjbassi/termui/grid.go b/vendor/github.com/cjbassi/termui/grid.go
deleted file mode 100644
index 58b4839..0000000
--- a/vendor/github.com/cjbassi/termui/grid.go
+++ /dev/null
@@ -1,66 +0,0 @@
-package termui
-
-var Body *Grid
-
-// GridBufferer introduces a Bufferer that can be manipulated by Grid.
-type GridBufferer interface {
- Bufferer
- Resize(int, int, int, int)
- SetGrid(int, int, int, int)
-}
-
-// Grid holds widgets and information about terminal dimensions.
-// Widgets are adjusted and rendered through the grid.
-type Grid struct {
- Widgets []GridBufferer
- Width int
- Height int
- Cols int
- Rows int
-}
-
-// NewGrid creates an empty Grid.
-func NewGrid() *Grid {
- return &Grid{}
-}
-
-// Set assigns a widget and its grid dimensions to Grid.
-func (self *Grid) Set(x0, y0, x1, y1 int, widget GridBufferer) {
- if widget == nil {
- return
- }
- if x1 <= x0 || y1 <= y0 {
- panic("Invalid widget coordinates")
- }
-
- widget.SetGrid(x0, y0, x1, y1)
- widget.Resize(self.Width, self.Height, self.Cols, self.Rows)
-
- self.Widgets = append(self.Widgets, widget)
-}
-
-// Resize resizes each widget in the grid.
-func (self *Grid) Resize() {
- for _, w := range self.Widgets {
- w.Resize(self.Width, self.Height, self.Cols, self.Rows)
- }
-}
-
-// Buffer implements the Bufferer interface by merging each widget in Grid into one buffer.
-func (self *Grid) Buffer() *Buffer {
- buf := NewFilledBuffer(0, 0, self.Width, self.Height, Cell{' ', ColorDefault, Theme.Bg})
- for _, w := range self.Widgets {
- buf.MergeWithOffset(w.Buffer(), w.GetXOffset(), w.GetYOffset())
- }
- return buf
-}
-
-// GetXOffset implements Bufferer interface.
-func (self *Grid) GetXOffset() int {
- return 0
-}
-
-// GetYOffset implements Bufferer interface.
-func (self *Grid) GetYOffset() int {
- return 0
-}
diff --git a/vendor/github.com/cjbassi/termui/init.go b/vendor/github.com/cjbassi/termui/init.go
deleted file mode 100644
index 764de2b..0000000
--- a/vendor/github.com/cjbassi/termui/init.go
+++ /dev/null
@@ -1,26 +0,0 @@
-package termui
-
-import (
- tb "github.com/nsf/termbox-go"
-)
-
-// Init initializes termui library. This function should be called before any others.
-// After initialization, the library must be finalized by 'Close' function.
-func Init() error {
- if err := tb.Init(); err != nil {
- return err
- }
- tb.SetInputMode(tb.InputEsc | tb.InputMouse)
- tb.SetOutputMode(tb.Output256)
-
- Body = NewGrid()
- Body.Width, Body.Height = tb.Size()
-
- return nil
-}
-
-// Close finalizes termui library.
-// It should be called after successful initialization when termui's functionality isn't required anymore.
-func Close() {
- tb.Close()
-}
diff --git a/vendor/github.com/cjbassi/termui/linegraph.go b/vendor/github.com/cjbassi/termui/linegraph.go
deleted file mode 100644
index 72e47ac..0000000
--- a/vendor/github.com/cjbassi/termui/linegraph.go
+++ /dev/null
@@ -1,125 +0,0 @@
-package termui
-
-import (
- "sort"
-
- drawille "github.com/cjbassi/drawille-go"
-)
-
-// LineGraph implements a line graph of data points.
-type LineGraph struct {
- *Block
- Data map[string][]float64
- LineColor map[string]Color
- Zoom int
- Labels map[string]string
-
- DefaultLineColor Color
-}
-
-// NewLineGraph returns a new LineGraph with current theme.
-func NewLineGraph() *LineGraph {
- return &LineGraph{
- Block: NewBlock(),
- Data: make(map[string][]float64),
- LineColor: make(map[string]Color),
- Labels: make(map[string]string),
- Zoom: 5,
-
- DefaultLineColor: Theme.LineGraph,
- }
-}
-
-// Buffer implements Bufferer interface.
-func (self *LineGraph) Buffer() *Buffer {
- buf := self.Block.Buffer()
- // we render each data point on to the canvas then copy over the braille to the buffer at the end
- // fyi braille characters have 2x4 dots for each character
- c := drawille.NewCanvas()
- // used to keep track of the braille colors until the end when we render the braille to the buffer
- colors := make([][]Color, self.X+2)
- for i := range colors {
- colors[i] = make([]Color, self.Y+2)
- }
-
- // sort the series so that overlapping data will overlap the same way each time
- seriesList := make([]string, len(self.Data))
- i := 0
- for seriesName := range self.Data {
- seriesList[i] = seriesName
- i++
- }
- sort.Strings(seriesList)
-
- // draw lines in reverse order so that the first color defined in the colorscheme is on top
- for i := len(seriesList) - 1; i >= 0; i-- {
- seriesName := seriesList[i]
- seriesData := self.Data[seriesName]
- seriesLineColor, ok := self.LineColor[seriesName]
- if !ok {
- seriesLineColor = self.DefaultLineColor
- }
-
- // coordinates of last point
- lastY, lastX := -1, -1
- // assign colors to `colors` and lines/points to the canvas
- for i := len(seriesData) - 1; i >= 0; i-- {
- x := ((self.X + 1) * 2) - 1 - (((len(seriesData) - 1) - i) * self.Zoom)
- y := ((self.Y + 1) * 4) - 1 - int((float64((self.Y)*4)-1)*(seriesData[i]/100))
- if x < 0 {
- // render the line to the last point up to the wall
- if x > 0-self.Zoom {
- for _, p := range drawille.Line(lastX, lastY, x, y) {
- if p.X > 0 {
- c.Set(p.X, p.Y)
- colors[p.X/2][p.Y/4] = seriesLineColor
- }
- }
- }
- break
- }
- if lastY == -1 { // if this is the first point
- c.Set(x, y)
- colors[x/2][y/4] = seriesLineColor
- } else {
- c.DrawLine(lastX, lastY, x, y)
- for _, p := range drawille.Line(lastX, lastY, x, y) {
- colors[p.X/2][p.Y/4] = seriesLineColor
- }
- }
- lastX, lastY = x, y
- }
-
- // copy braille and colors to buffer
- for y, line := range c.Rows(c.MinX(), c.MinY(), c.MaxX(), c.MaxY()) {
- for x, char := range line {
- x /= 3 // idk why but it works
- if x == 0 {
- continue
- }
- if char != 10240 { // empty braille character
- buf.SetCell(x, y, Cell{char, colors[x][y], self.Bg})
- }
- }
- }
- }
-
- // renders key/label ontop
- for j, seriesName := range seriesList {
- seriesLineColor, ok := self.LineColor[seriesName]
- if !ok {
- seriesLineColor = self.DefaultLineColor
- }
-
- // render key ontop, but let braille be drawn over space characters
- str := seriesName + " " + self.Labels[seriesName]
- for k, char := range str {
- if char != ' ' {
- buf.SetCell(3+k, j+2, Cell{char, seriesLineColor, self.Bg})
- }
- }
-
- }
-
- return buf
-}
diff --git a/vendor/github.com/cjbassi/termui/render.go b/vendor/github.com/cjbassi/termui/render.go
deleted file mode 100644
index 52bcdf3..0000000
--- a/vendor/github.com/cjbassi/termui/render.go
+++ /dev/null
@@ -1,40 +0,0 @@
-package termui
-
-import (
- "sync"
-
- tb "github.com/nsf/termbox-go"
-)
-
-// Bufferer should be implemented by all renderable components.
-type Bufferer interface {
- Buffer() *Buffer
- GetXOffset() int
- GetYOffset() int
-}
-
-// Render renders all Bufferers in the given order to termbox, then asks termbox to print the screen.
-func Render(bs ...Bufferer) {
- var wg sync.WaitGroup
- for _, b := range bs {
- wg.Add(1)
- go func(b Bufferer) {
- defer wg.Done()
- buf := b.Buffer()
- // set cells in buf
- for p, c := range buf.CellMap {
- if p.In(buf.Area) {
- tb.SetCell(p.X+b.GetXOffset(), p.Y+b.GetYOffset(), c.Ch, tb.Attribute(c.Fg)+1, tb.Attribute(c.Bg)+1)
- }
- }
- }(b)
- }
-
- wg.Wait()
- tb.Flush()
-}
-
-// Clear clears the screen with the default Bg color.
-func Clear() {
- tb.Clear(tb.ColorDefault+1, tb.Attribute(Theme.Bg)+1)
-}
diff --git a/vendor/github.com/cjbassi/termui/sparkline.go b/vendor/github.com/cjbassi/termui/sparkline.go
deleted file mode 100644
index e9073d3..0000000
--- a/vendor/github.com/cjbassi/termui/sparkline.go
+++ /dev/null
@@ -1,99 +0,0 @@
-package termui
-
-import (
- "fmt"
-)
-
-var SPARKS = [8]rune{'▁', '▂', '▃', '▄', '▅', '▆', '▇', '█'}
-
-// Sparkline is like: ▅▆▂▂▅▇▂▂▃▆▆▆▅▃. The data points should be non-negative integers.
-type Sparkline struct {
- Data []int
- Title1 string
- Title2 string
- TitleColor Color
- LineColor Color
-}
-
-// Sparklines is a renderable widget which groups together the given sparklines.
-type Sparklines struct {
- *Block
- Lines []*Sparkline
-}
-
-// Add appends a given Sparkline to the *Sparklines.
-func (self *Sparklines) Add(sl Sparkline) {
- self.Lines = append(self.Lines, &sl)
-}
-
-// NewSparkline returns an unrenderable single sparkline that intended to be added into a Sparklines.
-func NewSparkline() *Sparkline {
- return &Sparkline{
- TitleColor: Theme.Fg,
- LineColor: Theme.Sparkline,
- }
-}
-
-// NewSparklines return a new *Sparklines with given Sparklines, you can always add a new Sparkline later.
-func NewSparklines(ss ...*Sparkline) *Sparklines {
- return &Sparklines{
- Block: NewBlock(),
- Lines: ss,
- }
-}
-
-// Buffer implements Bufferer interface.
-func (self *Sparklines) Buffer() *Buffer {
- buf := self.Block.Buffer()
-
- lc := len(self.Lines) // lineCount
-
- // renders each sparkline and its titles
- for i, line := range self.Lines {
-
- // prints titles
- title1Y := 2 + (self.Y/lc)*i
- title2Y := (2 + (self.Y/lc)*i) + 1
- title1 := MaxString(line.Title1, self.X)
- title2 := MaxString(line.Title2, self.X)
- buf.SetString(1, title1Y, title1, line.TitleColor|AttrBold, self.Bg)
- buf.SetString(1, title2Y, title2, line.TitleColor|AttrBold, self.Bg)
-
- sparkY := (self.Y / lc) * (i + 1)
- // finds max data in current view used for relative heights
- max := 1
- for i := len(line.Data) - 1; i >= 0 && self.X-((len(line.Data)-1)-i) >= 1; i-- {
- if line.Data[i] > max {
- max = line.Data[i]
- }
- }
- // prints sparkline
- for x := self.X; x >= 1; x-- {
- char := SPARKS[0]
- if (self.X - x) < len(line.Data) {
- offset := self.X - x
- cur_item := line.Data[(len(line.Data)-1)-offset]
- percent := float64(cur_item) / float64(max)
- index := int(percent * 7)
- if index < 0 || index >= len(SPARKS) {
- Error("sparkline",
- fmt.Sprint(
- "len(line.Data): ", len(line.Data), "\n",
- "max: ", max, "\n",
- "x: ", x, "\n",
- "self.X: ", self.X, "\n",
- "offset: ", offset, "\n",
- "cur_item: ", cur_item, "\n",
- "percent: ", percent, "\n",
- "index: ", index, "\n",
- "len(SPARKS): ", len(SPARKS),
- ))
- }
- char = SPARKS[index]
- }
- buf.SetCell(x, sparkY, Cell{char, line.LineColor, self.Bg})
- }
- }
-
- return buf
-}
diff --git a/vendor/github.com/cjbassi/termui/table.go b/vendor/github.com/cjbassi/termui/table.go
deleted file mode 100644
index 7f18f1a..0000000
--- a/vendor/github.com/cjbassi/termui/table.go
+++ /dev/null
@@ -1,195 +0,0 @@
-package termui
-
-import (
- "fmt"
- "strings"
-)
-
-// Table tracks all the attributes of a Table instance
-type Table struct {
- *Block
-
- Header []string
- Rows [][]string
-
- ColWidths []int
- CellXPos []int // column position
- ColResizer func() // for widgets that inherit a Table and want to overload the ColResize method
- Gap int // gap between columns
- PadLeft int
-
- Cursor bool
- CursorColor Color
-
- UniqueCol int // the column used to identify the selected item
- SelectedItem string // used to keep the cursor on the correct item if the data changes
- SelectedRow int
- TopRow int // used to indicate where in the table we are scrolled at
-}
-
-// NewTable returns a new Table instance
-func NewTable() *Table {
- self := &Table{
- Block: NewBlock(),
- CursorColor: Theme.TableCursor,
- SelectedRow: 0,
- TopRow: 0,
- UniqueCol: 0,
- }
- self.ColResizer = self.ColResize
- return self
-}
-
-// ColResize is the default column resizer, but can be overriden.
-// ColResize calculates the width of each column.
-func (self *Table) ColResize() {
-}
-
-// Buffer implements the Bufferer interface.
-func (self *Table) Buffer() *Buffer {
- buf := self.Block.Buffer()
-
- self.ColResizer()
-
- // finds exact column starting position
- self.CellXPos = []int{}
- cur := 1 + self.PadLeft
- for _, w := range self.ColWidths {
- self.CellXPos = append(self.CellXPos, cur)
- cur += w
- cur += self.Gap
- }
-
- // prints header
- for i, h := range self.Header {
- width := self.ColWidths[i]
- if width == 0 {
- continue
- }
- // don't render column if it doesn't fit in widget
- if width > (self.X-self.CellXPos[i])+1 {
- continue
- }
- buf.SetString(self.CellXPos[i], 1, h, self.Fg|AttrBold, self.Bg)
- }
-
- // prints each row
- for rowNum := self.TopRow; rowNum < self.TopRow+self.Y-1 && rowNum < len(self.Rows); rowNum++ {
- if rowNum < 0 || rowNum >= len(self.Rows) {
- Error("table rows",
- fmt.Sprint(
- "rowNum: ", rowNum, "\n",
- "self.TopRow: ", self.TopRow, "\n",
- "len(self.Rows): ", len(self.Rows), "\n",
- "self.Y: ", self.Y,
- ))
- }
- row := self.Rows[rowNum]
- y := (rowNum + 2) - self.TopRow
-
- // prints cursor
- fg := self.Fg
- if self.Cursor {
- if (self.SelectedItem == "" && rowNum == self.SelectedRow) || (self.SelectedItem != "" && self.SelectedItem == row[self.UniqueCol]) {
- fg = self.CursorColor | AttrReverse
- for _, width := range self.ColWidths {
- if width == 0 {
- continue
- }
- buf.SetString(1, y, strings.Repeat(" ", self.X), fg, self.Bg)
- }
- self.SelectedItem = row[self.UniqueCol]
- self.SelectedRow = rowNum
- }
- }
-
- // prints each col of the row
- for i, width := range self.ColWidths {
- if width == 0 {
- continue
- }
- // don't render column if width is greater than distance to end of widget
- if width > (self.X-self.CellXPos[i])+1 {
- continue
- }
- r := MaxString(row[i], width)
- buf.SetString(self.CellXPos[i], y, r, fg, self.Bg)
- }
- }
-
- return buf
-}
-
-/////////////////////////////////////////////////////////////////////////////////
-// Cursor Movement //
-/////////////////////////////////////////////////////////////////////////////////
-
-// calcPos is used to calculate the cursor position and the current view.
-func (self *Table) calcPos() {
- self.SelectedItem = ""
-
- if self.SelectedRow < 0 {
- self.SelectedRow = 0
- }
- if self.SelectedRow < self.TopRow {
- self.TopRow = self.SelectedRow
- }
-
- if self.SelectedRow > len(self.Rows)-1 {
- self.SelectedRow = len(self.Rows) - 1
- }
- if self.SelectedRow > self.TopRow+(self.Y-2) {
- self.TopRow = self.SelectedRow - (self.Y - 2)
- }
-}
-
-func (self *Table) Up() {
- self.SelectedRow -= 1
- self.calcPos()
-}
-
-func (self *Table) Down() {
- self.SelectedRow += 1
- self.calcPos()
-}
-
-func (self *Table) Top() {
- self.SelectedRow = 0
- self.calcPos()
-}
-
-func (self *Table) Bottom() {
- self.SelectedRow = len(self.Rows) - 1
- self.calcPos()
-}
-
-// The number of lines in a page is equal to the height of the widgeself.
-
-func (self *Table) HalfPageUp() {
- self.SelectedRow = self.SelectedRow - (self.Y-2)/2
- self.calcPos()
-}
-
-func (self *Table) HalfPageDown() {
- self.SelectedRow = self.SelectedRow + (self.Y-2)/2
- self.calcPos()
-}
-
-func (self *Table) PageUp() {
- self.SelectedRow -= (self.Y - 2)
- self.calcPos()
-}
-
-func (self *Table) PageDown() {
- self.SelectedRow += (self.Y - 2)
- self.calcPos()
-}
-
-func (self *Table) Click(x, y int) {
- x = x - self.XOffset
- y = y - self.YOffset
- if (x > 0 && x <= self.X) && (y > 0 && y <= self.Y) {
- self.SelectedRow = (self.TopRow + y) - 2
- self.calcPos()
- }
-}
diff --git a/vendor/github.com/cjbassi/termui/utils.go b/vendor/github.com/cjbassi/termui/utils.go
deleted file mode 100644
index 614828b..0000000
--- a/vendor/github.com/cjbassi/termui/utils.go
+++ /dev/null
@@ -1,36 +0,0 @@
-package termui
-
-import (
- "fmt"
- "math"
-)
-
-const DOTS = '…'
-
-// MaxString trims a string and adds dots if the string is longer than a give length.
-func MaxString(s string, l int) string {
- if l <= 0 {
- return ""
- }
- r := []rune(s)
- if len(r) > l {
- r = r[:l]
- r[l-1] = DOTS
- }
- return string(r)
-}
-
-func Round(f float64) float64 {
- return math.Floor(f + .5)
-}
-
-func Error(issue, diagnostics string) {
- Close()
- fmt.Println("Error caught. Exiting program.")
- fmt.Println()
- fmt.Println("Issue with " + issue + ".")
- fmt.Println()
- fmt.Println("Diagnostics:\n" + diagnostics)
- fmt.Println()
- panic(1)
-}
diff --git a/vendor/github.com/docopt/docopt-go/.gitignore b/vendor/github.com/docopt/docopt-go/.gitignore
deleted file mode 100644
index 49ad16c..0000000
--- a/vendor/github.com/docopt/docopt-go/.gitignore
+++ /dev/null
@@ -1,25 +0,0 @@
-# Compiled Object files, Static and Dynamic libs (Shared Objects)
-*.o
-*.a
-*.so
-
-# Folders
-_obj
-_test
-
-# Architecture specific extensions/prefixes
-*.[568vq]
-[568vq].out
-
-*.cgo1.go
-*.cgo2.c
-_cgo_defun.c
-_cgo_gotypes.go
-_cgo_export.*
-
-_testmain.go
-
-*.exe
-
-# coverage droppings
-profile.cov
diff --git a/vendor/github.com/docopt/docopt-go/.travis.yml b/vendor/github.com/docopt/docopt-go/.travis.yml
deleted file mode 100644
index db820dc..0000000
--- a/vendor/github.com/docopt/docopt-go/.travis.yml
+++ /dev/null
@@ -1,32 +0,0 @@
-# Travis CI (http://travis-ci.org/) is a continuous integration
-# service for open source projects. This file configures it
-# to run unit tests for docopt-go.
-
-language: go
-
-go:
- - 1.4
- - 1.5
- - 1.6
- - 1.7
- - 1.8
- - 1.9
- - tip
-
-matrix:
- fast_finish: true
-
-before_install:
- - go get golang.org/x/tools/cmd/cover
- - go get github.com/mattn/goveralls
-
-install:
- - go get -d -v ./... && go build -v ./...
-
-script:
- - go vet -x ./...
- - go test -v ./...
- - go test -covermode=count -coverprofile=profile.cov .
-
-after_script:
- - $HOME/gopath/bin/goveralls -coverprofile=profile.cov -service=travis-ci
diff --git a/vendor/github.com/docopt/docopt-go/LICENSE b/vendor/github.com/docopt/docopt-go/LICENSE
deleted file mode 100644
index 5e51f73..0000000
--- a/vendor/github.com/docopt/docopt-go/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) 2013 Keith Batten
-Copyright (c) 2016 David Irvine
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
-the Software, and to permit persons to whom the Software is furnished to do so,
-subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
-FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
-COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/github.com/docopt/docopt-go/README.md b/vendor/github.com/docopt/docopt-go/README.md
deleted file mode 100644
index d03f8da..0000000
--- a/vendor/github.com/docopt/docopt-go/README.md
+++ /dev/null
@@ -1,116 +0,0 @@
-docopt-go
-=========
-
-[](https://travis-ci.org/docopt/docopt.go)
-[](https://coveralls.io/github/docopt/docopt.go)
-[](https://godoc.org/github.com/docopt/docopt.go)
-
-An implementation of [docopt](http://docopt.org/) in the [Go](http://golang.org/) programming language.
-
-**docopt** helps you create *beautiful* command-line interfaces easily:
-
-```go
-package main
-
-import (
- "fmt"
- "github.com/docopt/docopt-go"
-)
-
-func main() {
- usage := `Naval Fate.
-
-Usage:
- naval_fate ship new ...
- naval_fate ship move [--speed=]
- naval_fate ship shoot
- naval_fate mine (set|remove) [--moored|--drifting]
- naval_fate -h | --help
- naval_fate --version
-
-Options:
- -h --help Show this screen.
- --version Show version.
- --speed= Speed in knots [default: 10].
- --moored Moored (anchored) mine.
- --drifting Drifting mine.`
-
- arguments, _ := docopt.ParseDoc(usage)
- fmt.Println(arguments)
-}
-```
-
-**docopt** parses command-line arguments based on a help message. Don't write parser code: a good help message already has all the necessary information in it.
-
-## Installation
-
-⚠ Use the alias "docopt-go". To use docopt in your Go code:
-
-```go
-import "github.com/docopt/docopt-go"
-```
-
-To install docopt in your `$GOPATH`:
-
-```console
-$ go get github.com/docopt/docopt-go
-```
-
-## API
-
-Given a conventional command-line help message, docopt processes the arguments. See https://github.com/docopt/docopt#help-message-format for a description of the help message format.
-
-This package exposes three different APIs, depending on the level of control required. The first, simplest way to parse your docopt usage is to just call:
-
-```go
-docopt.ParseDoc(usage)
-```
-
-This will use `os.Args[1:]` as the argv slice, and use the default parser options. If you want to provide your own version string and args, then use:
-
-```go
-docopt.ParseArgs(usage, argv, "1.2.3")
-```
-
-If the last parameter (version) is a non-empty string, it will be printed when `--version` is given in the argv slice. Finally, we can instantiate our own `docopt.Parser` which gives us control over how things like help messages are printed and whether to exit after displaying usage messages, etc.
-
-```go
-parser := &docopt.Parser{
- HelpHandler: docopt.PrintHelpOnly,
- OptionsFirst: true,
-}
-opts, err := parser.ParseArgs(usage, argv, "")
-```
-
-In particular, setting your own custom `HelpHandler` function makes unit testing your own docs with example command line invocations much more enjoyable.
-
-All three of these return a map of option names to the values parsed from argv, and an error or nil. You can get the values using the helpers, or just treat it as a regular map:
-
-```go
-flag, _ := opts.Bool("--flag")
-secs, _ := opts.Int("")
-```
-
-Additionally, you can `Bind` these to a struct, assigning option values to the
-exported fields of that struct, all at once.
-
-```go
-var config struct {
- Command string `docopt:""`
- Tries int `docopt:"-n"`
- Force bool // Gets the value of --force
-}
-opts.Bind(&config)
-```
-
-More documentation is available at [godoc.org](https://godoc.org/github.com/docopt/docopt-go).
-
-## Unit Testing
-
-Unit testing your own usage docs is recommended, so you can be sure that for a given command line invocation, the expected options are set. An example of how to do this is [in the examples folder](examples/unit_test/unit_test.go).
-
-## Tests
-
-All tests from the Python version are implemented and passing at [Travis CI](https://travis-ci.org/docopt/docopt-go). New language-agnostic tests have been added to [test_golang.docopt](test_golang.docopt).
-
-To run tests for docopt-go, use `go test`.
diff --git a/vendor/github.com/docopt/docopt-go/doc.go b/vendor/github.com/docopt/docopt-go/doc.go
deleted file mode 100644
index c56ee12..0000000
--- a/vendor/github.com/docopt/docopt-go/doc.go
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
-Package docopt parses command-line arguments based on a help message.
-
-Given a conventional command-line help message, docopt processes the arguments.
-See https://github.com/docopt/docopt#help-message-format for a description of
-the help message format.
-
-This package exposes three different APIs, depending on the level of control
-required. The first, simplest way to parse your docopt usage is to just call:
-
- docopt.ParseDoc(usage)
-
-This will use os.Args[1:] as the argv slice, and use the default parser
-options. If you want to provide your own version string and args, then use:
-
- docopt.ParseArgs(usage, argv, "1.2.3")
-
-If the last parameter (version) is a non-empty string, it will be printed when
---version is given in the argv slice. Finally, we can instantiate our own
-docopt.Parser which gives us control over how things like help messages are
-printed and whether to exit after displaying usage messages, etc.
-
- parser := &docopt.Parser{
- HelpHandler: docopt.PrintHelpOnly,
- OptionsFirst: true,
- }
- opts, err := parser.ParseArgs(usage, argv, "")
-
-In particular, setting your own custom HelpHandler function makes unit testing
-your own docs with example command line invocations much more enjoyable.
-
-All three of these return a map of option names to the values parsed from argv,
-and an error or nil. You can get the values using the helpers, or just treat it
-as a regular map:
-
- flag, _ := opts.Bool("--flag")
- secs, _ := opts.Int("")
-
-Additionally, you can `Bind` these to a struct, assigning option values to the
-exported fields of that struct, all at once.
-
- var config struct {
- Command string `docopt:""`
- Tries int `docopt:"-n"`
- Force bool // Gets the value of --force
- }
- opts.Bind(&config)
-*/
-package docopt
diff --git a/vendor/github.com/docopt/docopt-go/docopt.go b/vendor/github.com/docopt/docopt-go/docopt.go
deleted file mode 100644
index c22feb7..0000000
--- a/vendor/github.com/docopt/docopt-go/docopt.go
+++ /dev/null
@@ -1,575 +0,0 @@
-// Licensed under terms of MIT license (see LICENSE-MIT)
-// Copyright (c) 2013 Keith Batten, kbatten@gmail.com
-// Copyright (c) 2016 David Irvine
-
-package docopt
-
-import (
- "fmt"
- "os"
- "regexp"
- "strings"
-)
-
-type Parser struct {
- // HelpHandler is called when we encounter bad user input, or when the user
- // asks for help.
- // By default, this calls os.Exit(0) if it handled a built-in option such
- // as -h, --help or --version. If the user errored with a wrong command or
- // options, we exit with a return code of 1.
- HelpHandler func(err error, usage string)
- // OptionsFirst requires that option flags always come before positional
- // arguments; otherwise they can overlap.
- OptionsFirst bool
- // SkipHelpFlags tells the parser not to look for -h and --help flags and
- // call the HelpHandler.
- SkipHelpFlags bool
-}
-
-var PrintHelpAndExit = func(err error, usage string) {
- if err != nil {
- fmt.Fprintln(os.Stderr, usage)
- os.Exit(1)
- } else {
- fmt.Println(usage)
- os.Exit(0)
- }
-}
-
-var PrintHelpOnly = func(err error, usage string) {
- if err != nil {
- fmt.Fprintln(os.Stderr, usage)
- } else {
- fmt.Println(usage)
- }
-}
-
-var NoHelpHandler = func(err error, usage string) {}
-
-var DefaultParser = &Parser{
- HelpHandler: PrintHelpAndExit,
- OptionsFirst: false,
- SkipHelpFlags: false,
-}
-
-// ParseDoc parses os.Args[1:] based on the interface described in doc, using the default parser options.
-func ParseDoc(doc string) (Opts, error) {
- return ParseArgs(doc, nil, "")
-}
-
-// ParseArgs parses custom arguments based on the interface described in doc. If you provide a non-empty version
-// string, then this will be displayed when the --version flag is found. This method uses the default parser options.
-func ParseArgs(doc string, argv []string, version string) (Opts, error) {
- return DefaultParser.ParseArgs(doc, argv, version)
-}
-
-// ParseArgs parses custom arguments based on the interface described in doc. If you provide a non-empty version
-// string, then this will be displayed when the --version flag is found.
-func (p *Parser) ParseArgs(doc string, argv []string, version string) (Opts, error) {
- return p.parse(doc, argv, version)
-}
-
-// Deprecated: Parse is provided for backward compatibility with the original docopt.go package.
-// Please rather make use of ParseDoc, ParseArgs, or use your own custom Parser.
-func Parse(doc string, argv []string, help bool, version string, optionsFirst bool, exit ...bool) (map[string]interface{}, error) {
- exitOk := true
- if len(exit) > 0 {
- exitOk = exit[0]
- }
- p := &Parser{
- OptionsFirst: optionsFirst,
- SkipHelpFlags: !help,
- }
- if exitOk {
- p.HelpHandler = PrintHelpAndExit
- } else {
- p.HelpHandler = PrintHelpOnly
- }
- return p.parse(doc, argv, version)
-}
-
-func (p *Parser) parse(doc string, argv []string, version string) (map[string]interface{}, error) {
- if argv == nil {
- argv = os.Args[1:]
- }
- if p.HelpHandler == nil {
- p.HelpHandler = DefaultParser.HelpHandler
- }
- args, output, err := parse(doc, argv, !p.SkipHelpFlags, version, p.OptionsFirst)
- if _, ok := err.(*UserError); ok {
- // the user gave us bad input
- p.HelpHandler(err, output)
- } else if len(output) > 0 && err == nil {
- // the user asked for help or --version
- p.HelpHandler(err, output)
- }
- return args, err
-}
-
-// -----------------------------------------------------------------------------
-
-// parse and return a map of args, output and all errors
-func parse(doc string, argv []string, help bool, version string, optionsFirst bool) (args map[string]interface{}, output string, err error) {
- if argv == nil && len(os.Args) > 1 {
- argv = os.Args[1:]
- }
-
- usageSections := parseSection("usage:", doc)
-
- if len(usageSections) == 0 {
- err = newLanguageError("\"usage:\" (case-insensitive) not found.")
- return
- }
- if len(usageSections) > 1 {
- err = newLanguageError("More than one \"usage:\" (case-insensitive).")
- return
- }
- usage := usageSections[0]
-
- options := parseDefaults(doc)
- formal, err := formalUsage(usage)
- if err != nil {
- output = handleError(err, usage)
- return
- }
-
- pat, err := parsePattern(formal, &options)
- if err != nil {
- output = handleError(err, usage)
- return
- }
-
- patternArgv, err := parseArgv(newTokenList(argv, errorUser), &options, optionsFirst)
- if err != nil {
- output = handleError(err, usage)
- return
- }
- patFlat, err := pat.flat(patternOption)
- if err != nil {
- output = handleError(err, usage)
- return
- }
- patternOptions := patFlat.unique()
-
- patFlat, err = pat.flat(patternOptionSSHORTCUT)
- if err != nil {
- output = handleError(err, usage)
- return
- }
- for _, optionsShortcut := range patFlat {
- docOptions := parseDefaults(doc)
- optionsShortcut.children = docOptions.unique().diff(patternOptions)
- }
-
- if output = extras(help, version, patternArgv, doc); len(output) > 0 {
- return
- }
-
- err = pat.fix()
- if err != nil {
- output = handleError(err, usage)
- return
- }
- matched, left, collected := pat.match(&patternArgv, nil)
- if matched && len(*left) == 0 {
- patFlat, err = pat.flat(patternDefault)
- if err != nil {
- output = handleError(err, usage)
- return
- }
- args = append(patFlat, *collected...).dictionary()
- return
- }
-
- err = newUserError("")
- output = handleError(err, usage)
- return
-}
-
-func handleError(err error, usage string) string {
- if _, ok := err.(*UserError); ok {
- return strings.TrimSpace(fmt.Sprintf("%s\n%s", err, usage))
- }
- return ""
-}
-
-func parseSection(name, source string) []string {
- p := regexp.MustCompile(`(?im)^([^\n]*` + name + `[^\n]*\n?(?:[ \t].*?(?:\n|$))*)`)
- s := p.FindAllString(source, -1)
- if s == nil {
- s = []string{}
- }
- for i, v := range s {
- s[i] = strings.TrimSpace(v)
- }
- return s
-}
-
-func parseDefaults(doc string) patternList {
- defaults := patternList{}
- p := regexp.MustCompile(`\n[ \t]*(-\S+?)`)
- for _, s := range parseSection("options:", doc) {
- // FIXME corner case "bla: options: --foo"
- _, _, s = stringPartition(s, ":") // get rid of "options:"
- split := p.Split("\n"+s, -1)[1:]
- match := p.FindAllStringSubmatch("\n"+s, -1)
- for i := range split {
- optionDescription := match[i][1] + split[i]
- if strings.HasPrefix(optionDescription, "-") {
- defaults = append(defaults, parseOption(optionDescription))
- }
- }
- }
- return defaults
-}
-
-func parsePattern(source string, options *patternList) (*pattern, error) {
- tokens := tokenListFromPattern(source)
- result, err := parseExpr(tokens, options)
- if err != nil {
- return nil, err
- }
- if tokens.current() != nil {
- return nil, tokens.errorFunc("unexpected ending: %s" + strings.Join(tokens.tokens, " "))
- }
- return newRequired(result...), nil
-}
-
-func parseArgv(tokens *tokenList, options *patternList, optionsFirst bool) (patternList, error) {
- /*
- Parse command-line argument vector.
-
- If options_first:
- argv ::= [ long | shorts ]* [ argument ]* [ '--' [ argument ]* ] ;
- else:
- argv ::= [ long | shorts | argument ]* [ '--' [ argument ]* ] ;
- */
- parsed := patternList{}
- for tokens.current() != nil {
- if tokens.current().eq("--") {
- for _, v := range tokens.tokens {
- parsed = append(parsed, newArgument("", v))
- }
- return parsed, nil
- } else if tokens.current().hasPrefix("--") {
- pl, err := parseLong(tokens, options)
- if err != nil {
- return nil, err
- }
- parsed = append(parsed, pl...)
- } else if tokens.current().hasPrefix("-") && !tokens.current().eq("-") {
- ps, err := parseShorts(tokens, options)
- if err != nil {
- return nil, err
- }
- parsed = append(parsed, ps...)
- } else if optionsFirst {
- for _, v := range tokens.tokens {
- parsed = append(parsed, newArgument("", v))
- }
- return parsed, nil
- } else {
- parsed = append(parsed, newArgument("", tokens.move().String()))
- }
- }
- return parsed, nil
-}
-
-func parseOption(optionDescription string) *pattern {
- optionDescription = strings.TrimSpace(optionDescription)
- options, _, description := stringPartition(optionDescription, " ")
- options = strings.Replace(options, ",", " ", -1)
- options = strings.Replace(options, "=", " ", -1)
-
- short := ""
- long := ""
- argcount := 0
- var value interface{}
- value = false
-
- reDefault := regexp.MustCompile(`(?i)\[default: (.*)\]`)
- for _, s := range strings.Fields(options) {
- if strings.HasPrefix(s, "--") {
- long = s
- } else if strings.HasPrefix(s, "-") {
- short = s
- } else {
- argcount = 1
- }
- if argcount > 0 {
- matched := reDefault.FindAllStringSubmatch(description, -1)
- if len(matched) > 0 {
- value = matched[0][1]
- } else {
- value = nil
- }
- }
- }
- return newOption(short, long, argcount, value)
-}
-
-func parseExpr(tokens *tokenList, options *patternList) (patternList, error) {
- // expr ::= seq ( '|' seq )* ;
- seq, err := parseSeq(tokens, options)
- if err != nil {
- return nil, err
- }
- if !tokens.current().eq("|") {
- return seq, nil
- }
- var result patternList
- if len(seq) > 1 {
- result = patternList{newRequired(seq...)}
- } else {
- result = seq
- }
- for tokens.current().eq("|") {
- tokens.move()
- seq, err = parseSeq(tokens, options)
- if err != nil {
- return nil, err
- }
- if len(seq) > 1 {
- result = append(result, newRequired(seq...))
- } else {
- result = append(result, seq...)
- }
- }
- if len(result) > 1 {
- return patternList{newEither(result...)}, nil
- }
- return result, nil
-}
-
-func parseSeq(tokens *tokenList, options *patternList) (patternList, error) {
- // seq ::= ( atom [ '...' ] )* ;
- result := patternList{}
- for !tokens.current().match(true, "]", ")", "|") {
- atom, err := parseAtom(tokens, options)
- if err != nil {
- return nil, err
- }
- if tokens.current().eq("...") {
- atom = patternList{newOneOrMore(atom...)}
- tokens.move()
- }
- result = append(result, atom...)
- }
- return result, nil
-}
-
-func parseAtom(tokens *tokenList, options *patternList) (patternList, error) {
- // atom ::= '(' expr ')' | '[' expr ']' | 'options' | long | shorts | argument | command ;
- tok := tokens.current()
- result := patternList{}
- if tokens.current().match(false, "(", "[") {
- tokens.move()
- var matching string
- pl, err := parseExpr(tokens, options)
- if err != nil {
- return nil, err
- }
- if tok.eq("(") {
- matching = ")"
- result = patternList{newRequired(pl...)}
- } else if tok.eq("[") {
- matching = "]"
- result = patternList{newOptional(pl...)}
- }
- moved := tokens.move()
- if !moved.eq(matching) {
- return nil, tokens.errorFunc("unmatched '%s', expected: '%s' got: '%s'", tok, matching, moved)
- }
- return result, nil
- } else if tok.eq("options") {
- tokens.move()
- return patternList{newOptionsShortcut()}, nil
- } else if tok.hasPrefix("--") && !tok.eq("--") {
- return parseLong(tokens, options)
- } else if tok.hasPrefix("-") && !tok.eq("-") && !tok.eq("--") {
- return parseShorts(tokens, options)
- } else if tok.hasPrefix("<") && tok.hasSuffix(">") || tok.isUpper() {
- return patternList{newArgument(tokens.move().String(), nil)}, nil
- }
- return patternList{newCommand(tokens.move().String(), false)}, nil
-}
-
-func parseLong(tokens *tokenList, options *patternList) (patternList, error) {
- // long ::= '--' chars [ ( ' ' | '=' ) chars ] ;
- long, eq, v := stringPartition(tokens.move().String(), "=")
- var value interface{}
- var opt *pattern
- if eq == "" && v == "" {
- value = nil
- } else {
- value = v
- }
-
- if !strings.HasPrefix(long, "--") {
- return nil, newError("long option '%s' doesn't start with --", long)
- }
- similar := patternList{}
- for _, o := range *options {
- if o.long == long {
- similar = append(similar, o)
- }
- }
- if tokens.err == errorUser && len(similar) == 0 { // if no exact match
- similar = patternList{}
- for _, o := range *options {
- if strings.HasPrefix(o.long, long) {
- similar = append(similar, o)
- }
- }
- }
- if len(similar) > 1 { // might be simply specified ambiguously 2+ times?
- similarLong := make([]string, len(similar))
- for i, s := range similar {
- similarLong[i] = s.long
- }
- return nil, tokens.errorFunc("%s is not a unique prefix: %s?", long, strings.Join(similarLong, ", "))
- } else if len(similar) < 1 {
- argcount := 0
- if eq == "=" {
- argcount = 1
- }
- opt = newOption("", long, argcount, false)
- *options = append(*options, opt)
- if tokens.err == errorUser {
- var val interface{}
- if argcount > 0 {
- val = value
- } else {
- val = true
- }
- opt = newOption("", long, argcount, val)
- }
- } else {
- opt = newOption(similar[0].short, similar[0].long, similar[0].argcount, similar[0].value)
- if opt.argcount == 0 {
- if value != nil {
- return nil, tokens.errorFunc("%s must not have an argument", opt.long)
- }
- } else {
- if value == nil {
- if tokens.current().match(true, "--") {
- return nil, tokens.errorFunc("%s requires argument", opt.long)
- }
- moved := tokens.move()
- if moved != nil {
- value = moved.String() // only set as string if not nil
- }
- }
- }
- if tokens.err == errorUser {
- if value != nil {
- opt.value = value
- } else {
- opt.value = true
- }
- }
- }
-
- return patternList{opt}, nil
-}
-
-func parseShorts(tokens *tokenList, options *patternList) (patternList, error) {
- // shorts ::= '-' ( chars )* [ [ ' ' ] chars ] ;
- tok := tokens.move()
- if !tok.hasPrefix("-") || tok.hasPrefix("--") {
- return nil, newError("short option '%s' doesn't start with -", tok)
- }
- left := strings.TrimLeft(tok.String(), "-")
- parsed := patternList{}
- for left != "" {
- var opt *pattern
- short := "-" + left[0:1]
- left = left[1:]
- similar := patternList{}
- for _, o := range *options {
- if o.short == short {
- similar = append(similar, o)
- }
- }
- if len(similar) > 1 {
- return nil, tokens.errorFunc("%s is specified ambiguously %d times", short, len(similar))
- } else if len(similar) < 1 {
- opt = newOption(short, "", 0, false)
- *options = append(*options, opt)
- if tokens.err == errorUser {
- opt = newOption(short, "", 0, true)
- }
- } else { // why copying is necessary here?
- opt = newOption(short, similar[0].long, similar[0].argcount, similar[0].value)
- var value interface{}
- if opt.argcount > 0 {
- if left == "" {
- if tokens.current().match(true, "--") {
- return nil, tokens.errorFunc("%s requires argument", short)
- }
- value = tokens.move().String()
- } else {
- value = left
- left = ""
- }
- }
- if tokens.err == errorUser {
- if value != nil {
- opt.value = value
- } else {
- opt.value = true
- }
- }
- }
- parsed = append(parsed, opt)
- }
- return parsed, nil
-}
-
-func formalUsage(section string) (string, error) {
- _, _, section = stringPartition(section, ":") // drop "usage:"
- pu := strings.Fields(section)
-
- if len(pu) == 0 {
- return "", newLanguageError("no fields found in usage (perhaps a spacing error).")
- }
-
- result := "( "
- for _, s := range pu[1:] {
- if s == pu[0] {
- result += ") | ( "
- } else {
- result += s + " "
- }
- }
- result += ")"
-
- return result, nil
-}
-
-func extras(help bool, version string, options patternList, doc string) string {
- if help {
- for _, o := range options {
- if (o.name == "-h" || o.name == "--help") && o.value == true {
- return strings.Trim(doc, "\n")
- }
- }
- }
- if version != "" {
- for _, o := range options {
- if (o.name == "--version") && o.value == true {
- return version
- }
- }
- }
- return ""
-}
-
-func stringPartition(s, sep string) (string, string, string) {
- sepPos := strings.Index(s, sep)
- if sepPos == -1 { // no seperator found
- return s, "", ""
- }
- split := strings.SplitN(s, sep, 2)
- return split[0], sep, split[1]
-}
diff --git a/vendor/github.com/docopt/docopt-go/error.go b/vendor/github.com/docopt/docopt-go/error.go
deleted file mode 100644
index bd26460..0000000
--- a/vendor/github.com/docopt/docopt-go/error.go
+++ /dev/null
@@ -1,49 +0,0 @@
-package docopt
-
-import (
- "fmt"
-)
-
-type errorType int
-
-const (
- errorUser errorType = iota
- errorLanguage
-)
-
-func (e errorType) String() string {
- switch e {
- case errorUser:
- return "errorUser"
- case errorLanguage:
- return "errorLanguage"
- }
- return ""
-}
-
-// UserError records an error with program arguments.
-type UserError struct {
- msg string
- Usage string
-}
-
-func (e UserError) Error() string {
- return e.msg
-}
-func newUserError(msg string, f ...interface{}) error {
- return &UserError{fmt.Sprintf(msg, f...), ""}
-}
-
-// LanguageError records an error with the doc string.
-type LanguageError struct {
- msg string
-}
-
-func (e LanguageError) Error() string {
- return e.msg
-}
-func newLanguageError(msg string, f ...interface{}) error {
- return &LanguageError{fmt.Sprintf(msg, f...)}
-}
-
-var newError = fmt.Errorf
diff --git a/vendor/github.com/docopt/docopt-go/opts.go b/vendor/github.com/docopt/docopt-go/opts.go
deleted file mode 100644
index 36320fb..0000000
--- a/vendor/github.com/docopt/docopt-go/opts.go
+++ /dev/null
@@ -1,264 +0,0 @@
-package docopt
-
-import (
- "fmt"
- "reflect"
- "strconv"
- "strings"
- "unicode"
-)
-
-func errKey(key string) error {
- return fmt.Errorf("no such key: %q", key)
-}
-func errType(key string) error {
- return fmt.Errorf("key: %q failed type conversion", key)
-}
-func errStrconv(key string, convErr error) error {
- return fmt.Errorf("key: %q failed type conversion: %s", key, convErr)
-}
-
-// Opts is a map of command line options to their values, with some convenience
-// methods for value type conversion (bool, float64, int, string). For example,
-// to get an option value as an int:
-//
-// opts, _ := docopt.ParseDoc("Usage: sleep ")
-// secs, _ := opts.Int("")
-//
-// Additionally, Opts.Bind allows you easily populate a struct's fields with the
-// values of each option value. See below for examples.
-//
-// Lastly, you can still treat Opts as a regular map, and do any type checking
-// and conversion that you want to yourself. For example:
-//
-// if s, ok := opts[""].(string); ok {
-// if val, err := strconv.ParseUint(s, 2, 64); err != nil { ... }
-// }
-//
-// Note that any non-boolean option / flag will have a string value in the
-// underlying map.
-type Opts map[string]interface{}
-
-func (o Opts) String(key string) (s string, err error) {
- v, ok := o[key]
- if !ok {
- err = errKey(key)
- return
- }
- s, ok = v.(string)
- if !ok {
- err = errType(key)
- }
- return
-}
-
-func (o Opts) Bool(key string) (b bool, err error) {
- v, ok := o[key]
- if !ok {
- err = errKey(key)
- return
- }
- b, ok = v.(bool)
- if !ok {
- err = errType(key)
- }
- return
-}
-
-func (o Opts) Int(key string) (i int, err error) {
- s, err := o.String(key)
- if err != nil {
- return
- }
- i, err = strconv.Atoi(s)
- if err != nil {
- err = errStrconv(key, err)
- }
- return
-}
-
-func (o Opts) Float64(key string) (f float64, err error) {
- s, err := o.String(key)
- if err != nil {
- return
- }
- f, err = strconv.ParseFloat(s, 64)
- if err != nil {
- err = errStrconv(key, err)
- }
- return
-}
-
-// Bind populates the fields of a given struct with matching option values.
-// Each key in Opts will be mapped to an exported field of the struct pointed
-// to by `v`, as follows:
-//
-// abc int // Unexported field, ignored
-// Abc string // Mapped from `--abc`, ``, or `abc`
-// // (case insensitive)
-// A string // Mapped from `-a`, `` or `a`
-// // (case insensitive)
-// Abc int `docopt:"XYZ"` // Mapped from `XYZ`
-// Abc bool `docopt:"-"` // Mapped from `-`
-// Abc bool `docopt:"-x,--xyz"` // Mapped from `-x` or `--xyz`
-// // (first non-zero value found)
-//
-// Tagged (annotated) fields will always be mapped first. If no field is tagged
-// with an option's key, Bind will try to map the option to an appropriately
-// named field (as above).
-//
-// Bind also handles conversion to bool, float, int or string types.
-func (o Opts) Bind(v interface{}) error {
- structVal := reflect.ValueOf(v)
- if structVal.Kind() != reflect.Ptr {
- return newError("'v' argument is not pointer to struct type")
- }
- for structVal.Kind() == reflect.Ptr {
- structVal = structVal.Elem()
- }
- if structVal.Kind() != reflect.Struct {
- return newError("'v' argument is not pointer to struct type")
- }
- structType := structVal.Type()
-
- tagged := make(map[string]int) // Tagged field tags
- untagged := make(map[string]int) // Untagged field names
-
- for i := 0; i < structType.NumField(); i++ {
- field := structType.Field(i)
- if isUnexportedField(field) || field.Anonymous {
- continue
- }
- tag := field.Tag.Get("docopt")
- if tag == "" {
- untagged[field.Name] = i
- continue
- }
- for _, t := range strings.Split(tag, ",") {
- tagged[t] = i
- }
- }
-
- // Get the index of the struct field to use, based on the option key.
- // Second argument is true/false on whether something was matched.
- getFieldIndex := func(key string) (int, bool) {
- if i, ok := tagged[key]; ok {
- return i, true
- }
- if i, ok := untagged[guessUntaggedField(key)]; ok {
- return i, true
- }
- return -1, false
- }
-
- indexMap := make(map[string]int) // Option keys to field index
-
- // Pre-check that option keys are mapped to fields and fields are zero valued, before populating them.
- for k := range o {
- i, ok := getFieldIndex(k)
- if !ok {
- if k == "--help" || k == "--version" { // Don't require these to be mapped.
- continue
- }
- return newError("mapping of %q is not found in given struct, or is an unexported field", k)
- }
- fieldVal := structVal.Field(i)
- zeroVal := reflect.Zero(fieldVal.Type())
- if !reflect.DeepEqual(fieldVal.Interface(), zeroVal.Interface()) {
- return newError("%q field is non-zero, will be overwritten by value of %q", structType.Field(i).Name, k)
- }
- indexMap[k] = i
- }
-
- // Populate fields with option values.
- for k, v := range o {
- i, ok := indexMap[k]
- if !ok {
- continue // Not mapped.
- }
- field := structVal.Field(i)
- if !reflect.DeepEqual(field.Interface(), reflect.Zero(field.Type()).Interface()) {
- // The struct's field is already non-zero (by our doing), so don't change it.
- // This happens with comma separated tags, e.g. `docopt:"-h,--help"` which is a
- // convenient way of checking if one of multiple boolean flags are set.
- continue
- }
- optVal := reflect.ValueOf(v)
- // Option value is the zero Value, so we can't get its .Type(). No need to assign anyway, so move along.
- if !optVal.IsValid() {
- continue
- }
- if !field.CanSet() {
- return newError("%q field cannot be set", structType.Field(i).Name)
- }
- // Try to assign now if able. bool and string values should be assignable already.
- if optVal.Type().AssignableTo(field.Type()) {
- field.Set(optVal)
- continue
- }
- // Try to convert the value and assign if able.
- switch field.Kind() {
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- if x, err := o.Int(k); err == nil {
- field.SetInt(int64(x))
- continue
- }
- case reflect.Float32, reflect.Float64:
- if x, err := o.Float64(k); err == nil {
- field.SetFloat(x)
- continue
- }
- }
- // TODO: Something clever (recursive?) with non-string slices.
- // case reflect.Slice:
- // if optVal.Kind() == reflect.Slice {
- // for i := 0; i < optVal.Len(); i++ {
- // sliceVal := optVal.Index(i)
- // fmt.Printf("%v", sliceVal)
- // }
- // fmt.Printf("\n")
- // }
- return newError("value of %q is not assignable to %q field", k, structType.Field(i).Name)
- }
-
- return nil
-}
-
-// isUnexportedField returns whether the field is unexported.
-// isUnexportedField is to avoid the bug in versions older than Go1.3.
-// See following links:
-// https://code.google.com/p/go/issues/detail?id=7247
-// http://golang.org/ref/spec#Exported_identifiers
-func isUnexportedField(field reflect.StructField) bool {
- return !(field.PkgPath == "" && unicode.IsUpper(rune(field.Name[0])))
-}
-
-// Convert a string like "--my-special-flag" to "MySpecialFlag".
-func titleCaseDashes(key string) string {
- nextToUpper := true
- mapFn := func(r rune) rune {
- if r == '-' {
- nextToUpper = true
- return -1
- }
- if nextToUpper {
- nextToUpper = false
- return unicode.ToUpper(r)
- }
- return r
- }
- return strings.Map(mapFn, key)
-}
-
-// Best guess which field.Name in a struct to assign for an option key.
-func guessUntaggedField(key string) string {
- switch {
- case strings.HasPrefix(key, "--") && len(key[2:]) > 1:
- return titleCaseDashes(key[2:])
- case strings.HasPrefix(key, "-") && len(key[1:]) == 1:
- return titleCaseDashes(key[1:])
- case strings.HasPrefix(key, "<") && strings.HasSuffix(key, ">"):
- key = key[1 : len(key)-1]
- }
- return strings.Title(strings.ToLower(key))
-}
diff --git a/vendor/github.com/docopt/docopt-go/pattern.go b/vendor/github.com/docopt/docopt-go/pattern.go
deleted file mode 100644
index 0a29667..0000000
--- a/vendor/github.com/docopt/docopt-go/pattern.go
+++ /dev/null
@@ -1,550 +0,0 @@
-package docopt
-
-import (
- "fmt"
- "reflect"
- "strings"
-)
-
-type patternType uint
-
-const (
- // leaf
- patternArgument patternType = 1 << iota
- patternCommand
- patternOption
-
- // branch
- patternRequired
- patternOptionAL
- patternOptionSSHORTCUT // Marker/placeholder for [options] shortcut.
- patternOneOrMore
- patternEither
-
- patternLeaf = patternArgument +
- patternCommand +
- patternOption
- patternBranch = patternRequired +
- patternOptionAL +
- patternOptionSSHORTCUT +
- patternOneOrMore +
- patternEither
- patternAll = patternLeaf + patternBranch
- patternDefault = 0
-)
-
-func (pt patternType) String() string {
- switch pt {
- case patternArgument:
- return "argument"
- case patternCommand:
- return "command"
- case patternOption:
- return "option"
- case patternRequired:
- return "required"
- case patternOptionAL:
- return "optional"
- case patternOptionSSHORTCUT:
- return "optionsshortcut"
- case patternOneOrMore:
- return "oneormore"
- case patternEither:
- return "either"
- case patternLeaf:
- return "leaf"
- case patternBranch:
- return "branch"
- case patternAll:
- return "all"
- case patternDefault:
- return "default"
- }
- return ""
-}
-
-type pattern struct {
- t patternType
-
- children patternList
-
- name string
- value interface{}
-
- short string
- long string
- argcount int
-}
-
-type patternList []*pattern
-
-func newBranchPattern(t patternType, pl ...*pattern) *pattern {
- var p pattern
- p.t = t
- p.children = make(patternList, len(pl))
- copy(p.children, pl)
- return &p
-}
-
-func newRequired(pl ...*pattern) *pattern {
- return newBranchPattern(patternRequired, pl...)
-}
-
-func newEither(pl ...*pattern) *pattern {
- return newBranchPattern(patternEither, pl...)
-}
-
-func newOneOrMore(pl ...*pattern) *pattern {
- return newBranchPattern(patternOneOrMore, pl...)
-}
-
-func newOptional(pl ...*pattern) *pattern {
- return newBranchPattern(patternOptionAL, pl...)
-}
-
-func newOptionsShortcut() *pattern {
- var p pattern
- p.t = patternOptionSSHORTCUT
- return &p
-}
-
-func newLeafPattern(t patternType, name string, value interface{}) *pattern {
- // default: value=nil
- var p pattern
- p.t = t
- p.name = name
- p.value = value
- return &p
-}
-
-func newArgument(name string, value interface{}) *pattern {
- // default: value=nil
- return newLeafPattern(patternArgument, name, value)
-}
-
-func newCommand(name string, value interface{}) *pattern {
- // default: value=false
- var p pattern
- p.t = patternCommand
- p.name = name
- p.value = value
- return &p
-}
-
-func newOption(short, long string, argcount int, value interface{}) *pattern {
- // default: "", "", 0, false
- var p pattern
- p.t = patternOption
- p.short = short
- p.long = long
- if long != "" {
- p.name = long
- } else {
- p.name = short
- }
- p.argcount = argcount
- if value == false && argcount > 0 {
- p.value = nil
- } else {
- p.value = value
- }
- return &p
-}
-
-func (p *pattern) flat(types patternType) (patternList, error) {
- if p.t&patternLeaf != 0 {
- if types == patternDefault {
- types = patternAll
- }
- if p.t&types != 0 {
- return patternList{p}, nil
- }
- return patternList{}, nil
- }
-
- if p.t&patternBranch != 0 {
- if p.t&types != 0 {
- return patternList{p}, nil
- }
- result := patternList{}
- for _, child := range p.children {
- childFlat, err := child.flat(types)
- if err != nil {
- return nil, err
- }
- result = append(result, childFlat...)
- }
- return result, nil
- }
- return nil, newError("unknown pattern type: %d, %d", p.t, types)
-}
-
-func (p *pattern) fix() error {
- err := p.fixIdentities(nil)
- if err != nil {
- return err
- }
- p.fixRepeatingArguments()
- return nil
-}
-
-func (p *pattern) fixIdentities(uniq patternList) error {
- // Make pattern-tree tips point to same object if they are equal.
- if p.t&patternBranch == 0 {
- return nil
- }
- if uniq == nil {
- pFlat, err := p.flat(patternDefault)
- if err != nil {
- return err
- }
- uniq = pFlat.unique()
- }
- for i, child := range p.children {
- if child.t&patternBranch == 0 {
- ind, err := uniq.index(child)
- if err != nil {
- return err
- }
- p.children[i] = uniq[ind]
- } else {
- err := child.fixIdentities(uniq)
- if err != nil {
- return err
- }
- }
- }
- return nil
-}
-
-func (p *pattern) fixRepeatingArguments() {
- // Fix elements that should accumulate/increment values.
- var either []patternList
-
- for _, child := range p.transform().children {
- either = append(either, child.children)
- }
- for _, cas := range either {
- casMultiple := patternList{}
- for _, e := range cas {
- if cas.count(e) > 1 {
- casMultiple = append(casMultiple, e)
- }
- }
- for _, e := range casMultiple {
- if e.t == patternArgument || e.t == patternOption && e.argcount > 0 {
- switch e.value.(type) {
- case string:
- e.value = strings.Fields(e.value.(string))
- case []string:
- default:
- e.value = []string{}
- }
- }
- if e.t == patternCommand || e.t == patternOption && e.argcount == 0 {
- e.value = 0
- }
- }
- }
-}
-
-func (p *pattern) match(left *patternList, collected *patternList) (bool, *patternList, *patternList) {
- if collected == nil {
- collected = &patternList{}
- }
- if p.t&patternRequired != 0 {
- l := left
- c := collected
- for _, p := range p.children {
- var matched bool
- matched, l, c = p.match(l, c)
- if !matched {
- return false, left, collected
- }
- }
- return true, l, c
- } else if p.t&patternOptionAL != 0 || p.t&patternOptionSSHORTCUT != 0 {
- for _, p := range p.children {
- _, left, collected = p.match(left, collected)
- }
- return true, left, collected
- } else if p.t&patternOneOrMore != 0 {
- if len(p.children) != 1 {
- panic("OneOrMore.match(): assert len(p.children) == 1")
- }
- l := left
- c := collected
- var lAlt *patternList
- matched := true
- times := 0
- for matched {
- // could it be that something didn't match but changed l or c?
- matched, l, c = p.children[0].match(l, c)
- if matched {
- times++
- }
- if lAlt == l {
- break
- }
- lAlt = l
- }
- if times >= 1 {
- return true, l, c
- }
- return false, left, collected
- } else if p.t&patternEither != 0 {
- type outcomeStruct struct {
- matched bool
- left *patternList
- collected *patternList
- length int
- }
- outcomes := []outcomeStruct{}
- for _, p := range p.children {
- matched, l, c := p.match(left, collected)
- outcome := outcomeStruct{matched, l, c, len(*l)}
- if matched {
- outcomes = append(outcomes, outcome)
- }
- }
- if len(outcomes) > 0 {
- minLen := outcomes[0].length
- minIndex := 0
- for i, v := range outcomes {
- if v.length < minLen {
- minIndex = i
- }
- }
- return outcomes[minIndex].matched, outcomes[minIndex].left, outcomes[minIndex].collected
- }
- return false, left, collected
- } else if p.t&patternLeaf != 0 {
- pos, match := p.singleMatch(left)
- var increment interface{}
- if match == nil {
- return false, left, collected
- }
- leftAlt := make(patternList, len((*left)[:pos]), len((*left)[:pos])+len((*left)[pos+1:]))
- copy(leftAlt, (*left)[:pos])
- leftAlt = append(leftAlt, (*left)[pos+1:]...)
- sameName := patternList{}
- for _, a := range *collected {
- if a.name == p.name {
- sameName = append(sameName, a)
- }
- }
-
- switch p.value.(type) {
- case int, []string:
- switch p.value.(type) {
- case int:
- increment = 1
- case []string:
- switch match.value.(type) {
- case string:
- increment = []string{match.value.(string)}
- default:
- increment = match.value
- }
- }
- if len(sameName) == 0 {
- match.value = increment
- collectedMatch := make(patternList, len(*collected), len(*collected)+1)
- copy(collectedMatch, *collected)
- collectedMatch = append(collectedMatch, match)
- return true, &leftAlt, &collectedMatch
- }
- switch sameName[0].value.(type) {
- case int:
- sameName[0].value = sameName[0].value.(int) + increment.(int)
- case []string:
- sameName[0].value = append(sameName[0].value.([]string), increment.([]string)...)
- }
- return true, &leftAlt, collected
- }
- collectedMatch := make(patternList, len(*collected), len(*collected)+1)
- copy(collectedMatch, *collected)
- collectedMatch = append(collectedMatch, match)
- return true, &leftAlt, &collectedMatch
- }
- panic("unmatched type")
-}
-
-func (p *pattern) singleMatch(left *patternList) (int, *pattern) {
- if p.t&patternArgument != 0 {
- for n, pat := range *left {
- if pat.t&patternArgument != 0 {
- return n, newArgument(p.name, pat.value)
- }
- }
- return -1, nil
- } else if p.t&patternCommand != 0 {
- for n, pat := range *left {
- if pat.t&patternArgument != 0 {
- if pat.value == p.name {
- return n, newCommand(p.name, true)
- }
- break
- }
- }
- return -1, nil
- } else if p.t&patternOption != 0 {
- for n, pat := range *left {
- if p.name == pat.name {
- return n, pat
- }
- }
- return -1, nil
- }
- panic("unmatched type")
-}
-
-func (p *pattern) String() string {
- if p.t&patternOption != 0 {
- return fmt.Sprintf("%s(%s, %s, %d, %+v)", p.t, p.short, p.long, p.argcount, p.value)
- } else if p.t&patternLeaf != 0 {
- return fmt.Sprintf("%s(%s, %+v)", p.t, p.name, p.value)
- } else if p.t&patternBranch != 0 {
- result := ""
- for i, child := range p.children {
- if i > 0 {
- result += ", "
- }
- result += child.String()
- }
- return fmt.Sprintf("%s(%s)", p.t, result)
- }
- panic("unmatched type")
-}
-
-func (p *pattern) transform() *pattern {
- /*
- Expand pattern into an (almost) equivalent one, but with single Either.
-
- Example: ((-a | -b) (-c | -d)) => (-a -c | -a -d | -b -c | -b -d)
- Quirks: [-a] => (-a), (-a...) => (-a -a)
- */
- result := []patternList{}
- groups := []patternList{patternList{p}}
- parents := patternRequired +
- patternOptionAL +
- patternOptionSSHORTCUT +
- patternEither +
- patternOneOrMore
- for len(groups) > 0 {
- children := groups[0]
- groups = groups[1:]
- var child *pattern
- for _, c := range children {
- if c.t&parents != 0 {
- child = c
- break
- }
- }
- if child != nil {
- children.remove(child)
- if child.t&patternEither != 0 {
- for _, c := range child.children {
- r := patternList{}
- r = append(r, c)
- r = append(r, children...)
- groups = append(groups, r)
- }
- } else if child.t&patternOneOrMore != 0 {
- r := patternList{}
- r = append(r, child.children.double()...)
- r = append(r, children...)
- groups = append(groups, r)
- } else {
- r := patternList{}
- r = append(r, child.children...)
- r = append(r, children...)
- groups = append(groups, r)
- }
- } else {
- result = append(result, children)
- }
- }
- either := patternList{}
- for _, e := range result {
- either = append(either, newRequired(e...))
- }
- return newEither(either...)
-}
-
-func (p *pattern) eq(other *pattern) bool {
- return reflect.DeepEqual(p, other)
-}
-
-func (pl patternList) unique() patternList {
- table := make(map[string]bool)
- result := patternList{}
- for _, v := range pl {
- if !table[v.String()] {
- table[v.String()] = true
- result = append(result, v)
- }
- }
- return result
-}
-
-func (pl patternList) index(p *pattern) (int, error) {
- for i, c := range pl {
- if c.eq(p) {
- return i, nil
- }
- }
- return -1, newError("%s not in list", p)
-}
-
-func (pl patternList) count(p *pattern) int {
- count := 0
- for _, c := range pl {
- if c.eq(p) {
- count++
- }
- }
- return count
-}
-
-func (pl patternList) diff(l patternList) patternList {
- lAlt := make(patternList, len(l))
- copy(lAlt, l)
- result := make(patternList, 0, len(pl))
- for _, v := range pl {
- if v != nil {
- match := false
- for i, w := range lAlt {
- if w.eq(v) {
- match = true
- lAlt[i] = nil
- break
- }
- }
- if match == false {
- result = append(result, v)
- }
- }
- }
- return result
-}
-
-func (pl patternList) double() patternList {
- l := len(pl)
- result := make(patternList, l*2)
- copy(result, pl)
- copy(result[l:2*l], pl)
- return result
-}
-
-func (pl *patternList) remove(p *pattern) {
- (*pl) = pl.diff(patternList{p})
-}
-
-func (pl patternList) dictionary() map[string]interface{} {
- dict := make(map[string]interface{})
- for _, a := range pl {
- dict[a.name] = a.value
- }
- return dict
-}
diff --git a/vendor/github.com/docopt/docopt-go/test_golang.docopt b/vendor/github.com/docopt/docopt-go/test_golang.docopt
deleted file mode 100644
index 323fd67..0000000
--- a/vendor/github.com/docopt/docopt-go/test_golang.docopt
+++ /dev/null
@@ -1,9 +0,0 @@
-r"""usage: prog [NAME_-2]..."""
-$ prog 10 20
-{"NAME_-2": ["10", "20"]}
-
-$ prog 10
-{"NAME_-2": ["10"]}
-
-$ prog
-{"NAME_-2": []}
diff --git a/vendor/github.com/docopt/docopt-go/testcases.docopt b/vendor/github.com/docopt/docopt-go/testcases.docopt
deleted file mode 100644
index efe9a07..0000000
--- a/vendor/github.com/docopt/docopt-go/testcases.docopt
+++ /dev/null
@@ -1,957 +0,0 @@
-r"""Usage: prog
-
-"""
-$ prog
-{}
-
-$ prog --xxx
-"user-error"
-
-
-r"""Usage: prog [options]
-
-Options: -a All.
-
-"""
-$ prog
-{"-a": false}
-
-$ prog -a
-{"-a": true}
-
-$ prog -x
-"user-error"
-
-
-r"""Usage: prog [options]
-
-Options: --all All.
-
-"""
-$ prog
-{"--all": false}
-
-$ prog --all
-{"--all": true}
-
-$ prog --xxx
-"user-error"
-
-
-r"""Usage: prog [options]
-
-Options: -v, --verbose Verbose.
-
-"""
-$ prog --verbose
-{"--verbose": true}
-
-$ prog --ver
-{"--verbose": true}
-
-$ prog -v
-{"--verbose": true}
-
-
-r"""Usage: prog [options]
-
-Options: -p PATH
-
-"""
-$ prog -p home/
-{"-p": "home/"}
-
-$ prog -phome/
-{"-p": "home/"}
-
-$ prog -p
-"user-error"
-
-
-r"""Usage: prog [options]
-
-Options: --path
-
-"""
-$ prog --path home/
-{"--path": "home/"}
-
-$ prog --path=home/
-{"--path": "home/"}
-
-$ prog --pa home/
-{"--path": "home/"}
-
-$ prog --pa=home/
-{"--path": "home/"}
-
-$ prog --path
-"user-error"
-
-
-r"""Usage: prog [options]
-
-Options: -p PATH, --path= Path to files.
-
-"""
-$ prog -proot
-{"--path": "root"}
-
-
-r"""Usage: prog [options]
-
-Options: -p --path PATH Path to files.
-
-"""
-$ prog -p root
-{"--path": "root"}
-
-$ prog --path root
-{"--path": "root"}
-
-
-r"""Usage: prog [options]
-
-Options:
- -p PATH Path to files [default: ./]
-
-"""
-$ prog
-{"-p": "./"}
-
-$ prog -phome
-{"-p": "home"}
-
-
-r"""UsAgE: prog [options]
-
-OpTiOnS: --path= Path to files
- [dEfAuLt: /root]
-
-"""
-$ prog
-{"--path": "/root"}
-
-$ prog --path=home
-{"--path": "home"}
-
-
-r"""usage: prog [options]
-
-options:
- -a Add
- -r Remote
- -m Message
-
-"""
-$ prog -a -r -m Hello
-{"-a": true,
- "-r": true,
- "-m": "Hello"}
-
-$ prog -armyourass
-{"-a": true,
- "-r": true,
- "-m": "yourass"}
-
-$ prog -a -r
-{"-a": true,
- "-r": true,
- "-m": null}
-
-
-r"""Usage: prog [options]
-
-Options: --version
- --verbose
-
-"""
-$ prog --version
-{"--version": true,
- "--verbose": false}
-
-$ prog --verbose
-{"--version": false,
- "--verbose": true}
-
-$ prog --ver
-"user-error"
-
-$ prog --verb
-{"--version": false,
- "--verbose": true}
-
-
-r"""usage: prog [-a -r -m ]
-
-options:
- -a Add
- -r Remote
- -m Message
-
-"""
-$ prog -armyourass
-{"-a": true,
- "-r": true,
- "-m": "yourass"}
-
-
-r"""usage: prog [-armmsg]
-
-options: -a Add
- -r Remote
- -m Message
-
-"""
-$ prog -a -r -m Hello
-{"-a": true,
- "-r": true,
- "-m": "Hello"}
-
-
-r"""usage: prog -a -b
-
-options:
- -a
- -b
-
-"""
-$ prog -a -b
-{"-a": true, "-b": true}
-
-$ prog -b -a
-{"-a": true, "-b": true}
-
-$ prog -a
-"user-error"
-
-$ prog
-"user-error"
-
-
-r"""usage: prog (-a -b)
-
-options: -a
- -b
-
-"""
-$ prog -a -b
-{"-a": true, "-b": true}
-
-$ prog -b -a
-{"-a": true, "-b": true}
-
-$ prog -a
-"user-error"
-
-$ prog
-"user-error"
-
-
-r"""usage: prog [-a] -b
-
-options: -a
- -b
-
-"""
-$ prog -a -b
-{"-a": true, "-b": true}
-
-$ prog -b -a
-{"-a": true, "-b": true}
-
-$ prog -a
-"user-error"
-
-$ prog -b
-{"-a": false, "-b": true}
-
-$ prog
-"user-error"
-
-
-r"""usage: prog [(-a -b)]
-
-options: -a
- -b
-
-"""
-$ prog -a -b
-{"-a": true, "-b": true}
-
-$ prog -b -a
-{"-a": true, "-b": true}
-
-$ prog -a
-"user-error"
-
-$ prog -b
-"user-error"
-
-$ prog
-{"-a": false, "-b": false}
-
-
-r"""usage: prog (-a|-b)
-
-options: -a
- -b
-
-"""
-$ prog -a -b
-"user-error"
-
-$ prog
-"user-error"
-
-$ prog -a
-{"-a": true, "-b": false}
-
-$ prog -b
-{"-a": false, "-b": true}
-
-
-r"""usage: prog [ -a | -b ]
-
-options: -a
- -b
-
-"""
-$ prog -a -b
-"user-error"
-
-$ prog
-{"-a": false, "-b": false}
-
-$ prog -a
-{"-a": true, "-b": false}
-
-$ prog -b
-{"-a": false, "-b": true}
-
-
-r"""usage: prog """
-$ prog 10
-{"": "10"}
-
-$ prog 10 20
-"user-error"
-
-$ prog
-"user-error"
-
-
-r"""usage: prog []"""
-$ prog 10
-{"": "10"}
-
-$ prog 10 20
-"user-error"
-
-$ prog
-{"": null}
-
-
-r"""usage: prog """
-$ prog 10 20 40
-{"": "10", "": "20", "": "40"}
-
-$ prog 10 20
-"user-error"
-
-$ prog
-"user-error"
-
-
-r"""usage: prog [ ]"""
-$ prog 10 20 40
-{"": "10", "": "20", "": "40"}
-
-$ prog 10 20
-{"": "10", "": "20", "": null}
-
-$ prog
-"user-error"
-
-
-r"""usage: prog [ | ]"""
-$ prog 10 20 40
-"user-error"
-
-$ prog 20 40
-{"": null, "": "20", "": "40"}
-
-$ prog
-{"": null, "": null, "": null}
-
-
-r"""usage: prog ( --all | )
-
-options:
- --all
-
-"""
-$ prog 10 --all
-{"": "10", "--all": true, "": null}
-
-$ prog 10
-{"": null, "--all": false, "": "10"}
-
-$ prog
-"user-error"
-
-
-r"""usage: prog [ ]"""
-$ prog 10 20
-{"": ["10", "20"]}
-
-$ prog 10
-{"": ["10"]}
-
-$ prog
-{"": []}
-
-
-r"""usage: prog [( )]"""
-$ prog 10 20
-{"": ["10", "20"]}
-
-$ prog 10
-"user-error"
-
-$ prog
-{"": []}
-
-
-r"""usage: prog NAME..."""
-$ prog 10 20
-{"NAME": ["10", "20"]}
-
-$ prog 10
-{"NAME": ["10"]}
-
-$ prog
-"user-error"
-
-
-r"""usage: prog [NAME]..."""
-$ prog 10 20
-{"NAME": ["10", "20"]}
-
-$ prog 10
-{"NAME": ["10"]}
-
-$ prog
-{"NAME": []}
-
-
-r"""usage: prog [NAME...]"""
-$ prog 10 20
-{"NAME": ["10", "20"]}
-
-$ prog 10
-{"NAME": ["10"]}
-
-$ prog
-{"NAME": []}
-
-
-r"""usage: prog [NAME [NAME ...]]"""
-$ prog 10 20
-{"NAME": ["10", "20"]}
-
-$ prog 10
-{"NAME": ["10"]}
-
-$ prog
-{"NAME": []}
-
-
-r"""usage: prog (NAME | --foo NAME)
-
-options: --foo
-
-"""
-$ prog 10
-{"NAME": "10", "--foo": false}
-
-$ prog --foo 10
-{"NAME": "10", "--foo": true}
-
-$ prog --foo=10
-"user-error"
-
-
-r"""usage: prog (NAME | --foo) [--bar | NAME]
-
-options: --foo
-options: --bar
-
-"""
-$ prog 10
-{"NAME": ["10"], "--foo": false, "--bar": false}
-
-$ prog 10 20
-{"NAME": ["10", "20"], "--foo": false, "--bar": false}
-
-$ prog --foo --bar
-{"NAME": [], "--foo": true, "--bar": true}
-
-
-r"""Naval Fate.
-
-Usage:
- prog ship new ...
- prog ship [] move [--speed=]
- prog ship shoot
- prog mine (set|remove) [--moored|--drifting]
- prog -h | --help
- prog --version
-
-Options:
- -h --help Show this screen.
- --version Show version.
- --speed= Speed in knots [default: 10].
- --moored Mored (anchored) mine.
- --drifting Drifting mine.
-
-"""
-$ prog ship Guardian move 150 300 --speed=20
-{"--drifting": false,
- "--help": false,
- "--moored": false,
- "--speed": "20",
- "--version": false,
- "": ["Guardian"],
- "": "150",
- "": "300",
- "mine": false,
- "move": true,
- "new": false,
- "remove": false,
- "set": false,
- "ship": true,
- "shoot": false}
-
-
-r"""usage: prog --hello"""
-$ prog --hello
-{"--hello": true}
-
-
-r"""usage: prog [--hello=]"""
-$ prog
-{"--hello": null}
-
-$ prog --hello wrld
-{"--hello": "wrld"}
-
-
-r"""usage: prog [-o]"""
-$ prog
-{"-o": false}
-
-$ prog -o
-{"-o": true}
-
-
-r"""usage: prog [-opr]"""
-$ prog -op
-{"-o": true, "-p": true, "-r": false}
-
-
-r"""usage: prog --aabb | --aa"""
-$ prog --aa
-{"--aabb": false, "--aa": true}
-
-$ prog --a
-"user-error" # not a unique prefix
-
-#
-# Counting number of flags
-#
-
-r"""Usage: prog -v"""
-$ prog -v
-{"-v": true}
-
-
-r"""Usage: prog [-v -v]"""
-$ prog
-{"-v": 0}
-
-$ prog -v
-{"-v": 1}
-
-$ prog -vv
-{"-v": 2}
-
-
-r"""Usage: prog -v ..."""
-$ prog
-"user-error"
-
-$ prog -v
-{"-v": 1}
-
-$ prog -vv
-{"-v": 2}
-
-$ prog -vvvvvv
-{"-v": 6}
-
-
-r"""Usage: prog [-v | -vv | -vvv]
-
-This one is probably most readable user-friednly variant.
-
-"""
-$ prog
-{"-v": 0}
-
-$ prog -v
-{"-v": 1}
-
-$ prog -vv
-{"-v": 2}
-
-$ prog -vvvv
-"user-error"
-
-
-r"""usage: prog [--ver --ver]"""
-$ prog --ver --ver
-{"--ver": 2}
-
-
-#
-# Counting commands
-#
-
-r"""usage: prog [go]"""
-$ prog go
-{"go": true}
-
-
-r"""usage: prog [go go]"""
-$ prog
-{"go": 0}
-
-$ prog go
-{"go": 1}
-
-$ prog go go
-{"go": 2}
-
-$ prog go go go
-"user-error"
-
-r"""usage: prog go..."""
-$ prog go go go go go
-{"go": 5}
-
-#
-# [options] does not include options from usage-pattern
-#
-r"""usage: prog [options] [-a]
-
-options: -a
- -b
-"""
-$ prog -a
-{"-a": true, "-b": false}
-
-$ prog -aa
-"user-error"
-
-#
-# Test [options] shourtcut
-#
-
-r"""Usage: prog [options] A
-Options:
- -q Be quiet
- -v Be verbose.
-
-"""
-$ prog arg
-{"A": "arg", "-v": false, "-q": false}
-
-$ prog -v arg
-{"A": "arg", "-v": true, "-q": false}
-
-$ prog -q arg
-{"A": "arg", "-v": false, "-q": true}
-
-#
-# Test single dash
-#
-
-r"""usage: prog [-]"""
-
-$ prog -
-{"-": true}
-
-$ prog
-{"-": false}
-
-#
-# If argument is repeated, its value should always be a list
-#
-
-r"""usage: prog [NAME [NAME ...]]"""
-
-$ prog a b
-{"NAME": ["a", "b"]}
-
-$ prog
-{"NAME": []}
-
-#
-# Option's argument defaults to null/None
-#
-
-r"""usage: prog [options]
-options:
- -a Add
- -m Message
-
-"""
-$ prog -a
-{"-m": null, "-a": true}
-
-#
-# Test options without description
-#
-
-r"""usage: prog --hello"""
-$ prog --hello
-{"--hello": true}
-
-r"""usage: prog [--hello=]"""
-$ prog
-{"--hello": null}
-
-$ prog --hello wrld
-{"--hello": "wrld"}
-
-r"""usage: prog [-o]"""
-$ prog
-{"-o": false}
-
-$ prog -o
-{"-o": true}
-
-r"""usage: prog [-opr]"""
-$ prog -op
-{"-o": true, "-p": true, "-r": false}
-
-r"""usage: git [-v | --verbose]"""
-$ prog -v
-{"-v": true, "--verbose": false}
-
-r"""usage: git remote [-v | --verbose]"""
-$ prog remote -v
-{"remote": true, "-v": true, "--verbose": false}
-
-#
-# Test empty usage pattern
-#
-
-r"""usage: prog"""
-$ prog
-{}
-
-r"""usage: prog
- prog
-"""
-$ prog 1 2
-{"": "1", "": "2"}
-
-$ prog
-{"": null, "": null}
-
-r"""usage: prog
- prog
-"""
-$ prog
-{"": null, "": null}
-
-#
-# Option's argument should not capture default value from usage pattern
-#
-
-r"""usage: prog [--file=]"""
-$ prog
-{"--file": null}
-
-r"""usage: prog [--file=]
-
-options: --file
-
-"""
-$ prog
-{"--file": null}
-
-r"""Usage: prog [-a ]
-
-Options: -a, --address TCP address [default: localhost:6283].
-
-"""
-$ prog
-{"--address": "localhost:6283"}
-
-#
-# If option with argument could be repeated,
-# its arguments should be accumulated into a list
-#
-
-r"""usage: prog --long= ..."""
-
-$ prog --long one
-{"--long": ["one"]}
-
-$ prog --long one --long two
-{"--long": ["one", "two"]}
-
-#
-# Test multiple elements repeated at once
-#
-
-r"""usage: prog (go --speed=)..."""
-$ prog go left --speed=5 go right --speed=9
-{"go": 2, "": ["left", "right"], "--speed": ["5", "9"]}
-
-#
-# Required options should work with option shortcut
-#
-
-r"""usage: prog [options] -a
-
-options: -a
-
-"""
-$ prog -a
-{"-a": true}
-
-#
-# If option could be repeated its defaults should be split into a list
-#
-
-r"""usage: prog [-o ]...
-
-options: -o [default: x]
-
-"""
-$ prog -o this -o that
-{"-o": ["this", "that"]}
-
-$ prog
-{"-o": ["x"]}
-
-r"""usage: prog [-o ]...
-
-options: -o [default: x y]
-
-"""
-$ prog -o this
-{"-o": ["this"]}
-
-$ prog
-{"-o": ["x", "y"]}
-
-#
-# Test stacked option's argument
-#
-
-r"""usage: prog -pPATH
-
-options: -p PATH
-
-"""
-$ prog -pHOME
-{"-p": "HOME"}
-
-#
-# Issue 56: Repeated mutually exclusive args give nested lists sometimes
-#
-
-r"""Usage: foo (--xx=x|--yy=y)..."""
-$ prog --xx=1 --yy=2
-{"--xx": ["1"], "--yy": ["2"]}
-
-#
-# POSIXly correct tokenization
-#
-
-r"""usage: prog []"""
-$ prog f.txt
-{"": "f.txt"}
-
-r"""usage: prog [--input=]..."""
-$ prog --input a.txt --input=b.txt
-{"--input": ["a.txt", "b.txt"]}
-
-#
-# Issue 85: `[options]` shourtcut with multiple subcommands
-#
-
-r"""usage: prog good [options]
- prog fail [options]
-
-options: --loglevel=N
-
-"""
-$ prog fail --loglevel 5
-{"--loglevel": "5", "fail": true, "good": false}
-
-#
-# Usage-section syntax
-#
-
-r"""usage:prog --foo"""
-$ prog --foo
-{"--foo": true}
-
-r"""PROGRAM USAGE: prog --foo"""
-$ prog --foo
-{"--foo": true}
-
-r"""Usage: prog --foo
- prog --bar
-NOT PART OF SECTION"""
-$ prog --foo
-{"--foo": true, "--bar": false}
-
-r"""Usage:
- prog --foo
- prog --bar
-
-NOT PART OF SECTION"""
-$ prog --foo
-{"--foo": true, "--bar": false}
-
-r"""Usage:
- prog --foo
- prog --bar
-NOT PART OF SECTION"""
-$ prog --foo
-{"--foo": true, "--bar": false}
-
-#
-# Options-section syntax
-#
-
-r"""Usage: prog [options]
-
-global options: --foo
-local options: --baz
- --bar
-other options:
- --egg
- --spam
--not-an-option-
-
-"""
-$ prog --baz --egg
-{"--foo": false, "--baz": true, "--bar": false, "--egg": true, "--spam": false}
diff --git a/vendor/github.com/docopt/docopt-go/token.go b/vendor/github.com/docopt/docopt-go/token.go
deleted file mode 100644
index cc18ec9..0000000
--- a/vendor/github.com/docopt/docopt-go/token.go
+++ /dev/null
@@ -1,126 +0,0 @@
-package docopt
-
-import (
- "regexp"
- "strings"
- "unicode"
-)
-
-type tokenList struct {
- tokens []string
- errorFunc func(string, ...interface{}) error
- err errorType
-}
-type token string
-
-func newTokenList(source []string, err errorType) *tokenList {
- errorFunc := newError
- if err == errorUser {
- errorFunc = newUserError
- } else if err == errorLanguage {
- errorFunc = newLanguageError
- }
- return &tokenList{source, errorFunc, err}
-}
-
-func tokenListFromString(source string) *tokenList {
- return newTokenList(strings.Fields(source), errorUser)
-}
-
-func tokenListFromPattern(source string) *tokenList {
- p := regexp.MustCompile(`([\[\]\(\)\|]|\.\.\.)`)
- source = p.ReplaceAllString(source, ` $1 `)
- p = regexp.MustCompile(`\s+|(\S*<.*?>)`)
- split := p.Split(source, -1)
- match := p.FindAllStringSubmatch(source, -1)
- var result []string
- l := len(split)
- for i := 0; i < l; i++ {
- if len(split[i]) > 0 {
- result = append(result, split[i])
- }
- if i < l-1 && len(match[i][1]) > 0 {
- result = append(result, match[i][1])
- }
- }
- return newTokenList(result, errorLanguage)
-}
-
-func (t *token) eq(s string) bool {
- if t == nil {
- return false
- }
- return string(*t) == s
-}
-func (t *token) match(matchNil bool, tokenStrings ...string) bool {
- if t == nil && matchNil {
- return true
- } else if t == nil && !matchNil {
- return false
- }
-
- for _, tok := range tokenStrings {
- if tok == string(*t) {
- return true
- }
- }
- return false
-}
-func (t *token) hasPrefix(prefix string) bool {
- if t == nil {
- return false
- }
- return strings.HasPrefix(string(*t), prefix)
-}
-func (t *token) hasSuffix(suffix string) bool {
- if t == nil {
- return false
- }
- return strings.HasSuffix(string(*t), suffix)
-}
-func (t *token) isUpper() bool {
- if t == nil {
- return false
- }
- return isStringUppercase(string(*t))
-}
-func (t *token) String() string {
- if t == nil {
- return ""
- }
- return string(*t)
-}
-
-func (tl *tokenList) current() *token {
- if len(tl.tokens) > 0 {
- return (*token)(&(tl.tokens[0]))
- }
- return nil
-}
-
-func (tl *tokenList) length() int {
- return len(tl.tokens)
-}
-
-func (tl *tokenList) move() *token {
- if len(tl.tokens) > 0 {
- t := tl.tokens[0]
- tl.tokens = tl.tokens[1:]
- return (*token)(&t)
- }
- return nil
-}
-
-// returns true if all cased characters in the string are uppercase
-// and there are there is at least one cased charcter
-func isStringUppercase(s string) bool {
- if strings.ToUpper(s) != s {
- return false
- }
- for _, c := range []rune(s) {
- if unicode.IsUpper(c) {
- return true
- }
- }
- return false
-}
diff --git a/vendor/github.com/go-ole/go-ole/.travis.yml b/vendor/github.com/go-ole/go-ole/.travis.yml
deleted file mode 100644
index 0c2c02b..0000000
--- a/vendor/github.com/go-ole/go-ole/.travis.yml
+++ /dev/null
@@ -1,9 +0,0 @@
-language: go
-sudo: false
-
-go:
- - 1.1
- - 1.2
- - 1.3
- - 1.4
- - tip
diff --git a/vendor/github.com/go-ole/go-ole/ChangeLog.md b/vendor/github.com/go-ole/go-ole/ChangeLog.md
deleted file mode 100644
index 4ba6a8c..0000000
--- a/vendor/github.com/go-ole/go-ole/ChangeLog.md
+++ /dev/null
@@ -1,49 +0,0 @@
-# Version 1.x.x
-
-* **Add more test cases and reference new test COM server project.** (Placeholder for future additions)
-
-# Version 1.2.0-alphaX
-
-**Minimum supported version is now Go 1.4. Go 1.1 support is deprecated, but should still build.**
-
- * Added CI configuration for Travis-CI and AppVeyor.
- * Added test InterfaceID and ClassID for the COM Test Server project.
- * Added more inline documentation (#83).
- * Added IEnumVARIANT implementation (#88).
- * Added IEnumVARIANT test cases (#99, #100, #101).
- * Added support for retrieving `time.Time` from VARIANT (#92).
- * Added test case for IUnknown (#64).
- * Added test case for IDispatch (#64).
- * Added test cases for scalar variants (#64, #76).
-
-# Version 1.1.1
-
- * Fixes for Linux build.
- * Fixes for Windows build.
-
-# Version 1.1.0
-
-The change to provide building on all platforms is a new feature. The increase in minor version reflects that and allows those who wish to stay on 1.0.x to continue to do so. Support for 1.0.x will be limited to bug fixes.
-
- * Move GUID out of variables.go into its own file to make new documentation available.
- * Move OleError out of ole.go into its own file to make new documentation available.
- * Add documentation to utility functions.
- * Add documentation to variant receiver functions.
- * Add documentation to ole structures.
- * Make variant available to other systems outside of Windows.
- * Make OLE structures available to other systems outside of Windows.
-
-## New Features
-
- * Library should now be built on all platforms supported by Go. Library will NOOP on any platform that is not Windows.
- * More functions are now documented and available on godoc.org.
-
-# Version 1.0.1
-
- 1. Fix package references from repository location change.
-
-# Version 1.0.0
-
-This version is stable enough for use. The COM API is still incomplete, but provides enough functionality for accessing COM servers using IDispatch interface.
-
-There is no changelog for this version. Check commits for history.
diff --git a/vendor/github.com/go-ole/go-ole/LICENSE b/vendor/github.com/go-ole/go-ole/LICENSE
deleted file mode 100644
index 623ec06..0000000
--- a/vendor/github.com/go-ole/go-ole/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-The MIT License (MIT)
-
-Copyright © 2013-2017 Yasuhiro Matsumoto,
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the “Software”), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/vendor/github.com/go-ole/go-ole/README.md b/vendor/github.com/go-ole/go-ole/README.md
deleted file mode 100644
index 0ea9db3..0000000
--- a/vendor/github.com/go-ole/go-ole/README.md
+++ /dev/null
@@ -1,46 +0,0 @@
-#Go OLE
-
-[](https://ci.appveyor.com/project/jacobsantos/go-ole-jgs28)
-[](https://travis-ci.org/go-ole/go-ole)
-[](https://godoc.org/github.com/go-ole/go-ole)
-
-Go bindings for Windows COM using shared libraries instead of cgo.
-
-By Yasuhiro Matsumoto.
-
-## Install
-
-To experiment with go-ole, you can just compile and run the example program:
-
-```
-go get github.com/go-ole/go-ole
-cd /path/to/go-ole/
-go test
-
-cd /path/to/go-ole/example/excel
-go run excel.go
-```
-
-## Continuous Integration
-
-Continuous integration configuration has been added for both Travis-CI and AppVeyor. You will have to add these to your own account for your fork in order for it to run.
-
-**Travis-CI**
-
-Travis-CI was added to check builds on Linux to ensure that `go get` works when cross building. Currently, Travis-CI is not used to test cross-building, but this may be changed in the future. It is also not currently possible to test the library on Linux, since COM API is specific to Windows and it is not currently possible to run a COM server on Linux or even connect to a remote COM server.
-
-**AppVeyor**
-
-AppVeyor is used to build on Windows using the (in-development) test COM server. It is currently only used to test the build and ensure that the code works on Windows. It will be used to register a COM server and then run the test cases based on the test COM server.
-
-The tests currently do run and do pass and this should be maintained with commits.
-
-##Versioning
-
-Go OLE uses [semantic versioning](http://semver.org) for version numbers, which is similar to the version contract of the Go language. Which means that the major version will always maintain backwards compatibility with minor versions. Minor versions will only add new additions and changes. Fixes will always be in patch.
-
-This contract should allow you to upgrade to new minor and patch versions without breakage or modifications to your existing code. Leave a ticket, if there is breakage, so that it could be fixed.
-
-##LICENSE
-
-Under the MIT License: http://mattn.mit-license.org/2013
diff --git a/vendor/github.com/go-ole/go-ole/appveyor.yml b/vendor/github.com/go-ole/go-ole/appveyor.yml
deleted file mode 100644
index 0d557ac..0000000
--- a/vendor/github.com/go-ole/go-ole/appveyor.yml
+++ /dev/null
@@ -1,54 +0,0 @@
-# Notes:
-# - Minimal appveyor.yml file is an empty file. All sections are optional.
-# - Indent each level of configuration with 2 spaces. Do not use tabs!
-# - All section names are case-sensitive.
-# - Section names should be unique on each level.
-
-version: "1.3.0.{build}-alpha-{branch}"
-
-os: Windows Server 2012 R2
-
-branches:
- only:
- - master
- - v1.2
- - v1.1
- - v1.0
-
-skip_tags: true
-
-clone_folder: c:\gopath\src\github.com\go-ole\go-ole
-
-environment:
- GOPATH: c:\gopath
- matrix:
- - GOARCH: amd64
- GOVERSION: 1.5
- GOROOT: c:\go
- DOWNLOADPLATFORM: "x64"
-
-install:
- - choco install mingw
- - SET PATH=c:\tools\mingw64\bin;%PATH%
- # - Download COM Server
- - ps: Start-FileDownload "https://github.com/go-ole/test-com-server/releases/download/v1.0.2/test-com-server-${env:DOWNLOADPLATFORM}.zip"
- - 7z e test-com-server-%DOWNLOADPLATFORM%.zip -oc:\gopath\src\github.com\go-ole\go-ole > NUL
- - c:\gopath\src\github.com\go-ole\go-ole\build\register-assembly.bat
- # - set
- - go version
- - go env
- - go get -u golang.org/x/tools/cmd/cover
- - go get -u golang.org/x/tools/cmd/godoc
- - go get -u golang.org/x/tools/cmd/stringer
-
-build_script:
- - cd c:\gopath\src\github.com\go-ole\go-ole
- - go get -v -t ./...
- - go build
- - go test -v -cover ./...
-
-# disable automatic tests
-test: off
-
-# disable deployment
-deploy: off
diff --git a/vendor/github.com/go-ole/go-ole/com.go b/vendor/github.com/go-ole/go-ole/com.go
deleted file mode 100644
index 75ebbf1..0000000
--- a/vendor/github.com/go-ole/go-ole/com.go
+++ /dev/null
@@ -1,329 +0,0 @@
-// +build windows
-
-package ole
-
-import (
- "errors"
- "syscall"
- "time"
- "unicode/utf16"
- "unsafe"
-)
-
-var (
- procCoInitialize, _ = modole32.FindProc("CoInitialize")
- procCoInitializeEx, _ = modole32.FindProc("CoInitializeEx")
- procCoUninitialize, _ = modole32.FindProc("CoUninitialize")
- procCoCreateInstance, _ = modole32.FindProc("CoCreateInstance")
- procCoTaskMemFree, _ = modole32.FindProc("CoTaskMemFree")
- procCLSIDFromProgID, _ = modole32.FindProc("CLSIDFromProgID")
- procCLSIDFromString, _ = modole32.FindProc("CLSIDFromString")
- procStringFromCLSID, _ = modole32.FindProc("StringFromCLSID")
- procStringFromIID, _ = modole32.FindProc("StringFromIID")
- procIIDFromString, _ = modole32.FindProc("IIDFromString")
- procGetUserDefaultLCID, _ = modkernel32.FindProc("GetUserDefaultLCID")
- procCopyMemory, _ = modkernel32.FindProc("RtlMoveMemory")
- procVariantInit, _ = modoleaut32.FindProc("VariantInit")
- procVariantClear, _ = modoleaut32.FindProc("VariantClear")
- procVariantTimeToSystemTime, _ = modoleaut32.FindProc("VariantTimeToSystemTime")
- procSysAllocString, _ = modoleaut32.FindProc("SysAllocString")
- procSysAllocStringLen, _ = modoleaut32.FindProc("SysAllocStringLen")
- procSysFreeString, _ = modoleaut32.FindProc("SysFreeString")
- procSysStringLen, _ = modoleaut32.FindProc("SysStringLen")
- procCreateDispTypeInfo, _ = modoleaut32.FindProc("CreateDispTypeInfo")
- procCreateStdDispatch, _ = modoleaut32.FindProc("CreateStdDispatch")
- procGetActiveObject, _ = modoleaut32.FindProc("GetActiveObject")
-
- procGetMessageW, _ = moduser32.FindProc("GetMessageW")
- procDispatchMessageW, _ = moduser32.FindProc("DispatchMessageW")
-)
-
-// coInitialize initializes COM library on current thread.
-//
-// MSDN documentation suggests that this function should not be called. Call
-// CoInitializeEx() instead. The reason has to do with threading and this
-// function is only for single-threaded apartments.
-//
-// That said, most users of the library have gotten away with just this
-// function. If you are experiencing threading issues, then use
-// CoInitializeEx().
-func coInitialize() (err error) {
- // http://msdn.microsoft.com/en-us/library/windows/desktop/ms678543(v=vs.85).aspx
- // Suggests that no value should be passed to CoInitialized.
- // Could just be Call() since the parameter is optional. <-- Needs testing to be sure.
- hr, _, _ := procCoInitialize.Call(uintptr(0))
- if hr != 0 {
- err = NewError(hr)
- }
- return
-}
-
-// coInitializeEx initializes COM library with concurrency model.
-func coInitializeEx(coinit uint32) (err error) {
- // http://msdn.microsoft.com/en-us/library/windows/desktop/ms695279(v=vs.85).aspx
- // Suggests that the first parameter is not only optional but should always be NULL.
- hr, _, _ := procCoInitializeEx.Call(uintptr(0), uintptr(coinit))
- if hr != 0 {
- err = NewError(hr)
- }
- return
-}
-
-// CoInitialize initializes COM library on current thread.
-//
-// MSDN documentation suggests that this function should not be called. Call
-// CoInitializeEx() instead. The reason has to do with threading and this
-// function is only for single-threaded apartments.
-//
-// That said, most users of the library have gotten away with just this
-// function. If you are experiencing threading issues, then use
-// CoInitializeEx().
-func CoInitialize(p uintptr) (err error) {
- // p is ignored and won't be used.
- // Avoid any variable not used errors.
- p = uintptr(0)
- return coInitialize()
-}
-
-// CoInitializeEx initializes COM library with concurrency model.
-func CoInitializeEx(p uintptr, coinit uint32) (err error) {
- // Avoid any variable not used errors.
- p = uintptr(0)
- return coInitializeEx(coinit)
-}
-
-// CoUninitialize uninitializes COM Library.
-func CoUninitialize() {
- procCoUninitialize.Call()
-}
-
-// CoTaskMemFree frees memory pointer.
-func CoTaskMemFree(memptr uintptr) {
- procCoTaskMemFree.Call(memptr)
-}
-
-// CLSIDFromProgID retrieves Class Identifier with the given Program Identifier.
-//
-// The Programmatic Identifier must be registered, because it will be looked up
-// in the Windows Registry. The registry entry has the following keys: CLSID,
-// Insertable, Protocol and Shell
-// (https://msdn.microsoft.com/en-us/library/dd542719(v=vs.85).aspx).
-//
-// programID identifies the class id with less precision and is not guaranteed
-// to be unique. These are usually found in the registry under
-// HKEY_LOCAL_MACHINE\SOFTWARE\Classes, usually with the format of
-// "Program.Component.Version" with version being optional.
-//
-// CLSIDFromProgID in Windows API.
-func CLSIDFromProgID(progId string) (clsid *GUID, err error) {
- var guid GUID
- lpszProgID := uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(progId)))
- hr, _, _ := procCLSIDFromProgID.Call(lpszProgID, uintptr(unsafe.Pointer(&guid)))
- if hr != 0 {
- err = NewError(hr)
- }
- clsid = &guid
- return
-}
-
-// CLSIDFromString retrieves Class ID from string representation.
-//
-// This is technically the string version of the GUID and will convert the
-// string to object.
-//
-// CLSIDFromString in Windows API.
-func CLSIDFromString(str string) (clsid *GUID, err error) {
- var guid GUID
- lpsz := uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(str)))
- hr, _, _ := procCLSIDFromString.Call(lpsz, uintptr(unsafe.Pointer(&guid)))
- if hr != 0 {
- err = NewError(hr)
- }
- clsid = &guid
- return
-}
-
-// StringFromCLSID returns GUID formated string from GUID object.
-func StringFromCLSID(clsid *GUID) (str string, err error) {
- var p *uint16
- hr, _, _ := procStringFromCLSID.Call(uintptr(unsafe.Pointer(clsid)), uintptr(unsafe.Pointer(&p)))
- if hr != 0 {
- err = NewError(hr)
- }
- str = LpOleStrToString(p)
- return
-}
-
-// IIDFromString returns GUID from program ID.
-func IIDFromString(progId string) (clsid *GUID, err error) {
- var guid GUID
- lpsz := uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(progId)))
- hr, _, _ := procIIDFromString.Call(lpsz, uintptr(unsafe.Pointer(&guid)))
- if hr != 0 {
- err = NewError(hr)
- }
- clsid = &guid
- return
-}
-
-// StringFromIID returns GUID formatted string from GUID object.
-func StringFromIID(iid *GUID) (str string, err error) {
- var p *uint16
- hr, _, _ := procStringFromIID.Call(uintptr(unsafe.Pointer(iid)), uintptr(unsafe.Pointer(&p)))
- if hr != 0 {
- err = NewError(hr)
- }
- str = LpOleStrToString(p)
- return
-}
-
-// CreateInstance of single uninitialized object with GUID.
-func CreateInstance(clsid *GUID, iid *GUID) (unk *IUnknown, err error) {
- if iid == nil {
- iid = IID_IUnknown
- }
- hr, _, _ := procCoCreateInstance.Call(
- uintptr(unsafe.Pointer(clsid)),
- 0,
- CLSCTX_SERVER,
- uintptr(unsafe.Pointer(iid)),
- uintptr(unsafe.Pointer(&unk)))
- if hr != 0 {
- err = NewError(hr)
- }
- return
-}
-
-// GetActiveObject retrieves pointer to active object.
-func GetActiveObject(clsid *GUID, iid *GUID) (unk *IUnknown, err error) {
- if iid == nil {
- iid = IID_IUnknown
- }
- hr, _, _ := procGetActiveObject.Call(
- uintptr(unsafe.Pointer(clsid)),
- uintptr(unsafe.Pointer(iid)),
- uintptr(unsafe.Pointer(&unk)))
- if hr != 0 {
- err = NewError(hr)
- }
- return
-}
-
-// VariantInit initializes variant.
-func VariantInit(v *VARIANT) (err error) {
- hr, _, _ := procVariantInit.Call(uintptr(unsafe.Pointer(v)))
- if hr != 0 {
- err = NewError(hr)
- }
- return
-}
-
-// VariantClear clears value in Variant settings to VT_EMPTY.
-func VariantClear(v *VARIANT) (err error) {
- hr, _, _ := procVariantClear.Call(uintptr(unsafe.Pointer(v)))
- if hr != 0 {
- err = NewError(hr)
- }
- return
-}
-
-// SysAllocString allocates memory for string and copies string into memory.
-func SysAllocString(v string) (ss *int16) {
- pss, _, _ := procSysAllocString.Call(uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(v))))
- ss = (*int16)(unsafe.Pointer(pss))
- return
-}
-
-// SysAllocStringLen copies up to length of given string returning pointer.
-func SysAllocStringLen(v string) (ss *int16) {
- utf16 := utf16.Encode([]rune(v + "\x00"))
- ptr := &utf16[0]
-
- pss, _, _ := procSysAllocStringLen.Call(uintptr(unsafe.Pointer(ptr)), uintptr(len(utf16)-1))
- ss = (*int16)(unsafe.Pointer(pss))
- return
-}
-
-// SysFreeString frees string system memory. This must be called with SysAllocString.
-func SysFreeString(v *int16) (err error) {
- hr, _, _ := procSysFreeString.Call(uintptr(unsafe.Pointer(v)))
- if hr != 0 {
- err = NewError(hr)
- }
- return
-}
-
-// SysStringLen is the length of the system allocated string.
-func SysStringLen(v *int16) uint32 {
- l, _, _ := procSysStringLen.Call(uintptr(unsafe.Pointer(v)))
- return uint32(l)
-}
-
-// CreateStdDispatch provides default IDispatch implementation for IUnknown.
-//
-// This handles default IDispatch implementation for objects. It haves a few
-// limitations with only supporting one language. It will also only return
-// default exception codes.
-func CreateStdDispatch(unk *IUnknown, v uintptr, ptinfo *IUnknown) (disp *IDispatch, err error) {
- hr, _, _ := procCreateStdDispatch.Call(
- uintptr(unsafe.Pointer(unk)),
- v,
- uintptr(unsafe.Pointer(ptinfo)),
- uintptr(unsafe.Pointer(&disp)))
- if hr != 0 {
- err = NewError(hr)
- }
- return
-}
-
-// CreateDispTypeInfo provides default ITypeInfo implementation for IDispatch.
-//
-// This will not handle the full implementation of the interface.
-func CreateDispTypeInfo(idata *INTERFACEDATA) (pptinfo *IUnknown, err error) {
- hr, _, _ := procCreateDispTypeInfo.Call(
- uintptr(unsafe.Pointer(idata)),
- uintptr(GetUserDefaultLCID()),
- uintptr(unsafe.Pointer(&pptinfo)))
- if hr != 0 {
- err = NewError(hr)
- }
- return
-}
-
-// copyMemory moves location of a block of memory.
-func copyMemory(dest unsafe.Pointer, src unsafe.Pointer, length uint32) {
- procCopyMemory.Call(uintptr(dest), uintptr(src), uintptr(length))
-}
-
-// GetUserDefaultLCID retrieves current user default locale.
-func GetUserDefaultLCID() (lcid uint32) {
- ret, _, _ := procGetUserDefaultLCID.Call()
- lcid = uint32(ret)
- return
-}
-
-// GetMessage in message queue from runtime.
-//
-// This function appears to block. PeekMessage does not block.
-func GetMessage(msg *Msg, hwnd uint32, MsgFilterMin uint32, MsgFilterMax uint32) (ret int32, err error) {
- r0, _, err := procGetMessageW.Call(uintptr(unsafe.Pointer(msg)), uintptr(hwnd), uintptr(MsgFilterMin), uintptr(MsgFilterMax))
- ret = int32(r0)
- return
-}
-
-// DispatchMessage to window procedure.
-func DispatchMessage(msg *Msg) (ret int32) {
- r0, _, _ := procDispatchMessageW.Call(uintptr(unsafe.Pointer(msg)))
- ret = int32(r0)
- return
-}
-
-// GetVariantDate converts COM Variant Time value to Go time.Time.
-func GetVariantDate(value float64) (time.Time, error) {
- var st syscall.Systemtime
- r, _, _ := procVariantTimeToSystemTime.Call(uintptr(value), uintptr(unsafe.Pointer(&st)))
- if r != 0 {
- return time.Date(int(st.Year), time.Month(st.Month), int(st.Day), int(st.Hour), int(st.Minute), int(st.Second), int(st.Milliseconds/1000), time.UTC), nil
- }
- return time.Now(), errors.New("Could not convert to time, passing current time.")
-}
diff --git a/vendor/github.com/go-ole/go-ole/com_func.go b/vendor/github.com/go-ole/go-ole/com_func.go
deleted file mode 100644
index 425aad3..0000000
--- a/vendor/github.com/go-ole/go-ole/com_func.go
+++ /dev/null
@@ -1,174 +0,0 @@
-// +build !windows
-
-package ole
-
-import (
- "time"
- "unsafe"
-)
-
-// coInitialize initializes COM library on current thread.
-//
-// MSDN documentation suggests that this function should not be called. Call
-// CoInitializeEx() instead. The reason has to do with threading and this
-// function is only for single-threaded apartments.
-//
-// That said, most users of the library have gotten away with just this
-// function. If you are experiencing threading issues, then use
-// CoInitializeEx().
-func coInitialize() error {
- return NewError(E_NOTIMPL)
-}
-
-// coInitializeEx initializes COM library with concurrency model.
-func coInitializeEx(coinit uint32) error {
- return NewError(E_NOTIMPL)
-}
-
-// CoInitialize initializes COM library on current thread.
-//
-// MSDN documentation suggests that this function should not be called. Call
-// CoInitializeEx() instead. The reason has to do with threading and this
-// function is only for single-threaded apartments.
-//
-// That said, most users of the library have gotten away with just this
-// function. If you are experiencing threading issues, then use
-// CoInitializeEx().
-func CoInitialize(p uintptr) error {
- return NewError(E_NOTIMPL)
-}
-
-// CoInitializeEx initializes COM library with concurrency model.
-func CoInitializeEx(p uintptr, coinit uint32) error {
- return NewError(E_NOTIMPL)
-}
-
-// CoUninitialize uninitializes COM Library.
-func CoUninitialize() {}
-
-// CoTaskMemFree frees memory pointer.
-func CoTaskMemFree(memptr uintptr) {}
-
-// CLSIDFromProgID retrieves Class Identifier with the given Program Identifier.
-//
-// The Programmatic Identifier must be registered, because it will be looked up
-// in the Windows Registry. The registry entry has the following keys: CLSID,
-// Insertable, Protocol and Shell
-// (https://msdn.microsoft.com/en-us/library/dd542719(v=vs.85).aspx).
-//
-// programID identifies the class id with less precision and is not guaranteed
-// to be unique. These are usually found in the registry under
-// HKEY_LOCAL_MACHINE\SOFTWARE\Classes, usually with the format of
-// "Program.Component.Version" with version being optional.
-//
-// CLSIDFromProgID in Windows API.
-func CLSIDFromProgID(progId string) (*GUID, error) {
- return nil, NewError(E_NOTIMPL)
-}
-
-// CLSIDFromString retrieves Class ID from string representation.
-//
-// This is technically the string version of the GUID and will convert the
-// string to object.
-//
-// CLSIDFromString in Windows API.
-func CLSIDFromString(str string) (*GUID, error) {
- return nil, NewError(E_NOTIMPL)
-}
-
-// StringFromCLSID returns GUID formated string from GUID object.
-func StringFromCLSID(clsid *GUID) (string, error) {
- return "", NewError(E_NOTIMPL)
-}
-
-// IIDFromString returns GUID from program ID.
-func IIDFromString(progId string) (*GUID, error) {
- return nil, NewError(E_NOTIMPL)
-}
-
-// StringFromIID returns GUID formatted string from GUID object.
-func StringFromIID(iid *GUID) (string, error) {
- return "", NewError(E_NOTIMPL)
-}
-
-// CreateInstance of single uninitialized object with GUID.
-func CreateInstance(clsid *GUID, iid *GUID) (*IUnknown, error) {
- return nil, NewError(E_NOTIMPL)
-}
-
-// GetActiveObject retrieves pointer to active object.
-func GetActiveObject(clsid *GUID, iid *GUID) (*IUnknown, error) {
- return nil, NewError(E_NOTIMPL)
-}
-
-// VariantInit initializes variant.
-func VariantInit(v *VARIANT) error {
- return NewError(E_NOTIMPL)
-}
-
-// VariantClear clears value in Variant settings to VT_EMPTY.
-func VariantClear(v *VARIANT) error {
- return NewError(E_NOTIMPL)
-}
-
-// SysAllocString allocates memory for string and copies string into memory.
-func SysAllocString(v string) *int16 {
- u := int16(0)
- return &u
-}
-
-// SysAllocStringLen copies up to length of given string returning pointer.
-func SysAllocStringLen(v string) *int16 {
- u := int16(0)
- return &u
-}
-
-// SysFreeString frees string system memory. This must be called with SysAllocString.
-func SysFreeString(v *int16) error {
- return NewError(E_NOTIMPL)
-}
-
-// SysStringLen is the length of the system allocated string.
-func SysStringLen(v *int16) uint32 {
- return uint32(0)
-}
-
-// CreateStdDispatch provides default IDispatch implementation for IUnknown.
-//
-// This handles default IDispatch implementation for objects. It haves a few
-// limitations with only supporting one language. It will also only return
-// default exception codes.
-func CreateStdDispatch(unk *IUnknown, v uintptr, ptinfo *IUnknown) (*IDispatch, error) {
- return nil, NewError(E_NOTIMPL)
-}
-
-// CreateDispTypeInfo provides default ITypeInfo implementation for IDispatch.
-//
-// This will not handle the full implementation of the interface.
-func CreateDispTypeInfo(idata *INTERFACEDATA) (*IUnknown, error) {
- return nil, NewError(E_NOTIMPL)
-}
-
-// copyMemory moves location of a block of memory.
-func copyMemory(dest unsafe.Pointer, src unsafe.Pointer, length uint32) {}
-
-// GetUserDefaultLCID retrieves current user default locale.
-func GetUserDefaultLCID() uint32 {
- return uint32(0)
-}
-
-// GetMessage in message queue from runtime.
-//
-// This function appears to block. PeekMessage does not block.
-func GetMessage(msg *Msg, hwnd uint32, MsgFilterMin uint32, MsgFilterMax uint32) (int32, error) {
- return int32(0), NewError(E_NOTIMPL)
-}
-
-// DispatchMessage to window procedure.
-func DispatchMessage(msg *Msg) int32 {
- return int32(0)
-}
-
-func GetVariantDate(value float64) (time.Time, error) {
- return time.Now(), NewError(E_NOTIMPL)
-}
diff --git a/vendor/github.com/go-ole/go-ole/connect.go b/vendor/github.com/go-ole/go-ole/connect.go
deleted file mode 100644
index b2ac2ec..0000000
--- a/vendor/github.com/go-ole/go-ole/connect.go
+++ /dev/null
@@ -1,192 +0,0 @@
-package ole
-
-// Connection contains IUnknown for fluent interface interaction.
-//
-// Deprecated. Use oleutil package instead.
-type Connection struct {
- Object *IUnknown // Access COM
-}
-
-// Initialize COM.
-func (*Connection) Initialize() (err error) {
- return coInitialize()
-}
-
-// Uninitialize COM.
-func (*Connection) Uninitialize() {
- CoUninitialize()
-}
-
-// Create IUnknown object based first on ProgId and then from String.
-func (c *Connection) Create(progId string) (err error) {
- var clsid *GUID
- clsid, err = CLSIDFromProgID(progId)
- if err != nil {
- clsid, err = CLSIDFromString(progId)
- if err != nil {
- return
- }
- }
-
- unknown, err := CreateInstance(clsid, IID_IUnknown)
- if err != nil {
- return
- }
- c.Object = unknown
-
- return
-}
-
-// Release IUnknown object.
-func (c *Connection) Release() {
- c.Object.Release()
-}
-
-// Load COM object from list of programIDs or strings.
-func (c *Connection) Load(names ...string) (errors []error) {
- var tempErrors []error = make([]error, len(names))
- var numErrors int = 0
- for _, name := range names {
- err := c.Create(name)
- if err != nil {
- tempErrors = append(tempErrors, err)
- numErrors += 1
- continue
- }
- break
- }
-
- copy(errors, tempErrors[0:numErrors])
- return
-}
-
-// Dispatch returns Dispatch object.
-func (c *Connection) Dispatch() (object *Dispatch, err error) {
- dispatch, err := c.Object.QueryInterface(IID_IDispatch)
- if err != nil {
- return
- }
- object = &Dispatch{dispatch}
- return
-}
-
-// Dispatch stores IDispatch object.
-type Dispatch struct {
- Object *IDispatch // Dispatch object.
-}
-
-// Call method on IDispatch with parameters.
-func (d *Dispatch) Call(method string, params ...interface{}) (result *VARIANT, err error) {
- id, err := d.GetId(method)
- if err != nil {
- return
- }
-
- result, err = d.Invoke(id, DISPATCH_METHOD, params)
- return
-}
-
-// MustCall method on IDispatch with parameters.
-func (d *Dispatch) MustCall(method string, params ...interface{}) (result *VARIANT) {
- id, err := d.GetId(method)
- if err != nil {
- panic(err)
- }
-
- result, err = d.Invoke(id, DISPATCH_METHOD, params)
- if err != nil {
- panic(err)
- }
-
- return
-}
-
-// Get property on IDispatch with parameters.
-func (d *Dispatch) Get(name string, params ...interface{}) (result *VARIANT, err error) {
- id, err := d.GetId(name)
- if err != nil {
- return
- }
- result, err = d.Invoke(id, DISPATCH_PROPERTYGET, params)
- return
-}
-
-// MustGet property on IDispatch with parameters.
-func (d *Dispatch) MustGet(name string, params ...interface{}) (result *VARIANT) {
- id, err := d.GetId(name)
- if err != nil {
- panic(err)
- }
-
- result, err = d.Invoke(id, DISPATCH_PROPERTYGET, params)
- if err != nil {
- panic(err)
- }
- return
-}
-
-// Set property on IDispatch with parameters.
-func (d *Dispatch) Set(name string, params ...interface{}) (result *VARIANT, err error) {
- id, err := d.GetId(name)
- if err != nil {
- return
- }
- result, err = d.Invoke(id, DISPATCH_PROPERTYPUT, params)
- return
-}
-
-// MustSet property on IDispatch with parameters.
-func (d *Dispatch) MustSet(name string, params ...interface{}) (result *VARIANT) {
- id, err := d.GetId(name)
- if err != nil {
- panic(err)
- }
-
- result, err = d.Invoke(id, DISPATCH_PROPERTYPUT, params)
- if err != nil {
- panic(err)
- }
- return
-}
-
-// GetId retrieves ID of name on IDispatch.
-func (d *Dispatch) GetId(name string) (id int32, err error) {
- var dispid []int32
- dispid, err = d.Object.GetIDsOfName([]string{name})
- if err != nil {
- return
- }
- id = dispid[0]
- return
-}
-
-// GetIds retrieves all IDs of names on IDispatch.
-func (d *Dispatch) GetIds(names ...string) (dispid []int32, err error) {
- dispid, err = d.Object.GetIDsOfName(names)
- return
-}
-
-// Invoke IDispatch on DisplayID of dispatch type with parameters.
-//
-// There have been problems where if send cascading params..., it would error
-// out because the parameters would be empty.
-func (d *Dispatch) Invoke(id int32, dispatch int16, params []interface{}) (result *VARIANT, err error) {
- if len(params) < 1 {
- result, err = d.Object.Invoke(id, dispatch)
- } else {
- result, err = d.Object.Invoke(id, dispatch, params...)
- }
- return
-}
-
-// Release IDispatch object.
-func (d *Dispatch) Release() {
- d.Object.Release()
-}
-
-// Connect initializes COM and attempts to load IUnknown based on given names.
-func Connect(names ...string) (connection *Connection) {
- connection.Initialize()
- connection.Load(names...)
- return
-}
diff --git a/vendor/github.com/go-ole/go-ole/constants.go b/vendor/github.com/go-ole/go-ole/constants.go
deleted file mode 100644
index fd0c6d7..0000000
--- a/vendor/github.com/go-ole/go-ole/constants.go
+++ /dev/null
@@ -1,153 +0,0 @@
-package ole
-
-const (
- CLSCTX_INPROC_SERVER = 1
- CLSCTX_INPROC_HANDLER = 2
- CLSCTX_LOCAL_SERVER = 4
- CLSCTX_INPROC_SERVER16 = 8
- CLSCTX_REMOTE_SERVER = 16
- CLSCTX_ALL = CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER | CLSCTX_LOCAL_SERVER
- CLSCTX_INPROC = CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER
- CLSCTX_SERVER = CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER
-)
-
-const (
- COINIT_APARTMENTTHREADED = 0x2
- COINIT_MULTITHREADED = 0x0
- COINIT_DISABLE_OLE1DDE = 0x4
- COINIT_SPEED_OVER_MEMORY = 0x8
-)
-
-const (
- DISPATCH_METHOD = 1
- DISPATCH_PROPERTYGET = 2
- DISPATCH_PROPERTYPUT = 4
- DISPATCH_PROPERTYPUTREF = 8
-)
-
-const (
- S_OK = 0x00000000
- E_UNEXPECTED = 0x8000FFFF
- E_NOTIMPL = 0x80004001
- E_OUTOFMEMORY = 0x8007000E
- E_INVALIDARG = 0x80070057
- E_NOINTERFACE = 0x80004002
- E_POINTER = 0x80004003
- E_HANDLE = 0x80070006
- E_ABORT = 0x80004004
- E_FAIL = 0x80004005
- E_ACCESSDENIED = 0x80070005
- E_PENDING = 0x8000000A
-
- CO_E_CLASSSTRING = 0x800401F3
-)
-
-const (
- CC_FASTCALL = iota
- CC_CDECL
- CC_MSCPASCAL
- CC_PASCAL = CC_MSCPASCAL
- CC_MACPASCAL
- CC_STDCALL
- CC_FPFASTCALL
- CC_SYSCALL
- CC_MPWCDECL
- CC_MPWPASCAL
- CC_MAX = CC_MPWPASCAL
-)
-
-type VT uint16
-
-const (
- VT_EMPTY VT = 0x0
- VT_NULL VT = 0x1
- VT_I2 VT = 0x2
- VT_I4 VT = 0x3
- VT_R4 VT = 0x4
- VT_R8 VT = 0x5
- VT_CY VT = 0x6
- VT_DATE VT = 0x7
- VT_BSTR VT = 0x8
- VT_DISPATCH VT = 0x9
- VT_ERROR VT = 0xa
- VT_BOOL VT = 0xb
- VT_VARIANT VT = 0xc
- VT_UNKNOWN VT = 0xd
- VT_DECIMAL VT = 0xe
- VT_I1 VT = 0x10
- VT_UI1 VT = 0x11
- VT_UI2 VT = 0x12
- VT_UI4 VT = 0x13
- VT_I8 VT = 0x14
- VT_UI8 VT = 0x15
- VT_INT VT = 0x16
- VT_UINT VT = 0x17
- VT_VOID VT = 0x18
- VT_HRESULT VT = 0x19
- VT_PTR VT = 0x1a
- VT_SAFEARRAY VT = 0x1b
- VT_CARRAY VT = 0x1c
- VT_USERDEFINED VT = 0x1d
- VT_LPSTR VT = 0x1e
- VT_LPWSTR VT = 0x1f
- VT_RECORD VT = 0x24
- VT_INT_PTR VT = 0x25
- VT_UINT_PTR VT = 0x26
- VT_FILETIME VT = 0x40
- VT_BLOB VT = 0x41
- VT_STREAM VT = 0x42
- VT_STORAGE VT = 0x43
- VT_STREAMED_OBJECT VT = 0x44
- VT_STORED_OBJECT VT = 0x45
- VT_BLOB_OBJECT VT = 0x46
- VT_CF VT = 0x47
- VT_CLSID VT = 0x48
- VT_BSTR_BLOB VT = 0xfff
- VT_VECTOR VT = 0x1000
- VT_ARRAY VT = 0x2000
- VT_BYREF VT = 0x4000
- VT_RESERVED VT = 0x8000
- VT_ILLEGAL VT = 0xffff
- VT_ILLEGALMASKED VT = 0xfff
- VT_TYPEMASK VT = 0xfff
-)
-
-const (
- DISPID_UNKNOWN = -1
- DISPID_VALUE = 0
- DISPID_PROPERTYPUT = -3
- DISPID_NEWENUM = -4
- DISPID_EVALUATE = -5
- DISPID_CONSTRUCTOR = -6
- DISPID_DESTRUCTOR = -7
- DISPID_COLLECT = -8
-)
-
-const (
- TKIND_ENUM = 1
- TKIND_RECORD = 2
- TKIND_MODULE = 3
- TKIND_INTERFACE = 4
- TKIND_DISPATCH = 5
- TKIND_COCLASS = 6
- TKIND_ALIAS = 7
- TKIND_UNION = 8
- TKIND_MAX = 9
-)
-
-// Safe Array Feature Flags
-
-const (
- FADF_AUTO = 0x0001
- FADF_STATIC = 0x0002
- FADF_EMBEDDED = 0x0004
- FADF_FIXEDSIZE = 0x0010
- FADF_RECORD = 0x0020
- FADF_HAVEIID = 0x0040
- FADF_HAVEVARTYPE = 0x0080
- FADF_BSTR = 0x0100
- FADF_UNKNOWN = 0x0200
- FADF_DISPATCH = 0x0400
- FADF_VARIANT = 0x0800
- FADF_RESERVED = 0xF008
-)
diff --git a/vendor/github.com/go-ole/go-ole/error.go b/vendor/github.com/go-ole/go-ole/error.go
deleted file mode 100644
index 096b456..0000000
--- a/vendor/github.com/go-ole/go-ole/error.go
+++ /dev/null
@@ -1,51 +0,0 @@
-package ole
-
-// OleError stores COM errors.
-type OleError struct {
- hr uintptr
- description string
- subError error
-}
-
-// NewError creates new error with HResult.
-func NewError(hr uintptr) *OleError {
- return &OleError{hr: hr}
-}
-
-// NewErrorWithDescription creates new COM error with HResult and description.
-func NewErrorWithDescription(hr uintptr, description string) *OleError {
- return &OleError{hr: hr, description: description}
-}
-
-// NewErrorWithSubError creates new COM error with parent error.
-func NewErrorWithSubError(hr uintptr, description string, err error) *OleError {
- return &OleError{hr: hr, description: description, subError: err}
-}
-
-// Code is the HResult.
-func (v *OleError) Code() uintptr {
- return uintptr(v.hr)
-}
-
-// String description, either manually set or format message with error code.
-func (v *OleError) String() string {
- if v.description != "" {
- return errstr(int(v.hr)) + " (" + v.description + ")"
- }
- return errstr(int(v.hr))
-}
-
-// Error implements error interface.
-func (v *OleError) Error() string {
- return v.String()
-}
-
-// Description retrieves error summary, if there is one.
-func (v *OleError) Description() string {
- return v.description
-}
-
-// SubError returns parent error, if there is one.
-func (v *OleError) SubError() error {
- return v.subError
-}
diff --git a/vendor/github.com/go-ole/go-ole/error_func.go b/vendor/github.com/go-ole/go-ole/error_func.go
deleted file mode 100644
index 8a2ffaa..0000000
--- a/vendor/github.com/go-ole/go-ole/error_func.go
+++ /dev/null
@@ -1,8 +0,0 @@
-// +build !windows
-
-package ole
-
-// errstr converts error code to string.
-func errstr(errno int) string {
- return ""
-}
diff --git a/vendor/github.com/go-ole/go-ole/error_windows.go b/vendor/github.com/go-ole/go-ole/error_windows.go
deleted file mode 100644
index d0e8e68..0000000
--- a/vendor/github.com/go-ole/go-ole/error_windows.go
+++ /dev/null
@@ -1,24 +0,0 @@
-// +build windows
-
-package ole
-
-import (
- "fmt"
- "syscall"
- "unicode/utf16"
-)
-
-// errstr converts error code to string.
-func errstr(errno int) string {
- // ask windows for the remaining errors
- var flags uint32 = syscall.FORMAT_MESSAGE_FROM_SYSTEM | syscall.FORMAT_MESSAGE_ARGUMENT_ARRAY | syscall.FORMAT_MESSAGE_IGNORE_INSERTS
- b := make([]uint16, 300)
- n, err := syscall.FormatMessage(flags, 0, uint32(errno), 0, b, nil)
- if err != nil {
- return fmt.Sprintf("error %d (FormatMessage failed with: %v)", errno, err)
- }
- // trim terminating \r and \n
- for ; n > 0 && (b[n-1] == '\n' || b[n-1] == '\r'); n-- {
- }
- return string(utf16.Decode(b[:n]))
-}
diff --git a/vendor/github.com/go-ole/go-ole/guid.go b/vendor/github.com/go-ole/go-ole/guid.go
deleted file mode 100644
index 8d20f68..0000000
--- a/vendor/github.com/go-ole/go-ole/guid.go
+++ /dev/null
@@ -1,284 +0,0 @@
-package ole
-
-var (
- // IID_NULL is null Interface ID, used when no other Interface ID is known.
- IID_NULL = NewGUID("{00000000-0000-0000-0000-000000000000}")
-
- // IID_IUnknown is for IUnknown interfaces.
- IID_IUnknown = NewGUID("{00000000-0000-0000-C000-000000000046}")
-
- // IID_IDispatch is for IDispatch interfaces.
- IID_IDispatch = NewGUID("{00020400-0000-0000-C000-000000000046}")
-
- // IID_IEnumVariant is for IEnumVariant interfaces
- IID_IEnumVariant = NewGUID("{00020404-0000-0000-C000-000000000046}")
-
- // IID_IConnectionPointContainer is for IConnectionPointContainer interfaces.
- IID_IConnectionPointContainer = NewGUID("{B196B284-BAB4-101A-B69C-00AA00341D07}")
-
- // IID_IConnectionPoint is for IConnectionPoint interfaces.
- IID_IConnectionPoint = NewGUID("{B196B286-BAB4-101A-B69C-00AA00341D07}")
-
- // IID_IInspectable is for IInspectable interfaces.
- IID_IInspectable = NewGUID("{AF86E2E0-B12D-4C6A-9C5A-D7AA65101E90}")
-
- // IID_IProvideClassInfo is for IProvideClassInfo interfaces.
- IID_IProvideClassInfo = NewGUID("{B196B283-BAB4-101A-B69C-00AA00341D07}")
-)
-
-// These are for testing and not part of any library.
-var (
- // IID_ICOMTestString is for ICOMTestString interfaces.
- //
- // {E0133EB4-C36F-469A-9D3D-C66B84BE19ED}
- IID_ICOMTestString = NewGUID("{E0133EB4-C36F-469A-9D3D-C66B84BE19ED}")
-
- // IID_ICOMTestInt8 is for ICOMTestInt8 interfaces.
- //
- // {BEB06610-EB84-4155-AF58-E2BFF53680B4}
- IID_ICOMTestInt8 = NewGUID("{BEB06610-EB84-4155-AF58-E2BFF53680B4}")
-
- // IID_ICOMTestInt16 is for ICOMTestInt16 interfaces.
- //
- // {DAA3F9FA-761E-4976-A860-8364CE55F6FC}
- IID_ICOMTestInt16 = NewGUID("{DAA3F9FA-761E-4976-A860-8364CE55F6FC}")
-
- // IID_ICOMTestInt32 is for ICOMTestInt32 interfaces.
- //
- // {E3DEDEE7-38A2-4540-91D1-2EEF1D8891B0}
- IID_ICOMTestInt32 = NewGUID("{E3DEDEE7-38A2-4540-91D1-2EEF1D8891B0}")
-
- // IID_ICOMTestInt64 is for ICOMTestInt64 interfaces.
- //
- // {8D437CBC-B3ED-485C-BC32-C336432A1623}
- IID_ICOMTestInt64 = NewGUID("{8D437CBC-B3ED-485C-BC32-C336432A1623}")
-
- // IID_ICOMTestFloat is for ICOMTestFloat interfaces.
- //
- // {BF1ED004-EA02-456A-AA55-2AC8AC6B054C}
- IID_ICOMTestFloat = NewGUID("{BF1ED004-EA02-456A-AA55-2AC8AC6B054C}")
-
- // IID_ICOMTestDouble is for ICOMTestDouble interfaces.
- //
- // {BF908A81-8687-4E93-999F-D86FAB284BA0}
- IID_ICOMTestDouble = NewGUID("{BF908A81-8687-4E93-999F-D86FAB284BA0}")
-
- // IID_ICOMTestBoolean is for ICOMTestBoolean interfaces.
- //
- // {D530E7A6-4EE8-40D1-8931-3D63B8605010}
- IID_ICOMTestBoolean = NewGUID("{D530E7A6-4EE8-40D1-8931-3D63B8605010}")
-
- // IID_ICOMEchoTestObject is for ICOMEchoTestObject interfaces.
- //
- // {6485B1EF-D780-4834-A4FE-1EBB51746CA3}
- IID_ICOMEchoTestObject = NewGUID("{6485B1EF-D780-4834-A4FE-1EBB51746CA3}")
-
- // IID_ICOMTestTypes is for ICOMTestTypes interfaces.
- //
- // {CCA8D7AE-91C0-4277-A8B3-FF4EDF28D3C0}
- IID_ICOMTestTypes = NewGUID("{CCA8D7AE-91C0-4277-A8B3-FF4EDF28D3C0}")
-
- // CLSID_COMEchoTestObject is for COMEchoTestObject class.
- //
- // {3C24506A-AE9E-4D50-9157-EF317281F1B0}
- CLSID_COMEchoTestObject = NewGUID("{3C24506A-AE9E-4D50-9157-EF317281F1B0}")
-
- // CLSID_COMTestScalarClass is for COMTestScalarClass class.
- //
- // {865B85C5-0334-4AC6-9EF6-AACEC8FC5E86}
- CLSID_COMTestScalarClass = NewGUID("{865B85C5-0334-4AC6-9EF6-AACEC8FC5E86}")
-)
-
-const hextable = "0123456789ABCDEF"
-const emptyGUID = "{00000000-0000-0000-0000-000000000000}"
-
-// GUID is Windows API specific GUID type.
-//
-// This exists to match Windows GUID type for direct passing for COM.
-// Format is in xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxxxxxx.
-type GUID struct {
- Data1 uint32
- Data2 uint16
- Data3 uint16
- Data4 [8]byte
-}
-
-// NewGUID converts the given string into a globally unique identifier that is
-// compliant with the Windows API.
-//
-// The supplied string may be in any of these formats:
-//
-// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-// XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
-// {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}
-//
-// The conversion of the supplied string is not case-sensitive.
-func NewGUID(guid string) *GUID {
- d := []byte(guid)
- var d1, d2, d3, d4a, d4b []byte
-
- switch len(d) {
- case 38:
- if d[0] != '{' || d[37] != '}' {
- return nil
- }
- d = d[1:37]
- fallthrough
- case 36:
- if d[8] != '-' || d[13] != '-' || d[18] != '-' || d[23] != '-' {
- return nil
- }
- d1 = d[0:8]
- d2 = d[9:13]
- d3 = d[14:18]
- d4a = d[19:23]
- d4b = d[24:36]
- case 32:
- d1 = d[0:8]
- d2 = d[8:12]
- d3 = d[12:16]
- d4a = d[16:20]
- d4b = d[20:32]
- default:
- return nil
- }
-
- var g GUID
- var ok1, ok2, ok3, ok4 bool
- g.Data1, ok1 = decodeHexUint32(d1)
- g.Data2, ok2 = decodeHexUint16(d2)
- g.Data3, ok3 = decodeHexUint16(d3)
- g.Data4, ok4 = decodeHexByte64(d4a, d4b)
- if ok1 && ok2 && ok3 && ok4 {
- return &g
- }
- return nil
-}
-
-func decodeHexUint32(src []byte) (value uint32, ok bool) {
- var b1, b2, b3, b4 byte
- var ok1, ok2, ok3, ok4 bool
- b1, ok1 = decodeHexByte(src[0], src[1])
- b2, ok2 = decodeHexByte(src[2], src[3])
- b3, ok3 = decodeHexByte(src[4], src[5])
- b4, ok4 = decodeHexByte(src[6], src[7])
- value = (uint32(b1) << 24) | (uint32(b2) << 16) | (uint32(b3) << 8) | uint32(b4)
- ok = ok1 && ok2 && ok3 && ok4
- return
-}
-
-func decodeHexUint16(src []byte) (value uint16, ok bool) {
- var b1, b2 byte
- var ok1, ok2 bool
- b1, ok1 = decodeHexByte(src[0], src[1])
- b2, ok2 = decodeHexByte(src[2], src[3])
- value = (uint16(b1) << 8) | uint16(b2)
- ok = ok1 && ok2
- return
-}
-
-func decodeHexByte64(s1 []byte, s2 []byte) (value [8]byte, ok bool) {
- var ok1, ok2, ok3, ok4, ok5, ok6, ok7, ok8 bool
- value[0], ok1 = decodeHexByte(s1[0], s1[1])
- value[1], ok2 = decodeHexByte(s1[2], s1[3])
- value[2], ok3 = decodeHexByte(s2[0], s2[1])
- value[3], ok4 = decodeHexByte(s2[2], s2[3])
- value[4], ok5 = decodeHexByte(s2[4], s2[5])
- value[5], ok6 = decodeHexByte(s2[6], s2[7])
- value[6], ok7 = decodeHexByte(s2[8], s2[9])
- value[7], ok8 = decodeHexByte(s2[10], s2[11])
- ok = ok1 && ok2 && ok3 && ok4 && ok5 && ok6 && ok7 && ok8
- return
-}
-
-func decodeHexByte(c1, c2 byte) (value byte, ok bool) {
- var n1, n2 byte
- var ok1, ok2 bool
- n1, ok1 = decodeHexChar(c1)
- n2, ok2 = decodeHexChar(c2)
- value = (n1 << 4) | n2
- ok = ok1 && ok2
- return
-}
-
-func decodeHexChar(c byte) (byte, bool) {
- switch {
- case '0' <= c && c <= '9':
- return c - '0', true
- case 'a' <= c && c <= 'f':
- return c - 'a' + 10, true
- case 'A' <= c && c <= 'F':
- return c - 'A' + 10, true
- }
-
- return 0, false
-}
-
-// String converts the GUID to string form. It will adhere to this pattern:
-//
-// {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}
-//
-// If the GUID is nil, the string representation of an empty GUID is returned:
-//
-// {00000000-0000-0000-0000-000000000000}
-func (guid *GUID) String() string {
- if guid == nil {
- return emptyGUID
- }
-
- var c [38]byte
- c[0] = '{'
- putUint32Hex(c[1:9], guid.Data1)
- c[9] = '-'
- putUint16Hex(c[10:14], guid.Data2)
- c[14] = '-'
- putUint16Hex(c[15:19], guid.Data3)
- c[19] = '-'
- putByteHex(c[20:24], guid.Data4[0:2])
- c[24] = '-'
- putByteHex(c[25:37], guid.Data4[2:8])
- c[37] = '}'
- return string(c[:])
-}
-
-func putUint32Hex(b []byte, v uint32) {
- b[0] = hextable[byte(v>>24)>>4]
- b[1] = hextable[byte(v>>24)&0x0f]
- b[2] = hextable[byte(v>>16)>>4]
- b[3] = hextable[byte(v>>16)&0x0f]
- b[4] = hextable[byte(v>>8)>>4]
- b[5] = hextable[byte(v>>8)&0x0f]
- b[6] = hextable[byte(v)>>4]
- b[7] = hextable[byte(v)&0x0f]
-}
-
-func putUint16Hex(b []byte, v uint16) {
- b[0] = hextable[byte(v>>8)>>4]
- b[1] = hextable[byte(v>>8)&0x0f]
- b[2] = hextable[byte(v)>>4]
- b[3] = hextable[byte(v)&0x0f]
-}
-
-func putByteHex(dst, src []byte) {
- for i := 0; i < len(src); i++ {
- dst[i*2] = hextable[src[i]>>4]
- dst[i*2+1] = hextable[src[i]&0x0f]
- }
-}
-
-// IsEqualGUID compares two GUID.
-//
-// Not constant time comparison.
-func IsEqualGUID(guid1 *GUID, guid2 *GUID) bool {
- return guid1.Data1 == guid2.Data1 &&
- guid1.Data2 == guid2.Data2 &&
- guid1.Data3 == guid2.Data3 &&
- guid1.Data4[0] == guid2.Data4[0] &&
- guid1.Data4[1] == guid2.Data4[1] &&
- guid1.Data4[2] == guid2.Data4[2] &&
- guid1.Data4[3] == guid2.Data4[3] &&
- guid1.Data4[4] == guid2.Data4[4] &&
- guid1.Data4[5] == guid2.Data4[5] &&
- guid1.Data4[6] == guid2.Data4[6] &&
- guid1.Data4[7] == guid2.Data4[7]
-}
diff --git a/vendor/github.com/go-ole/go-ole/iconnectionpoint.go b/vendor/github.com/go-ole/go-ole/iconnectionpoint.go
deleted file mode 100644
index 9e6c49f..0000000
--- a/vendor/github.com/go-ole/go-ole/iconnectionpoint.go
+++ /dev/null
@@ -1,20 +0,0 @@
-package ole
-
-import "unsafe"
-
-type IConnectionPoint struct {
- IUnknown
-}
-
-type IConnectionPointVtbl struct {
- IUnknownVtbl
- GetConnectionInterface uintptr
- GetConnectionPointContainer uintptr
- Advise uintptr
- Unadvise uintptr
- EnumConnections uintptr
-}
-
-func (v *IConnectionPoint) VTable() *IConnectionPointVtbl {
- return (*IConnectionPointVtbl)(unsafe.Pointer(v.RawVTable))
-}
diff --git a/vendor/github.com/go-ole/go-ole/iconnectionpoint_func.go b/vendor/github.com/go-ole/go-ole/iconnectionpoint_func.go
deleted file mode 100644
index 5414dc3..0000000
--- a/vendor/github.com/go-ole/go-ole/iconnectionpoint_func.go
+++ /dev/null
@@ -1,21 +0,0 @@
-// +build !windows
-
-package ole
-
-import "unsafe"
-
-func (v *IConnectionPoint) GetConnectionInterface(piid **GUID) int32 {
- return int32(0)
-}
-
-func (v *IConnectionPoint) Advise(unknown *IUnknown) (uint32, error) {
- return uint32(0), NewError(E_NOTIMPL)
-}
-
-func (v *IConnectionPoint) Unadvise(cookie uint32) error {
- return NewError(E_NOTIMPL)
-}
-
-func (v *IConnectionPoint) EnumConnections(p *unsafe.Pointer) (err error) {
- return NewError(E_NOTIMPL)
-}
diff --git a/vendor/github.com/go-ole/go-ole/iconnectionpoint_windows.go b/vendor/github.com/go-ole/go-ole/iconnectionpoint_windows.go
deleted file mode 100644
index 32bc183..0000000
--- a/vendor/github.com/go-ole/go-ole/iconnectionpoint_windows.go
+++ /dev/null
@@ -1,43 +0,0 @@
-// +build windows
-
-package ole
-
-import (
- "syscall"
- "unsafe"
-)
-
-func (v *IConnectionPoint) GetConnectionInterface(piid **GUID) int32 {
- // XXX: This doesn't look like it does what it's supposed to
- return release((*IUnknown)(unsafe.Pointer(v)))
-}
-
-func (v *IConnectionPoint) Advise(unknown *IUnknown) (cookie uint32, err error) {
- hr, _, _ := syscall.Syscall(
- v.VTable().Advise,
- 3,
- uintptr(unsafe.Pointer(v)),
- uintptr(unsafe.Pointer(unknown)),
- uintptr(unsafe.Pointer(&cookie)))
- if hr != 0 {
- err = NewError(hr)
- }
- return
-}
-
-func (v *IConnectionPoint) Unadvise(cookie uint32) (err error) {
- hr, _, _ := syscall.Syscall(
- v.VTable().Unadvise,
- 2,
- uintptr(unsafe.Pointer(v)),
- uintptr(cookie),
- 0)
- if hr != 0 {
- err = NewError(hr)
- }
- return
-}
-
-func (v *IConnectionPoint) EnumConnections(p *unsafe.Pointer) error {
- return NewError(E_NOTIMPL)
-}
diff --git a/vendor/github.com/go-ole/go-ole/iconnectionpointcontainer.go b/vendor/github.com/go-ole/go-ole/iconnectionpointcontainer.go
deleted file mode 100644
index 165860d..0000000
--- a/vendor/github.com/go-ole/go-ole/iconnectionpointcontainer.go
+++ /dev/null
@@ -1,17 +0,0 @@
-package ole
-
-import "unsafe"
-
-type IConnectionPointContainer struct {
- IUnknown
-}
-
-type IConnectionPointContainerVtbl struct {
- IUnknownVtbl
- EnumConnectionPoints uintptr
- FindConnectionPoint uintptr
-}
-
-func (v *IConnectionPointContainer) VTable() *IConnectionPointContainerVtbl {
- return (*IConnectionPointContainerVtbl)(unsafe.Pointer(v.RawVTable))
-}
diff --git a/vendor/github.com/go-ole/go-ole/iconnectionpointcontainer_func.go b/vendor/github.com/go-ole/go-ole/iconnectionpointcontainer_func.go
deleted file mode 100644
index 5dfa42a..0000000
--- a/vendor/github.com/go-ole/go-ole/iconnectionpointcontainer_func.go
+++ /dev/null
@@ -1,11 +0,0 @@
-// +build !windows
-
-package ole
-
-func (v *IConnectionPointContainer) EnumConnectionPoints(points interface{}) error {
- return NewError(E_NOTIMPL)
-}
-
-func (v *IConnectionPointContainer) FindConnectionPoint(iid *GUID, point **IConnectionPoint) error {
- return NewError(E_NOTIMPL)
-}
diff --git a/vendor/github.com/go-ole/go-ole/iconnectionpointcontainer_windows.go b/vendor/github.com/go-ole/go-ole/iconnectionpointcontainer_windows.go
deleted file mode 100644
index ad30d79..0000000
--- a/vendor/github.com/go-ole/go-ole/iconnectionpointcontainer_windows.go
+++ /dev/null
@@ -1,25 +0,0 @@
-// +build windows
-
-package ole
-
-import (
- "syscall"
- "unsafe"
-)
-
-func (v *IConnectionPointContainer) EnumConnectionPoints(points interface{}) error {
- return NewError(E_NOTIMPL)
-}
-
-func (v *IConnectionPointContainer) FindConnectionPoint(iid *GUID, point **IConnectionPoint) (err error) {
- hr, _, _ := syscall.Syscall(
- v.VTable().FindConnectionPoint,
- 3,
- uintptr(unsafe.Pointer(v)),
- uintptr(unsafe.Pointer(iid)),
- uintptr(unsafe.Pointer(point)))
- if hr != 0 {
- err = NewError(hr)
- }
- return
-}
diff --git a/vendor/github.com/go-ole/go-ole/idispatch.go b/vendor/github.com/go-ole/go-ole/idispatch.go
deleted file mode 100644
index d4af124..0000000
--- a/vendor/github.com/go-ole/go-ole/idispatch.go
+++ /dev/null
@@ -1,94 +0,0 @@
-package ole
-
-import "unsafe"
-
-type IDispatch struct {
- IUnknown
-}
-
-type IDispatchVtbl struct {
- IUnknownVtbl
- GetTypeInfoCount uintptr
- GetTypeInfo uintptr
- GetIDsOfNames uintptr
- Invoke uintptr
-}
-
-func (v *IDispatch) VTable() *IDispatchVtbl {
- return (*IDispatchVtbl)(unsafe.Pointer(v.RawVTable))
-}
-
-func (v *IDispatch) GetIDsOfName(names []string) (dispid []int32, err error) {
- dispid, err = getIDsOfName(v, names)
- return
-}
-
-func (v *IDispatch) Invoke(dispid int32, dispatch int16, params ...interface{}) (result *VARIANT, err error) {
- result, err = invoke(v, dispid, dispatch, params...)
- return
-}
-
-func (v *IDispatch) GetTypeInfoCount() (c uint32, err error) {
- c, err = getTypeInfoCount(v)
- return
-}
-
-func (v *IDispatch) GetTypeInfo() (tinfo *ITypeInfo, err error) {
- tinfo, err = getTypeInfo(v)
- return
-}
-
-// GetSingleIDOfName is a helper that returns single display ID for IDispatch name.
-//
-// This replaces the common pattern of attempting to get a single name from the list of available
-// IDs. It gives the first ID, if it is available.
-func (v *IDispatch) GetSingleIDOfName(name string) (displayID int32, err error) {
- var displayIDs []int32
- displayIDs, err = v.GetIDsOfName([]string{name})
- if err != nil {
- return
- }
- displayID = displayIDs[0]
- return
-}
-
-// InvokeWithOptionalArgs accepts arguments as an array, works like Invoke.
-//
-// Accepts name and will attempt to retrieve Display ID to pass to Invoke.
-//
-// Passing params as an array is a workaround that could be fixed in later versions of Go that
-// prevent passing empty params. During testing it was discovered that this is an acceptable way of
-// getting around not being able to pass params normally.
-func (v *IDispatch) InvokeWithOptionalArgs(name string, dispatch int16, params []interface{}) (result *VARIANT, err error) {
- displayID, err := v.GetSingleIDOfName(name)
- if err != nil {
- return
- }
-
- if len(params) < 1 {
- result, err = v.Invoke(displayID, dispatch)
- } else {
- result, err = v.Invoke(displayID, dispatch, params...)
- }
-
- return
-}
-
-// CallMethod invokes named function with arguments on object.
-func (v *IDispatch) CallMethod(name string, params ...interface{}) (*VARIANT, error) {
- return v.InvokeWithOptionalArgs(name, DISPATCH_METHOD, params)
-}
-
-// GetProperty retrieves the property with the name with the ability to pass arguments.
-//
-// Most of the time you will not need to pass arguments as most objects do not allow for this
-// feature. Or at least, should not allow for this feature. Some servers don't follow best practices
-// and this is provided for those edge cases.
-func (v *IDispatch) GetProperty(name string, params ...interface{}) (*VARIANT, error) {
- return v.InvokeWithOptionalArgs(name, DISPATCH_PROPERTYGET, params)
-}
-
-// PutProperty attempts to mutate a property in the object.
-func (v *IDispatch) PutProperty(name string, params ...interface{}) (*VARIANT, error) {
- return v.InvokeWithOptionalArgs(name, DISPATCH_PROPERTYPUT, params)
-}
diff --git a/vendor/github.com/go-ole/go-ole/idispatch_func.go b/vendor/github.com/go-ole/go-ole/idispatch_func.go
deleted file mode 100644
index b8fbbe3..0000000
--- a/vendor/github.com/go-ole/go-ole/idispatch_func.go
+++ /dev/null
@@ -1,19 +0,0 @@
-// +build !windows
-
-package ole
-
-func getIDsOfName(disp *IDispatch, names []string) ([]int32, error) {
- return []int32{}, NewError(E_NOTIMPL)
-}
-
-func getTypeInfoCount(disp *IDispatch) (uint32, error) {
- return uint32(0), NewError(E_NOTIMPL)
-}
-
-func getTypeInfo(disp *IDispatch) (*ITypeInfo, error) {
- return nil, NewError(E_NOTIMPL)
-}
-
-func invoke(disp *IDispatch, dispid int32, dispatch int16, params ...interface{}) (*VARIANT, error) {
- return nil, NewError(E_NOTIMPL)
-}
diff --git a/vendor/github.com/go-ole/go-ole/idispatch_windows.go b/vendor/github.com/go-ole/go-ole/idispatch_windows.go
deleted file mode 100644
index 020e4f5..0000000
--- a/vendor/github.com/go-ole/go-ole/idispatch_windows.go
+++ /dev/null
@@ -1,197 +0,0 @@
-// +build windows
-
-package ole
-
-import (
- "syscall"
- "time"
- "unsafe"
-)
-
-func getIDsOfName(disp *IDispatch, names []string) (dispid []int32, err error) {
- wnames := make([]*uint16, len(names))
- for i := 0; i < len(names); i++ {
- wnames[i] = syscall.StringToUTF16Ptr(names[i])
- }
- dispid = make([]int32, len(names))
- namelen := uint32(len(names))
- hr, _, _ := syscall.Syscall6(
- disp.VTable().GetIDsOfNames,
- 6,
- uintptr(unsafe.Pointer(disp)),
- uintptr(unsafe.Pointer(IID_NULL)),
- uintptr(unsafe.Pointer(&wnames[0])),
- uintptr(namelen),
- uintptr(GetUserDefaultLCID()),
- uintptr(unsafe.Pointer(&dispid[0])))
- if hr != 0 {
- err = NewError(hr)
- }
- return
-}
-
-func getTypeInfoCount(disp *IDispatch) (c uint32, err error) {
- hr, _, _ := syscall.Syscall(
- disp.VTable().GetTypeInfoCount,
- 2,
- uintptr(unsafe.Pointer(disp)),
- uintptr(unsafe.Pointer(&c)),
- 0)
- if hr != 0 {
- err = NewError(hr)
- }
- return
-}
-
-func getTypeInfo(disp *IDispatch) (tinfo *ITypeInfo, err error) {
- hr, _, _ := syscall.Syscall(
- disp.VTable().GetTypeInfo,
- 3,
- uintptr(unsafe.Pointer(disp)),
- uintptr(GetUserDefaultLCID()),
- uintptr(unsafe.Pointer(&tinfo)))
- if hr != 0 {
- err = NewError(hr)
- }
- return
-}
-
-func invoke(disp *IDispatch, dispid int32, dispatch int16, params ...interface{}) (result *VARIANT, err error) {
- var dispparams DISPPARAMS
-
- if dispatch&DISPATCH_PROPERTYPUT != 0 {
- dispnames := [1]int32{DISPID_PROPERTYPUT}
- dispparams.rgdispidNamedArgs = uintptr(unsafe.Pointer(&dispnames[0]))
- dispparams.cNamedArgs = 1
- } else if dispatch&DISPATCH_PROPERTYPUTREF != 0 {
- dispnames := [1]int32{DISPID_PROPERTYPUT}
- dispparams.rgdispidNamedArgs = uintptr(unsafe.Pointer(&dispnames[0]))
- dispparams.cNamedArgs = 1
- }
- var vargs []VARIANT
- if len(params) > 0 {
- vargs = make([]VARIANT, len(params))
- for i, v := range params {
- //n := len(params)-i-1
- n := len(params) - i - 1
- VariantInit(&vargs[n])
- switch vv := v.(type) {
- case bool:
- if vv {
- vargs[n] = NewVariant(VT_BOOL, 0xffff)
- } else {
- vargs[n] = NewVariant(VT_BOOL, 0)
- }
- case *bool:
- vargs[n] = NewVariant(VT_BOOL|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*bool)))))
- case uint8:
- vargs[n] = NewVariant(VT_I1, int64(v.(uint8)))
- case *uint8:
- vargs[n] = NewVariant(VT_I1|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*uint8)))))
- case int8:
- vargs[n] = NewVariant(VT_I1, int64(v.(int8)))
- case *int8:
- vargs[n] = NewVariant(VT_I1|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*uint8)))))
- case int16:
- vargs[n] = NewVariant(VT_I2, int64(v.(int16)))
- case *int16:
- vargs[n] = NewVariant(VT_I2|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*int16)))))
- case uint16:
- vargs[n] = NewVariant(VT_UI2, int64(v.(uint16)))
- case *uint16:
- vargs[n] = NewVariant(VT_UI2|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*uint16)))))
- case int32:
- vargs[n] = NewVariant(VT_I4, int64(v.(int32)))
- case *int32:
- vargs[n] = NewVariant(VT_I4|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*int32)))))
- case uint32:
- vargs[n] = NewVariant(VT_UI4, int64(v.(uint32)))
- case *uint32:
- vargs[n] = NewVariant(VT_UI4|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*uint32)))))
- case int64:
- vargs[n] = NewVariant(VT_I8, int64(v.(int64)))
- case *int64:
- vargs[n] = NewVariant(VT_I8|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*int64)))))
- case uint64:
- vargs[n] = NewVariant(VT_UI8, int64(uintptr(v.(uint64))))
- case *uint64:
- vargs[n] = NewVariant(VT_UI8|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*uint64)))))
- case int:
- vargs[n] = NewVariant(VT_I4, int64(v.(int)))
- case *int:
- vargs[n] = NewVariant(VT_I4|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*int)))))
- case uint:
- vargs[n] = NewVariant(VT_UI4, int64(v.(uint)))
- case *uint:
- vargs[n] = NewVariant(VT_UI4|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*uint)))))
- case float32:
- vargs[n] = NewVariant(VT_R4, *(*int64)(unsafe.Pointer(&vv)))
- case *float32:
- vargs[n] = NewVariant(VT_R4|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*float32)))))
- case float64:
- vargs[n] = NewVariant(VT_R8, *(*int64)(unsafe.Pointer(&vv)))
- case *float64:
- vargs[n] = NewVariant(VT_R8|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*float64)))))
- case string:
- vargs[n] = NewVariant(VT_BSTR, int64(uintptr(unsafe.Pointer(SysAllocStringLen(v.(string))))))
- case *string:
- vargs[n] = NewVariant(VT_BSTR|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*string)))))
- case time.Time:
- s := vv.Format("2006-01-02 15:04:05")
- vargs[n] = NewVariant(VT_BSTR, int64(uintptr(unsafe.Pointer(SysAllocStringLen(s)))))
- case *time.Time:
- s := vv.Format("2006-01-02 15:04:05")
- vargs[n] = NewVariant(VT_BSTR|VT_BYREF, int64(uintptr(unsafe.Pointer(&s))))
- case *IDispatch:
- vargs[n] = NewVariant(VT_DISPATCH, int64(uintptr(unsafe.Pointer(v.(*IDispatch)))))
- case **IDispatch:
- vargs[n] = NewVariant(VT_DISPATCH|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(**IDispatch)))))
- case nil:
- vargs[n] = NewVariant(VT_NULL, 0)
- case *VARIANT:
- vargs[n] = NewVariant(VT_VARIANT|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*VARIANT)))))
- case []byte:
- safeByteArray := safeArrayFromByteSlice(v.([]byte))
- vargs[n] = NewVariant(VT_ARRAY|VT_UI1, int64(uintptr(unsafe.Pointer(safeByteArray))))
- defer VariantClear(&vargs[n])
- case []string:
- safeByteArray := safeArrayFromStringSlice(v.([]string))
- vargs[n] = NewVariant(VT_ARRAY|VT_BSTR, int64(uintptr(unsafe.Pointer(safeByteArray))))
- defer VariantClear(&vargs[n])
- default:
- panic("unknown type")
- }
- }
- dispparams.rgvarg = uintptr(unsafe.Pointer(&vargs[0]))
- dispparams.cArgs = uint32(len(params))
- }
-
- result = new(VARIANT)
- var excepInfo EXCEPINFO
- VariantInit(result)
- hr, _, _ := syscall.Syscall9(
- disp.VTable().Invoke,
- 9,
- uintptr(unsafe.Pointer(disp)),
- uintptr(dispid),
- uintptr(unsafe.Pointer(IID_NULL)),
- uintptr(GetUserDefaultLCID()),
- uintptr(dispatch),
- uintptr(unsafe.Pointer(&dispparams)),
- uintptr(unsafe.Pointer(result)),
- uintptr(unsafe.Pointer(&excepInfo)),
- 0)
- if hr != 0 {
- err = NewErrorWithSubError(hr, BstrToString(excepInfo.bstrDescription), excepInfo)
- }
- for i, varg := range vargs {
- n := len(params) - i - 1
- if varg.VT == VT_BSTR && varg.Val != 0 {
- SysFreeString(((*int16)(unsafe.Pointer(uintptr(varg.Val)))))
- }
- if varg.VT == (VT_BSTR|VT_BYREF) && varg.Val != 0 {
- *(params[n].(*string)) = LpOleStrToString(*(**uint16)(unsafe.Pointer(uintptr(varg.Val))))
- }
- }
- return
-}
diff --git a/vendor/github.com/go-ole/go-ole/ienumvariant.go b/vendor/github.com/go-ole/go-ole/ienumvariant.go
deleted file mode 100644
index 2433897..0000000
--- a/vendor/github.com/go-ole/go-ole/ienumvariant.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package ole
-
-import "unsafe"
-
-type IEnumVARIANT struct {
- IUnknown
-}
-
-type IEnumVARIANTVtbl struct {
- IUnknownVtbl
- Next uintptr
- Skip uintptr
- Reset uintptr
- Clone uintptr
-}
-
-func (v *IEnumVARIANT) VTable() *IEnumVARIANTVtbl {
- return (*IEnumVARIANTVtbl)(unsafe.Pointer(v.RawVTable))
-}
diff --git a/vendor/github.com/go-ole/go-ole/ienumvariant_func.go b/vendor/github.com/go-ole/go-ole/ienumvariant_func.go
deleted file mode 100644
index c148481..0000000
--- a/vendor/github.com/go-ole/go-ole/ienumvariant_func.go
+++ /dev/null
@@ -1,19 +0,0 @@
-// +build !windows
-
-package ole
-
-func (enum *IEnumVARIANT) Clone() (*IEnumVARIANT, error) {
- return nil, NewError(E_NOTIMPL)
-}
-
-func (enum *IEnumVARIANT) Reset() error {
- return NewError(E_NOTIMPL)
-}
-
-func (enum *IEnumVARIANT) Skip(celt uint) error {
- return NewError(E_NOTIMPL)
-}
-
-func (enum *IEnumVARIANT) Next(celt uint) (VARIANT, uint, error) {
- return NewVariant(VT_NULL, int64(0)), 0, NewError(E_NOTIMPL)
-}
diff --git a/vendor/github.com/go-ole/go-ole/ienumvariant_windows.go b/vendor/github.com/go-ole/go-ole/ienumvariant_windows.go
deleted file mode 100644
index 4781f3b..0000000
--- a/vendor/github.com/go-ole/go-ole/ienumvariant_windows.go
+++ /dev/null
@@ -1,63 +0,0 @@
-// +build windows
-
-package ole
-
-import (
- "syscall"
- "unsafe"
-)
-
-func (enum *IEnumVARIANT) Clone() (cloned *IEnumVARIANT, err error) {
- hr, _, _ := syscall.Syscall(
- enum.VTable().Clone,
- 2,
- uintptr(unsafe.Pointer(enum)),
- uintptr(unsafe.Pointer(&cloned)),
- 0)
- if hr != 0 {
- err = NewError(hr)
- }
- return
-}
-
-func (enum *IEnumVARIANT) Reset() (err error) {
- hr, _, _ := syscall.Syscall(
- enum.VTable().Reset,
- 1,
- uintptr(unsafe.Pointer(enum)),
- 0,
- 0)
- if hr != 0 {
- err = NewError(hr)
- }
- return
-}
-
-func (enum *IEnumVARIANT) Skip(celt uint) (err error) {
- hr, _, _ := syscall.Syscall(
- enum.VTable().Skip,
- 2,
- uintptr(unsafe.Pointer(enum)),
- uintptr(celt),
- 0)
- if hr != 0 {
- err = NewError(hr)
- }
- return
-}
-
-func (enum *IEnumVARIANT) Next(celt uint) (array VARIANT, length uint, err error) {
- hr, _, _ := syscall.Syscall6(
- enum.VTable().Next,
- 4,
- uintptr(unsafe.Pointer(enum)),
- uintptr(celt),
- uintptr(unsafe.Pointer(&array)),
- uintptr(unsafe.Pointer(&length)),
- 0,
- 0)
- if hr != 0 {
- err = NewError(hr)
- }
- return
-}
diff --git a/vendor/github.com/go-ole/go-ole/iinspectable.go b/vendor/github.com/go-ole/go-ole/iinspectable.go
deleted file mode 100644
index f4a19e2..0000000
--- a/vendor/github.com/go-ole/go-ole/iinspectable.go
+++ /dev/null
@@ -1,18 +0,0 @@
-package ole
-
-import "unsafe"
-
-type IInspectable struct {
- IUnknown
-}
-
-type IInspectableVtbl struct {
- IUnknownVtbl
- GetIIds uintptr
- GetRuntimeClassName uintptr
- GetTrustLevel uintptr
-}
-
-func (v *IInspectable) VTable() *IInspectableVtbl {
- return (*IInspectableVtbl)(unsafe.Pointer(v.RawVTable))
-}
diff --git a/vendor/github.com/go-ole/go-ole/iinspectable_func.go b/vendor/github.com/go-ole/go-ole/iinspectable_func.go
deleted file mode 100644
index 348829b..0000000
--- a/vendor/github.com/go-ole/go-ole/iinspectable_func.go
+++ /dev/null
@@ -1,15 +0,0 @@
-// +build !windows
-
-package ole
-
-func (v *IInspectable) GetIids() ([]*GUID, error) {
- return []*GUID{}, NewError(E_NOTIMPL)
-}
-
-func (v *IInspectable) GetRuntimeClassName() (string, error) {
- return "", NewError(E_NOTIMPL)
-}
-
-func (v *IInspectable) GetTrustLevel() (uint32, error) {
- return uint32(0), NewError(E_NOTIMPL)
-}
diff --git a/vendor/github.com/go-ole/go-ole/iinspectable_windows.go b/vendor/github.com/go-ole/go-ole/iinspectable_windows.go
deleted file mode 100644
index 4519a4a..0000000
--- a/vendor/github.com/go-ole/go-ole/iinspectable_windows.go
+++ /dev/null
@@ -1,72 +0,0 @@
-// +build windows
-
-package ole
-
-import (
- "bytes"
- "encoding/binary"
- "reflect"
- "syscall"
- "unsafe"
-)
-
-func (v *IInspectable) GetIids() (iids []*GUID, err error) {
- var count uint32
- var array uintptr
- hr, _, _ := syscall.Syscall(
- v.VTable().GetIIds,
- 3,
- uintptr(unsafe.Pointer(v)),
- uintptr(unsafe.Pointer(&count)),
- uintptr(unsafe.Pointer(&array)))
- if hr != 0 {
- err = NewError(hr)
- return
- }
- defer CoTaskMemFree(array)
-
- iids = make([]*GUID, count)
- byteCount := count * uint32(unsafe.Sizeof(GUID{}))
- slicehdr := reflect.SliceHeader{Data: array, Len: int(byteCount), Cap: int(byteCount)}
- byteSlice := *(*[]byte)(unsafe.Pointer(&slicehdr))
- reader := bytes.NewReader(byteSlice)
- for i := range iids {
- guid := GUID{}
- err = binary.Read(reader, binary.LittleEndian, &guid)
- if err != nil {
- return
- }
- iids[i] = &guid
- }
- return
-}
-
-func (v *IInspectable) GetRuntimeClassName() (s string, err error) {
- var hstring HString
- hr, _, _ := syscall.Syscall(
- v.VTable().GetRuntimeClassName,
- 2,
- uintptr(unsafe.Pointer(v)),
- uintptr(unsafe.Pointer(&hstring)),
- 0)
- if hr != 0 {
- err = NewError(hr)
- return
- }
- s = hstring.String()
- DeleteHString(hstring)
- return
-}
-
-func (v *IInspectable) GetTrustLevel() (level uint32, err error) {
- hr, _, _ := syscall.Syscall(
- v.VTable().GetTrustLevel,
- 2,
- uintptr(unsafe.Pointer(v)),
- uintptr(unsafe.Pointer(&level)),
- 0)
- if hr != 0 {
- err = NewError(hr)
- }
- return
-}
diff --git a/vendor/github.com/go-ole/go-ole/iprovideclassinfo.go b/vendor/github.com/go-ole/go-ole/iprovideclassinfo.go
deleted file mode 100644
index 25f3a6f..0000000
--- a/vendor/github.com/go-ole/go-ole/iprovideclassinfo.go
+++ /dev/null
@@ -1,21 +0,0 @@
-package ole
-
-import "unsafe"
-
-type IProvideClassInfo struct {
- IUnknown
-}
-
-type IProvideClassInfoVtbl struct {
- IUnknownVtbl
- GetClassInfo uintptr
-}
-
-func (v *IProvideClassInfo) VTable() *IProvideClassInfoVtbl {
- return (*IProvideClassInfoVtbl)(unsafe.Pointer(v.RawVTable))
-}
-
-func (v *IProvideClassInfo) GetClassInfo() (cinfo *ITypeInfo, err error) {
- cinfo, err = getClassInfo(v)
- return
-}
diff --git a/vendor/github.com/go-ole/go-ole/iprovideclassinfo_func.go b/vendor/github.com/go-ole/go-ole/iprovideclassinfo_func.go
deleted file mode 100644
index 7e3cb63..0000000
--- a/vendor/github.com/go-ole/go-ole/iprovideclassinfo_func.go
+++ /dev/null
@@ -1,7 +0,0 @@
-// +build !windows
-
-package ole
-
-func getClassInfo(disp *IProvideClassInfo) (tinfo *ITypeInfo, err error) {
- return nil, NewError(E_NOTIMPL)
-}
diff --git a/vendor/github.com/go-ole/go-ole/iprovideclassinfo_windows.go b/vendor/github.com/go-ole/go-ole/iprovideclassinfo_windows.go
deleted file mode 100644
index 2ad0163..0000000
--- a/vendor/github.com/go-ole/go-ole/iprovideclassinfo_windows.go
+++ /dev/null
@@ -1,21 +0,0 @@
-// +build windows
-
-package ole
-
-import (
- "syscall"
- "unsafe"
-)
-
-func getClassInfo(disp *IProvideClassInfo) (tinfo *ITypeInfo, err error) {
- hr, _, _ := syscall.Syscall(
- disp.VTable().GetClassInfo,
- 2,
- uintptr(unsafe.Pointer(disp)),
- uintptr(unsafe.Pointer(&tinfo)),
- 0)
- if hr != 0 {
- err = NewError(hr)
- }
- return
-}
diff --git a/vendor/github.com/go-ole/go-ole/itypeinfo.go b/vendor/github.com/go-ole/go-ole/itypeinfo.go
deleted file mode 100644
index dd3c5e2..0000000
--- a/vendor/github.com/go-ole/go-ole/itypeinfo.go
+++ /dev/null
@@ -1,34 +0,0 @@
-package ole
-
-import "unsafe"
-
-type ITypeInfo struct {
- IUnknown
-}
-
-type ITypeInfoVtbl struct {
- IUnknownVtbl
- GetTypeAttr uintptr
- GetTypeComp uintptr
- GetFuncDesc uintptr
- GetVarDesc uintptr
- GetNames uintptr
- GetRefTypeOfImplType uintptr
- GetImplTypeFlags uintptr
- GetIDsOfNames uintptr
- Invoke uintptr
- GetDocumentation uintptr
- GetDllEntry uintptr
- GetRefTypeInfo uintptr
- AddressOfMember uintptr
- CreateInstance uintptr
- GetMops uintptr
- GetContainingTypeLib uintptr
- ReleaseTypeAttr uintptr
- ReleaseFuncDesc uintptr
- ReleaseVarDesc uintptr
-}
-
-func (v *ITypeInfo) VTable() *ITypeInfoVtbl {
- return (*ITypeInfoVtbl)(unsafe.Pointer(v.RawVTable))
-}
diff --git a/vendor/github.com/go-ole/go-ole/itypeinfo_func.go b/vendor/github.com/go-ole/go-ole/itypeinfo_func.go
deleted file mode 100644
index 8364a65..0000000
--- a/vendor/github.com/go-ole/go-ole/itypeinfo_func.go
+++ /dev/null
@@ -1,7 +0,0 @@
-// +build !windows
-
-package ole
-
-func (v *ITypeInfo) GetTypeAttr() (*TYPEATTR, error) {
- return nil, NewError(E_NOTIMPL)
-}
diff --git a/vendor/github.com/go-ole/go-ole/itypeinfo_windows.go b/vendor/github.com/go-ole/go-ole/itypeinfo_windows.go
deleted file mode 100644
index 54782b3..0000000
--- a/vendor/github.com/go-ole/go-ole/itypeinfo_windows.go
+++ /dev/null
@@ -1,21 +0,0 @@
-// +build windows
-
-package ole
-
-import (
- "syscall"
- "unsafe"
-)
-
-func (v *ITypeInfo) GetTypeAttr() (tattr *TYPEATTR, err error) {
- hr, _, _ := syscall.Syscall(
- uintptr(v.VTable().GetTypeAttr),
- 2,
- uintptr(unsafe.Pointer(v)),
- uintptr(unsafe.Pointer(&tattr)),
- 0)
- if hr != 0 {
- err = NewError(hr)
- }
- return
-}
diff --git a/vendor/github.com/go-ole/go-ole/iunknown.go b/vendor/github.com/go-ole/go-ole/iunknown.go
deleted file mode 100644
index 108f28e..0000000
--- a/vendor/github.com/go-ole/go-ole/iunknown.go
+++ /dev/null
@@ -1,57 +0,0 @@
-package ole
-
-import "unsafe"
-
-type IUnknown struct {
- RawVTable *interface{}
-}
-
-type IUnknownVtbl struct {
- QueryInterface uintptr
- AddRef uintptr
- Release uintptr
-}
-
-type UnknownLike interface {
- QueryInterface(iid *GUID) (disp *IDispatch, err error)
- AddRef() int32
- Release() int32
-}
-
-func (v *IUnknown) VTable() *IUnknownVtbl {
- return (*IUnknownVtbl)(unsafe.Pointer(v.RawVTable))
-}
-
-func (v *IUnknown) PutQueryInterface(interfaceID *GUID, obj interface{}) error {
- return reflectQueryInterface(v, v.VTable().QueryInterface, interfaceID, obj)
-}
-
-func (v *IUnknown) IDispatch(interfaceID *GUID) (dispatch *IDispatch, err error) {
- err = v.PutQueryInterface(interfaceID, &dispatch)
- return
-}
-
-func (v *IUnknown) IEnumVARIANT(interfaceID *GUID) (enum *IEnumVARIANT, err error) {
- err = v.PutQueryInterface(interfaceID, &enum)
- return
-}
-
-func (v *IUnknown) QueryInterface(iid *GUID) (*IDispatch, error) {
- return queryInterface(v, iid)
-}
-
-func (v *IUnknown) MustQueryInterface(iid *GUID) (disp *IDispatch) {
- unk, err := queryInterface(v, iid)
- if err != nil {
- panic(err)
- }
- return unk
-}
-
-func (v *IUnknown) AddRef() int32 {
- return addRef(v)
-}
-
-func (v *IUnknown) Release() int32 {
- return release(v)
-}
diff --git a/vendor/github.com/go-ole/go-ole/iunknown_func.go b/vendor/github.com/go-ole/go-ole/iunknown_func.go
deleted file mode 100644
index d0a62cf..0000000
--- a/vendor/github.com/go-ole/go-ole/iunknown_func.go
+++ /dev/null
@@ -1,19 +0,0 @@
-// +build !windows
-
-package ole
-
-func reflectQueryInterface(self interface{}, method uintptr, interfaceID *GUID, obj interface{}) (err error) {
- return NewError(E_NOTIMPL)
-}
-
-func queryInterface(unk *IUnknown, iid *GUID) (disp *IDispatch, err error) {
- return nil, NewError(E_NOTIMPL)
-}
-
-func addRef(unk *IUnknown) int32 {
- return 0
-}
-
-func release(unk *IUnknown) int32 {
- return 0
-}
diff --git a/vendor/github.com/go-ole/go-ole/iunknown_windows.go b/vendor/github.com/go-ole/go-ole/iunknown_windows.go
deleted file mode 100644
index ede5bb8..0000000
--- a/vendor/github.com/go-ole/go-ole/iunknown_windows.go
+++ /dev/null
@@ -1,58 +0,0 @@
-// +build windows
-
-package ole
-
-import (
- "reflect"
- "syscall"
- "unsafe"
-)
-
-func reflectQueryInterface(self interface{}, method uintptr, interfaceID *GUID, obj interface{}) (err error) {
- selfValue := reflect.ValueOf(self).Elem()
- objValue := reflect.ValueOf(obj).Elem()
-
- hr, _, _ := syscall.Syscall(
- method,
- 3,
- selfValue.UnsafeAddr(),
- uintptr(unsafe.Pointer(interfaceID)),
- objValue.Addr().Pointer())
- if hr != 0 {
- err = NewError(hr)
- }
- return
-}
-
-func queryInterface(unk *IUnknown, iid *GUID) (disp *IDispatch, err error) {
- hr, _, _ := syscall.Syscall(
- unk.VTable().QueryInterface,
- 3,
- uintptr(unsafe.Pointer(unk)),
- uintptr(unsafe.Pointer(iid)),
- uintptr(unsafe.Pointer(&disp)))
- if hr != 0 {
- err = NewError(hr)
- }
- return
-}
-
-func addRef(unk *IUnknown) int32 {
- ret, _, _ := syscall.Syscall(
- unk.VTable().AddRef,
- 1,
- uintptr(unsafe.Pointer(unk)),
- 0,
- 0)
- return int32(ret)
-}
-
-func release(unk *IUnknown) int32 {
- ret, _, _ := syscall.Syscall(
- unk.VTable().Release,
- 1,
- uintptr(unsafe.Pointer(unk)),
- 0,
- 0)
- return int32(ret)
-}
diff --git a/vendor/github.com/go-ole/go-ole/ole.go b/vendor/github.com/go-ole/go-ole/ole.go
deleted file mode 100644
index e2ae4f4..0000000
--- a/vendor/github.com/go-ole/go-ole/ole.go
+++ /dev/null
@@ -1,157 +0,0 @@
-package ole
-
-import (
- "fmt"
- "strings"
-)
-
-// DISPPARAMS are the arguments that passed to methods or property.
-type DISPPARAMS struct {
- rgvarg uintptr
- rgdispidNamedArgs uintptr
- cArgs uint32
- cNamedArgs uint32
-}
-
-// EXCEPINFO defines exception info.
-type EXCEPINFO struct {
- wCode uint16
- wReserved uint16
- bstrSource *uint16
- bstrDescription *uint16
- bstrHelpFile *uint16
- dwHelpContext uint32
- pvReserved uintptr
- pfnDeferredFillIn uintptr
- scode uint32
-}
-
-// WCode return wCode in EXCEPINFO.
-func (e EXCEPINFO) WCode() uint16 {
- return e.wCode
-}
-
-// SCODE return scode in EXCEPINFO.
-func (e EXCEPINFO) SCODE() uint32 {
- return e.scode
-}
-
-// String convert EXCEPINFO to string.
-func (e EXCEPINFO) String() string {
- var src, desc, hlp string
- if e.bstrSource == nil {
- src = ""
- } else {
- src = BstrToString(e.bstrSource)
- }
-
- if e.bstrDescription == nil {
- desc = ""
- } else {
- desc = BstrToString(e.bstrDescription)
- }
-
- if e.bstrHelpFile == nil {
- hlp = ""
- } else {
- hlp = BstrToString(e.bstrHelpFile)
- }
-
- return fmt.Sprintf(
- "wCode: %#x, bstrSource: %v, bstrDescription: %v, bstrHelpFile: %v, dwHelpContext: %#x, scode: %#x",
- e.wCode, src, desc, hlp, e.dwHelpContext, e.scode,
- )
-}
-
-// Error implements error interface and returns error string.
-func (e EXCEPINFO) Error() string {
- if e.bstrDescription != nil {
- return strings.TrimSpace(BstrToString(e.bstrDescription))
- }
-
- src := "Unknown"
- if e.bstrSource != nil {
- src = BstrToString(e.bstrSource)
- }
-
- code := e.scode
- if e.wCode != 0 {
- code = uint32(e.wCode)
- }
-
- return fmt.Sprintf("%v: %#x", src, code)
-}
-
-// PARAMDATA defines parameter data type.
-type PARAMDATA struct {
- Name *int16
- Vt uint16
-}
-
-// METHODDATA defines method info.
-type METHODDATA struct {
- Name *uint16
- Data *PARAMDATA
- Dispid int32
- Meth uint32
- CC int32
- CArgs uint32
- Flags uint16
- VtReturn uint32
-}
-
-// INTERFACEDATA defines interface info.
-type INTERFACEDATA struct {
- MethodData *METHODDATA
- CMembers uint32
-}
-
-// Point is 2D vector type.
-type Point struct {
- X int32
- Y int32
-}
-
-// Msg is message between processes.
-type Msg struct {
- Hwnd uint32
- Message uint32
- Wparam int32
- Lparam int32
- Time uint32
- Pt Point
-}
-
-// TYPEDESC defines data type.
-type TYPEDESC struct {
- Hreftype uint32
- VT uint16
-}
-
-// IDLDESC defines IDL info.
-type IDLDESC struct {
- DwReserved uint32
- WIDLFlags uint16
-}
-
-// TYPEATTR defines type info.
-type TYPEATTR struct {
- Guid GUID
- Lcid uint32
- dwReserved uint32
- MemidConstructor int32
- MemidDestructor int32
- LpstrSchema *uint16
- CbSizeInstance uint32
- Typekind int32
- CFuncs uint16
- CVars uint16
- CImplTypes uint16
- CbSizeVft uint16
- CbAlignment uint16
- WTypeFlags uint16
- WMajorVerNum uint16
- WMinorVerNum uint16
- TdescAlias TYPEDESC
- IdldescType IDLDESC
-}
diff --git a/vendor/github.com/go-ole/go-ole/oleutil/connection.go b/vendor/github.com/go-ole/go-ole/oleutil/connection.go
deleted file mode 100644
index 60df73c..0000000
--- a/vendor/github.com/go-ole/go-ole/oleutil/connection.go
+++ /dev/null
@@ -1,100 +0,0 @@
-// +build windows
-
-package oleutil
-
-import (
- "reflect"
- "unsafe"
-
- ole "github.com/go-ole/go-ole"
-)
-
-type stdDispatch struct {
- lpVtbl *stdDispatchVtbl
- ref int32
- iid *ole.GUID
- iface interface{}
- funcMap map[string]int32
-}
-
-type stdDispatchVtbl struct {
- pQueryInterface uintptr
- pAddRef uintptr
- pRelease uintptr
- pGetTypeInfoCount uintptr
- pGetTypeInfo uintptr
- pGetIDsOfNames uintptr
- pInvoke uintptr
-}
-
-func dispQueryInterface(this *ole.IUnknown, iid *ole.GUID, punk **ole.IUnknown) uint32 {
- pthis := (*stdDispatch)(unsafe.Pointer(this))
- *punk = nil
- if ole.IsEqualGUID(iid, ole.IID_IUnknown) ||
- ole.IsEqualGUID(iid, ole.IID_IDispatch) {
- dispAddRef(this)
- *punk = this
- return ole.S_OK
- }
- if ole.IsEqualGUID(iid, pthis.iid) {
- dispAddRef(this)
- *punk = this
- return ole.S_OK
- }
- return ole.E_NOINTERFACE
-}
-
-func dispAddRef(this *ole.IUnknown) int32 {
- pthis := (*stdDispatch)(unsafe.Pointer(this))
- pthis.ref++
- return pthis.ref
-}
-
-func dispRelease(this *ole.IUnknown) int32 {
- pthis := (*stdDispatch)(unsafe.Pointer(this))
- pthis.ref--
- return pthis.ref
-}
-
-func dispGetIDsOfNames(this *ole.IUnknown, iid *ole.GUID, wnames []*uint16, namelen int, lcid int, pdisp []int32) uintptr {
- pthis := (*stdDispatch)(unsafe.Pointer(this))
- names := make([]string, len(wnames))
- for i := 0; i < len(names); i++ {
- names[i] = ole.LpOleStrToString(wnames[i])
- }
- for n := 0; n < namelen; n++ {
- if id, ok := pthis.funcMap[names[n]]; ok {
- pdisp[n] = id
- }
- }
- return ole.S_OK
-}
-
-func dispGetTypeInfoCount(pcount *int) uintptr {
- if pcount != nil {
- *pcount = 0
- }
- return ole.S_OK
-}
-
-func dispGetTypeInfo(ptypeif *uintptr) uintptr {
- return ole.E_NOTIMPL
-}
-
-func dispInvoke(this *ole.IDispatch, dispid int32, riid *ole.GUID, lcid int, flags int16, dispparams *ole.DISPPARAMS, result *ole.VARIANT, pexcepinfo *ole.EXCEPINFO, nerr *uint) uintptr {
- pthis := (*stdDispatch)(unsafe.Pointer(this))
- found := ""
- for name, id := range pthis.funcMap {
- if id == dispid {
- found = name
- }
- }
- if found != "" {
- rv := reflect.ValueOf(pthis.iface).Elem()
- rm := rv.MethodByName(found)
- rr := rm.Call([]reflect.Value{})
- println(len(rr))
- return ole.S_OK
- }
- return ole.E_NOTIMPL
-}
diff --git a/vendor/github.com/go-ole/go-ole/oleutil/connection_func.go b/vendor/github.com/go-ole/go-ole/oleutil/connection_func.go
deleted file mode 100644
index 8818fb8..0000000
--- a/vendor/github.com/go-ole/go-ole/oleutil/connection_func.go
+++ /dev/null
@@ -1,10 +0,0 @@
-// +build !windows
-
-package oleutil
-
-import ole "github.com/go-ole/go-ole"
-
-// ConnectObject creates a connection point between two services for communication.
-func ConnectObject(disp *ole.IDispatch, iid *ole.GUID, idisp interface{}) (uint32, error) {
- return 0, ole.NewError(ole.E_NOTIMPL)
-}
diff --git a/vendor/github.com/go-ole/go-ole/oleutil/connection_windows.go b/vendor/github.com/go-ole/go-ole/oleutil/connection_windows.go
deleted file mode 100644
index ab9c0d8..0000000
--- a/vendor/github.com/go-ole/go-ole/oleutil/connection_windows.go
+++ /dev/null
@@ -1,58 +0,0 @@
-// +build windows
-
-package oleutil
-
-import (
- "reflect"
- "syscall"
- "unsafe"
-
- ole "github.com/go-ole/go-ole"
-)
-
-// ConnectObject creates a connection point between two services for communication.
-func ConnectObject(disp *ole.IDispatch, iid *ole.GUID, idisp interface{}) (cookie uint32, err error) {
- unknown, err := disp.QueryInterface(ole.IID_IConnectionPointContainer)
- if err != nil {
- return
- }
-
- container := (*ole.IConnectionPointContainer)(unsafe.Pointer(unknown))
- var point *ole.IConnectionPoint
- err = container.FindConnectionPoint(iid, &point)
- if err != nil {
- return
- }
- if edisp, ok := idisp.(*ole.IUnknown); ok {
- cookie, err = point.Advise(edisp)
- container.Release()
- if err != nil {
- return
- }
- }
- rv := reflect.ValueOf(disp).Elem()
- if rv.Type().Kind() == reflect.Struct {
- dest := &stdDispatch{}
- dest.lpVtbl = &stdDispatchVtbl{}
- dest.lpVtbl.pQueryInterface = syscall.NewCallback(dispQueryInterface)
- dest.lpVtbl.pAddRef = syscall.NewCallback(dispAddRef)
- dest.lpVtbl.pRelease = syscall.NewCallback(dispRelease)
- dest.lpVtbl.pGetTypeInfoCount = syscall.NewCallback(dispGetTypeInfoCount)
- dest.lpVtbl.pGetTypeInfo = syscall.NewCallback(dispGetTypeInfo)
- dest.lpVtbl.pGetIDsOfNames = syscall.NewCallback(dispGetIDsOfNames)
- dest.lpVtbl.pInvoke = syscall.NewCallback(dispInvoke)
- dest.iface = disp
- dest.iid = iid
- cookie, err = point.Advise((*ole.IUnknown)(unsafe.Pointer(dest)))
- container.Release()
- if err != nil {
- point.Release()
- return
- }
- return
- }
-
- container.Release()
-
- return 0, ole.NewError(ole.E_INVALIDARG)
-}
diff --git a/vendor/github.com/go-ole/go-ole/oleutil/go-get.go b/vendor/github.com/go-ole/go-ole/oleutil/go-get.go
deleted file mode 100644
index 5834762..0000000
--- a/vendor/github.com/go-ole/go-ole/oleutil/go-get.go
+++ /dev/null
@@ -1,6 +0,0 @@
-// This file is here so go get succeeds as without it errors with:
-// no buildable Go source files in ...
-//
-// +build !windows
-
-package oleutil
diff --git a/vendor/github.com/go-ole/go-ole/oleutil/oleutil.go b/vendor/github.com/go-ole/go-ole/oleutil/oleutil.go
deleted file mode 100644
index f7803c1..0000000
--- a/vendor/github.com/go-ole/go-ole/oleutil/oleutil.go
+++ /dev/null
@@ -1,127 +0,0 @@
-package oleutil
-
-import ole "github.com/go-ole/go-ole"
-
-// ClassIDFrom retrieves class ID whether given is program ID or application string.
-func ClassIDFrom(programID string) (classID *ole.GUID, err error) {
- return ole.ClassIDFrom(programID)
-}
-
-// CreateObject creates object from programID based on interface type.
-//
-// Only supports IUnknown.
-//
-// Program ID can be either program ID or application string.
-func CreateObject(programID string) (unknown *ole.IUnknown, err error) {
- classID, err := ole.ClassIDFrom(programID)
- if err != nil {
- return
- }
-
- unknown, err = ole.CreateInstance(classID, ole.IID_IUnknown)
- if err != nil {
- return
- }
-
- return
-}
-
-// GetActiveObject retrieves active object for program ID and interface ID based
-// on interface type.
-//
-// Only supports IUnknown.
-//
-// Program ID can be either program ID or application string.
-func GetActiveObject(programID string) (unknown *ole.IUnknown, err error) {
- classID, err := ole.ClassIDFrom(programID)
- if err != nil {
- return
- }
-
- unknown, err = ole.GetActiveObject(classID, ole.IID_IUnknown)
- if err != nil {
- return
- }
-
- return
-}
-
-// CallMethod calls method on IDispatch with parameters.
-func CallMethod(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT, err error) {
- return disp.InvokeWithOptionalArgs(name, ole.DISPATCH_METHOD, params)
-}
-
-// MustCallMethod calls method on IDispatch with parameters or panics.
-func MustCallMethod(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT) {
- r, err := CallMethod(disp, name, params...)
- if err != nil {
- panic(err.Error())
- }
- return r
-}
-
-// GetProperty retrieves property from IDispatch.
-func GetProperty(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT, err error) {
- return disp.InvokeWithOptionalArgs(name, ole.DISPATCH_PROPERTYGET, params)
-}
-
-// MustGetProperty retrieves property from IDispatch or panics.
-func MustGetProperty(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT) {
- r, err := GetProperty(disp, name, params...)
- if err != nil {
- panic(err.Error())
- }
- return r
-}
-
-// PutProperty mutates property.
-func PutProperty(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT, err error) {
- return disp.InvokeWithOptionalArgs(name, ole.DISPATCH_PROPERTYPUT, params)
-}
-
-// MustPutProperty mutates property or panics.
-func MustPutProperty(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT) {
- r, err := PutProperty(disp, name, params...)
- if err != nil {
- panic(err.Error())
- }
- return r
-}
-
-// PutPropertyRef mutates property reference.
-func PutPropertyRef(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT, err error) {
- return disp.InvokeWithOptionalArgs(name, ole.DISPATCH_PROPERTYPUTREF, params)
-}
-
-// MustPutPropertyRef mutates property reference or panics.
-func MustPutPropertyRef(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT) {
- r, err := PutPropertyRef(disp, name, params...)
- if err != nil {
- panic(err.Error())
- }
- return r
-}
-
-func ForEach(disp *ole.IDispatch, f func(v *ole.VARIANT) error) error {
- newEnum, err := disp.GetProperty("_NewEnum")
- if err != nil {
- return err
- }
- defer newEnum.Clear()
-
- enum, err := newEnum.ToIUnknown().IEnumVARIANT(ole.IID_IEnumVariant)
- if err != nil {
- return err
- }
- defer enum.Release()
-
- for item, length, err := enum.Next(1); length > 0; item, length, err = enum.Next(1) {
- if err != nil {
- return err
- }
- if ferr := f(&item); ferr != nil {
- return ferr
- }
- }
- return nil
-}
diff --git a/vendor/github.com/go-ole/go-ole/safearray.go b/vendor/github.com/go-ole/go-ole/safearray.go
deleted file mode 100644
index a5201b5..0000000
--- a/vendor/github.com/go-ole/go-ole/safearray.go
+++ /dev/null
@@ -1,27 +0,0 @@
-// Package is meant to retrieve and process safe array data returned from COM.
-
-package ole
-
-// SafeArrayBound defines the SafeArray boundaries.
-type SafeArrayBound struct {
- Elements uint32
- LowerBound int32
-}
-
-// SafeArray is how COM handles arrays.
-type SafeArray struct {
- Dimensions uint16
- FeaturesFlag uint16
- ElementsSize uint32
- LocksAmount uint32
- Data uint32
- Bounds [16]byte
-}
-
-// SAFEARRAY is obsolete, exists for backwards compatibility.
-// Use SafeArray
-type SAFEARRAY SafeArray
-
-// SAFEARRAYBOUND is obsolete, exists for backwards compatibility.
-// Use SafeArrayBound
-type SAFEARRAYBOUND SafeArrayBound
diff --git a/vendor/github.com/go-ole/go-ole/safearray_func.go b/vendor/github.com/go-ole/go-ole/safearray_func.go
deleted file mode 100644
index 8ff0baa..0000000
--- a/vendor/github.com/go-ole/go-ole/safearray_func.go
+++ /dev/null
@@ -1,211 +0,0 @@
-// +build !windows
-
-package ole
-
-import (
- "unsafe"
-)
-
-// safeArrayAccessData returns raw array pointer.
-//
-// AKA: SafeArrayAccessData in Windows API.
-func safeArrayAccessData(safearray *SafeArray) (uintptr, error) {
- return uintptr(0), NewError(E_NOTIMPL)
-}
-
-// safeArrayUnaccessData releases raw array.
-//
-// AKA: SafeArrayUnaccessData in Windows API.
-func safeArrayUnaccessData(safearray *SafeArray) error {
- return NewError(E_NOTIMPL)
-}
-
-// safeArrayAllocData allocates SafeArray.
-//
-// AKA: SafeArrayAllocData in Windows API.
-func safeArrayAllocData(safearray *SafeArray) error {
- return NewError(E_NOTIMPL)
-}
-
-// safeArrayAllocDescriptor allocates SafeArray.
-//
-// AKA: SafeArrayAllocDescriptor in Windows API.
-func safeArrayAllocDescriptor(dimensions uint32) (*SafeArray, error) {
- return nil, NewError(E_NOTIMPL)
-}
-
-// safeArrayAllocDescriptorEx allocates SafeArray.
-//
-// AKA: SafeArrayAllocDescriptorEx in Windows API.
-func safeArrayAllocDescriptorEx(variantType VT, dimensions uint32) (*SafeArray, error) {
- return nil, NewError(E_NOTIMPL)
-}
-
-// safeArrayCopy returns copy of SafeArray.
-//
-// AKA: SafeArrayCopy in Windows API.
-func safeArrayCopy(original *SafeArray) (*SafeArray, error) {
- return nil, NewError(E_NOTIMPL)
-}
-
-// safeArrayCopyData duplicates SafeArray into another SafeArray object.
-//
-// AKA: SafeArrayCopyData in Windows API.
-func safeArrayCopyData(original *SafeArray, duplicate *SafeArray) error {
- return NewError(E_NOTIMPL)
-}
-
-// safeArrayCreate creates SafeArray.
-//
-// AKA: SafeArrayCreate in Windows API.
-func safeArrayCreate(variantType VT, dimensions uint32, bounds *SafeArrayBound) (*SafeArray, error) {
- return nil, NewError(E_NOTIMPL)
-}
-
-// safeArrayCreateEx creates SafeArray.
-//
-// AKA: SafeArrayCreateEx in Windows API.
-func safeArrayCreateEx(variantType VT, dimensions uint32, bounds *SafeArrayBound, extra uintptr) (*SafeArray, error) {
- return nil, NewError(E_NOTIMPL)
-}
-
-// safeArrayCreateVector creates SafeArray.
-//
-// AKA: SafeArrayCreateVector in Windows API.
-func safeArrayCreateVector(variantType VT, lowerBound int32, length uint32) (*SafeArray, error) {
- return nil, NewError(E_NOTIMPL)
-}
-
-// safeArrayCreateVectorEx creates SafeArray.
-//
-// AKA: SafeArrayCreateVectorEx in Windows API.
-func safeArrayCreateVectorEx(variantType VT, lowerBound int32, length uint32, extra uintptr) (*SafeArray, error) {
- return nil, NewError(E_NOTIMPL)
-}
-
-// safeArrayDestroy destroys SafeArray object.
-//
-// AKA: SafeArrayDestroy in Windows API.
-func safeArrayDestroy(safearray *SafeArray) error {
- return NewError(E_NOTIMPL)
-}
-
-// safeArrayDestroyData destroys SafeArray object.
-//
-// AKA: SafeArrayDestroyData in Windows API.
-func safeArrayDestroyData(safearray *SafeArray) error {
- return NewError(E_NOTIMPL)
-}
-
-// safeArrayDestroyDescriptor destroys SafeArray object.
-//
-// AKA: SafeArrayDestroyDescriptor in Windows API.
-func safeArrayDestroyDescriptor(safearray *SafeArray) error {
- return NewError(E_NOTIMPL)
-}
-
-// safeArrayGetDim is the amount of dimensions in the SafeArray.
-//
-// SafeArrays may have multiple dimensions. Meaning, it could be
-// multidimensional array.
-//
-// AKA: SafeArrayGetDim in Windows API.
-func safeArrayGetDim(safearray *SafeArray) (*uint32, error) {
- u := uint32(0)
- return &u, NewError(E_NOTIMPL)
-}
-
-// safeArrayGetElementSize is the element size in bytes.
-//
-// AKA: SafeArrayGetElemsize in Windows API.
-func safeArrayGetElementSize(safearray *SafeArray) (*uint32, error) {
- u := uint32(0)
- return &u, NewError(E_NOTIMPL)
-}
-
-// safeArrayGetElement retrieves element at given index.
-func safeArrayGetElement(safearray *SafeArray, index int64, pv unsafe.Pointer) error {
- return NewError(E_NOTIMPL)
-}
-
-// safeArrayGetElement retrieves element at given index and converts to string.
-func safeArrayGetElementString(safearray *SafeArray, index int64) (string, error) {
- return "", NewError(E_NOTIMPL)
-}
-
-// safeArrayGetIID is the InterfaceID of the elements in the SafeArray.
-//
-// AKA: SafeArrayGetIID in Windows API.
-func safeArrayGetIID(safearray *SafeArray) (*GUID, error) {
- return nil, NewError(E_NOTIMPL)
-}
-
-// safeArrayGetLBound returns lower bounds of SafeArray.
-//
-// SafeArrays may have multiple dimensions. Meaning, it could be
-// multidimensional array.
-//
-// AKA: SafeArrayGetLBound in Windows API.
-func safeArrayGetLBound(safearray *SafeArray, dimension uint32) (int64, error) {
- return int64(0), NewError(E_NOTIMPL)
-}
-
-// safeArrayGetUBound returns upper bounds of SafeArray.
-//
-// SafeArrays may have multiple dimensions. Meaning, it could be
-// multidimensional array.
-//
-// AKA: SafeArrayGetUBound in Windows API.
-func safeArrayGetUBound(safearray *SafeArray, dimension uint32) (int64, error) {
- return int64(0), NewError(E_NOTIMPL)
-}
-
-// safeArrayGetVartype returns data type of SafeArray.
-//
-// AKA: SafeArrayGetVartype in Windows API.
-func safeArrayGetVartype(safearray *SafeArray) (uint16, error) {
- return uint16(0), NewError(E_NOTIMPL)
-}
-
-// safeArrayLock locks SafeArray for reading to modify SafeArray.
-//
-// This must be called during some calls to ensure that another process does not
-// read or write to the SafeArray during editing.
-//
-// AKA: SafeArrayLock in Windows API.
-func safeArrayLock(safearray *SafeArray) error {
- return NewError(E_NOTIMPL)
-}
-
-// safeArrayUnlock unlocks SafeArray for reading.
-//
-// AKA: SafeArrayUnlock in Windows API.
-func safeArrayUnlock(safearray *SafeArray) error {
- return NewError(E_NOTIMPL)
-}
-
-// safeArrayPutElement stores the data element at the specified location in the
-// array.
-//
-// AKA: SafeArrayPutElement in Windows API.
-func safeArrayPutElement(safearray *SafeArray, index int64, element uintptr) error {
- return NewError(E_NOTIMPL)
-}
-
-// safeArrayGetRecordInfo accesses IRecordInfo info for custom types.
-//
-// AKA: SafeArrayGetRecordInfo in Windows API.
-//
-// XXX: Must implement IRecordInfo interface for this to return.
-func safeArrayGetRecordInfo(safearray *SafeArray) (interface{}, error) {
- return nil, NewError(E_NOTIMPL)
-}
-
-// safeArraySetRecordInfo mutates IRecordInfo info for custom types.
-//
-// AKA: SafeArraySetRecordInfo in Windows API.
-//
-// XXX: Must implement IRecordInfo interface for this to return.
-func safeArraySetRecordInfo(safearray *SafeArray, recordInfo interface{}) error {
- return NewError(E_NOTIMPL)
-}
diff --git a/vendor/github.com/go-ole/go-ole/safearray_windows.go b/vendor/github.com/go-ole/go-ole/safearray_windows.go
deleted file mode 100644
index b27936e..0000000
--- a/vendor/github.com/go-ole/go-ole/safearray_windows.go
+++ /dev/null
@@ -1,337 +0,0 @@
-// +build windows
-
-package ole
-
-import (
- "unsafe"
-)
-
-var (
- procSafeArrayAccessData, _ = modoleaut32.FindProc("SafeArrayAccessData")
- procSafeArrayAllocData, _ = modoleaut32.FindProc("SafeArrayAllocData")
- procSafeArrayAllocDescriptor, _ = modoleaut32.FindProc("SafeArrayAllocDescriptor")
- procSafeArrayAllocDescriptorEx, _ = modoleaut32.FindProc("SafeArrayAllocDescriptorEx")
- procSafeArrayCopy, _ = modoleaut32.FindProc("SafeArrayCopy")
- procSafeArrayCopyData, _ = modoleaut32.FindProc("SafeArrayCopyData")
- procSafeArrayCreate, _ = modoleaut32.FindProc("SafeArrayCreate")
- procSafeArrayCreateEx, _ = modoleaut32.FindProc("SafeArrayCreateEx")
- procSafeArrayCreateVector, _ = modoleaut32.FindProc("SafeArrayCreateVector")
- procSafeArrayCreateVectorEx, _ = modoleaut32.FindProc("SafeArrayCreateVectorEx")
- procSafeArrayDestroy, _ = modoleaut32.FindProc("SafeArrayDestroy")
- procSafeArrayDestroyData, _ = modoleaut32.FindProc("SafeArrayDestroyData")
- procSafeArrayDestroyDescriptor, _ = modoleaut32.FindProc("SafeArrayDestroyDescriptor")
- procSafeArrayGetDim, _ = modoleaut32.FindProc("SafeArrayGetDim")
- procSafeArrayGetElement, _ = modoleaut32.FindProc("SafeArrayGetElement")
- procSafeArrayGetElemsize, _ = modoleaut32.FindProc("SafeArrayGetElemsize")
- procSafeArrayGetIID, _ = modoleaut32.FindProc("SafeArrayGetIID")
- procSafeArrayGetLBound, _ = modoleaut32.FindProc("SafeArrayGetLBound")
- procSafeArrayGetUBound, _ = modoleaut32.FindProc("SafeArrayGetUBound")
- procSafeArrayGetVartype, _ = modoleaut32.FindProc("SafeArrayGetVartype")
- procSafeArrayLock, _ = modoleaut32.FindProc("SafeArrayLock")
- procSafeArrayPtrOfIndex, _ = modoleaut32.FindProc("SafeArrayPtrOfIndex")
- procSafeArrayUnaccessData, _ = modoleaut32.FindProc("SafeArrayUnaccessData")
- procSafeArrayUnlock, _ = modoleaut32.FindProc("SafeArrayUnlock")
- procSafeArrayPutElement, _ = modoleaut32.FindProc("SafeArrayPutElement")
- //procSafeArrayRedim, _ = modoleaut32.FindProc("SafeArrayRedim") // TODO
- //procSafeArraySetIID, _ = modoleaut32.FindProc("SafeArraySetIID") // TODO
- procSafeArrayGetRecordInfo, _ = modoleaut32.FindProc("SafeArrayGetRecordInfo")
- procSafeArraySetRecordInfo, _ = modoleaut32.FindProc("SafeArraySetRecordInfo")
-)
-
-// safeArrayAccessData returns raw array pointer.
-//
-// AKA: SafeArrayAccessData in Windows API.
-// Todo: Test
-func safeArrayAccessData(safearray *SafeArray) (element uintptr, err error) {
- err = convertHresultToError(
- procSafeArrayAccessData.Call(
- uintptr(unsafe.Pointer(safearray)),
- uintptr(unsafe.Pointer(&element))))
- return
-}
-
-// safeArrayUnaccessData releases raw array.
-//
-// AKA: SafeArrayUnaccessData in Windows API.
-func safeArrayUnaccessData(safearray *SafeArray) (err error) {
- err = convertHresultToError(procSafeArrayUnaccessData.Call(uintptr(unsafe.Pointer(safearray))))
- return
-}
-
-// safeArrayAllocData allocates SafeArray.
-//
-// AKA: SafeArrayAllocData in Windows API.
-func safeArrayAllocData(safearray *SafeArray) (err error) {
- err = convertHresultToError(procSafeArrayAllocData.Call(uintptr(unsafe.Pointer(safearray))))
- return
-}
-
-// safeArrayAllocDescriptor allocates SafeArray.
-//
-// AKA: SafeArrayAllocDescriptor in Windows API.
-func safeArrayAllocDescriptor(dimensions uint32) (safearray *SafeArray, err error) {
- err = convertHresultToError(
- procSafeArrayAllocDescriptor.Call(uintptr(dimensions), uintptr(unsafe.Pointer(&safearray))))
- return
-}
-
-// safeArrayAllocDescriptorEx allocates SafeArray.
-//
-// AKA: SafeArrayAllocDescriptorEx in Windows API.
-func safeArrayAllocDescriptorEx(variantType VT, dimensions uint32) (safearray *SafeArray, err error) {
- err = convertHresultToError(
- procSafeArrayAllocDescriptorEx.Call(
- uintptr(variantType),
- uintptr(dimensions),
- uintptr(unsafe.Pointer(&safearray))))
- return
-}
-
-// safeArrayCopy returns copy of SafeArray.
-//
-// AKA: SafeArrayCopy in Windows API.
-func safeArrayCopy(original *SafeArray) (safearray *SafeArray, err error) {
- err = convertHresultToError(
- procSafeArrayCopy.Call(
- uintptr(unsafe.Pointer(original)),
- uintptr(unsafe.Pointer(&safearray))))
- return
-}
-
-// safeArrayCopyData duplicates SafeArray into another SafeArray object.
-//
-// AKA: SafeArrayCopyData in Windows API.
-func safeArrayCopyData(original *SafeArray, duplicate *SafeArray) (err error) {
- err = convertHresultToError(
- procSafeArrayCopyData.Call(
- uintptr(unsafe.Pointer(original)),
- uintptr(unsafe.Pointer(duplicate))))
- return
-}
-
-// safeArrayCreate creates SafeArray.
-//
-// AKA: SafeArrayCreate in Windows API.
-func safeArrayCreate(variantType VT, dimensions uint32, bounds *SafeArrayBound) (safearray *SafeArray, err error) {
- sa, _, err := procSafeArrayCreate.Call(
- uintptr(variantType),
- uintptr(dimensions),
- uintptr(unsafe.Pointer(bounds)))
- safearray = (*SafeArray)(unsafe.Pointer(&sa))
- return
-}
-
-// safeArrayCreateEx creates SafeArray.
-//
-// AKA: SafeArrayCreateEx in Windows API.
-func safeArrayCreateEx(variantType VT, dimensions uint32, bounds *SafeArrayBound, extra uintptr) (safearray *SafeArray, err error) {
- sa, _, err := procSafeArrayCreateEx.Call(
- uintptr(variantType),
- uintptr(dimensions),
- uintptr(unsafe.Pointer(bounds)),
- extra)
- safearray = (*SafeArray)(unsafe.Pointer(sa))
- return
-}
-
-// safeArrayCreateVector creates SafeArray.
-//
-// AKA: SafeArrayCreateVector in Windows API.
-func safeArrayCreateVector(variantType VT, lowerBound int32, length uint32) (safearray *SafeArray, err error) {
- sa, _, err := procSafeArrayCreateVector.Call(
- uintptr(variantType),
- uintptr(lowerBound),
- uintptr(length))
- safearray = (*SafeArray)(unsafe.Pointer(sa))
- return
-}
-
-// safeArrayCreateVectorEx creates SafeArray.
-//
-// AKA: SafeArrayCreateVectorEx in Windows API.
-func safeArrayCreateVectorEx(variantType VT, lowerBound int32, length uint32, extra uintptr) (safearray *SafeArray, err error) {
- sa, _, err := procSafeArrayCreateVectorEx.Call(
- uintptr(variantType),
- uintptr(lowerBound),
- uintptr(length),
- extra)
- safearray = (*SafeArray)(unsafe.Pointer(sa))
- return
-}
-
-// safeArrayDestroy destroys SafeArray object.
-//
-// AKA: SafeArrayDestroy in Windows API.
-func safeArrayDestroy(safearray *SafeArray) (err error) {
- err = convertHresultToError(procSafeArrayDestroy.Call(uintptr(unsafe.Pointer(safearray))))
- return
-}
-
-// safeArrayDestroyData destroys SafeArray object.
-//
-// AKA: SafeArrayDestroyData in Windows API.
-func safeArrayDestroyData(safearray *SafeArray) (err error) {
- err = convertHresultToError(procSafeArrayDestroyData.Call(uintptr(unsafe.Pointer(safearray))))
- return
-}
-
-// safeArrayDestroyDescriptor destroys SafeArray object.
-//
-// AKA: SafeArrayDestroyDescriptor in Windows API.
-func safeArrayDestroyDescriptor(safearray *SafeArray) (err error) {
- err = convertHresultToError(procSafeArrayDestroyDescriptor.Call(uintptr(unsafe.Pointer(safearray))))
- return
-}
-
-// safeArrayGetDim is the amount of dimensions in the SafeArray.
-//
-// SafeArrays may have multiple dimensions. Meaning, it could be
-// multidimensional array.
-//
-// AKA: SafeArrayGetDim in Windows API.
-func safeArrayGetDim(safearray *SafeArray) (dimensions *uint32, err error) {
- l, _, err := procSafeArrayGetDim.Call(uintptr(unsafe.Pointer(safearray)))
- dimensions = (*uint32)(unsafe.Pointer(l))
- return
-}
-
-// safeArrayGetElementSize is the element size in bytes.
-//
-// AKA: SafeArrayGetElemsize in Windows API.
-func safeArrayGetElementSize(safearray *SafeArray) (length *uint32, err error) {
- l, _, err := procSafeArrayGetElemsize.Call(uintptr(unsafe.Pointer(safearray)))
- length = (*uint32)(unsafe.Pointer(l))
- return
-}
-
-// safeArrayGetElement retrieves element at given index.
-func safeArrayGetElement(safearray *SafeArray, index int64, pv unsafe.Pointer) error {
- return convertHresultToError(
- procSafeArrayGetElement.Call(
- uintptr(unsafe.Pointer(safearray)),
- uintptr(unsafe.Pointer(&index)),
- uintptr(pv)))
-}
-
-// safeArrayGetElementString retrieves element at given index and converts to string.
-func safeArrayGetElementString(safearray *SafeArray, index int64) (str string, err error) {
- var element *int16
- err = convertHresultToError(
- procSafeArrayGetElement.Call(
- uintptr(unsafe.Pointer(safearray)),
- uintptr(unsafe.Pointer(&index)),
- uintptr(unsafe.Pointer(&element))))
- str = BstrToString(*(**uint16)(unsafe.Pointer(&element)))
- SysFreeString(element)
- return
-}
-
-// safeArrayGetIID is the InterfaceID of the elements in the SafeArray.
-//
-// AKA: SafeArrayGetIID in Windows API.
-func safeArrayGetIID(safearray *SafeArray) (guid *GUID, err error) {
- err = convertHresultToError(
- procSafeArrayGetIID.Call(
- uintptr(unsafe.Pointer(safearray)),
- uintptr(unsafe.Pointer(&guid))))
- return
-}
-
-// safeArrayGetLBound returns lower bounds of SafeArray.
-//
-// SafeArrays may have multiple dimensions. Meaning, it could be
-// multidimensional array.
-//
-// AKA: SafeArrayGetLBound in Windows API.
-func safeArrayGetLBound(safearray *SafeArray, dimension uint32) (lowerBound int64, err error) {
- err = convertHresultToError(
- procSafeArrayGetLBound.Call(
- uintptr(unsafe.Pointer(safearray)),
- uintptr(dimension),
- uintptr(unsafe.Pointer(&lowerBound))))
- return
-}
-
-// safeArrayGetUBound returns upper bounds of SafeArray.
-//
-// SafeArrays may have multiple dimensions. Meaning, it could be
-// multidimensional array.
-//
-// AKA: SafeArrayGetUBound in Windows API.
-func safeArrayGetUBound(safearray *SafeArray, dimension uint32) (upperBound int64, err error) {
- err = convertHresultToError(
- procSafeArrayGetUBound.Call(
- uintptr(unsafe.Pointer(safearray)),
- uintptr(dimension),
- uintptr(unsafe.Pointer(&upperBound))))
- return
-}
-
-// safeArrayGetVartype returns data type of SafeArray.
-//
-// AKA: SafeArrayGetVartype in Windows API.
-func safeArrayGetVartype(safearray *SafeArray) (varType uint16, err error) {
- err = convertHresultToError(
- procSafeArrayGetVartype.Call(
- uintptr(unsafe.Pointer(safearray)),
- uintptr(unsafe.Pointer(&varType))))
- return
-}
-
-// safeArrayLock locks SafeArray for reading to modify SafeArray.
-//
-// This must be called during some calls to ensure that another process does not
-// read or write to the SafeArray during editing.
-//
-// AKA: SafeArrayLock in Windows API.
-func safeArrayLock(safearray *SafeArray) (err error) {
- err = convertHresultToError(procSafeArrayLock.Call(uintptr(unsafe.Pointer(safearray))))
- return
-}
-
-// safeArrayUnlock unlocks SafeArray for reading.
-//
-// AKA: SafeArrayUnlock in Windows API.
-func safeArrayUnlock(safearray *SafeArray) (err error) {
- err = convertHresultToError(procSafeArrayUnlock.Call(uintptr(unsafe.Pointer(safearray))))
- return
-}
-
-// safeArrayPutElement stores the data element at the specified location in the
-// array.
-//
-// AKA: SafeArrayPutElement in Windows API.
-func safeArrayPutElement(safearray *SafeArray, index int64, element uintptr) (err error) {
- err = convertHresultToError(
- procSafeArrayPutElement.Call(
- uintptr(unsafe.Pointer(safearray)),
- uintptr(unsafe.Pointer(&index)),
- uintptr(unsafe.Pointer(element))))
- return
-}
-
-// safeArrayGetRecordInfo accesses IRecordInfo info for custom types.
-//
-// AKA: SafeArrayGetRecordInfo in Windows API.
-//
-// XXX: Must implement IRecordInfo interface for this to return.
-func safeArrayGetRecordInfo(safearray *SafeArray) (recordInfo interface{}, err error) {
- err = convertHresultToError(
- procSafeArrayGetRecordInfo.Call(
- uintptr(unsafe.Pointer(safearray)),
- uintptr(unsafe.Pointer(&recordInfo))))
- return
-}
-
-// safeArraySetRecordInfo mutates IRecordInfo info for custom types.
-//
-// AKA: SafeArraySetRecordInfo in Windows API.
-//
-// XXX: Must implement IRecordInfo interface for this to return.
-func safeArraySetRecordInfo(safearray *SafeArray, recordInfo interface{}) (err error) {
- err = convertHresultToError(
- procSafeArraySetRecordInfo.Call(
- uintptr(unsafe.Pointer(safearray)),
- uintptr(unsafe.Pointer(&recordInfo))))
- return
-}
diff --git a/vendor/github.com/go-ole/go-ole/safearrayconversion.go b/vendor/github.com/go-ole/go-ole/safearrayconversion.go
deleted file mode 100644
index ffeb2b9..0000000
--- a/vendor/github.com/go-ole/go-ole/safearrayconversion.go
+++ /dev/null
@@ -1,140 +0,0 @@
-// Helper for converting SafeArray to array of objects.
-
-package ole
-
-import (
- "unsafe"
-)
-
-type SafeArrayConversion struct {
- Array *SafeArray
-}
-
-func (sac *SafeArrayConversion) ToStringArray() (strings []string) {
- totalElements, _ := sac.TotalElements(0)
- strings = make([]string, totalElements)
-
- for i := int64(0); i < totalElements; i++ {
- strings[int32(i)], _ = safeArrayGetElementString(sac.Array, i)
- }
-
- return
-}
-
-func (sac *SafeArrayConversion) ToByteArray() (bytes []byte) {
- totalElements, _ := sac.TotalElements(0)
- bytes = make([]byte, totalElements)
-
- for i := int64(0); i < totalElements; i++ {
- safeArrayGetElement(sac.Array, i, unsafe.Pointer(&bytes[int32(i)]))
- }
-
- return
-}
-
-func (sac *SafeArrayConversion) ToValueArray() (values []interface{}) {
- totalElements, _ := sac.TotalElements(0)
- values = make([]interface{}, totalElements)
- vt, _ := safeArrayGetVartype(sac.Array)
-
- for i := 0; i < int(totalElements); i++ {
- switch VT(vt) {
- case VT_BOOL:
- var v bool
- safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v))
- values[i] = v
- case VT_I1:
- var v int8
- safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v))
- values[i] = v
- case VT_I2:
- var v int16
- safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v))
- values[i] = v
- case VT_I4:
- var v int32
- safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v))
- values[i] = v
- case VT_I8:
- var v int64
- safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v))
- values[i] = v
- case VT_UI1:
- var v uint8
- safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v))
- values[i] = v
- case VT_UI2:
- var v uint16
- safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v))
- values[i] = v
- case VT_UI4:
- var v uint32
- safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v))
- values[i] = v
- case VT_UI8:
- var v uint64
- safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v))
- values[i] = v
- case VT_R4:
- var v float32
- safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v))
- values[i] = v
- case VT_R8:
- var v float64
- safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v))
- values[i] = v
- case VT_BSTR:
- var v string
- safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v))
- values[i] = v
- case VT_VARIANT:
- var v VARIANT
- safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v))
- values[i] = v.Value()
- default:
- // TODO
- }
- }
-
- return
-}
-
-func (sac *SafeArrayConversion) GetType() (varType uint16, err error) {
- return safeArrayGetVartype(sac.Array)
-}
-
-func (sac *SafeArrayConversion) GetDimensions() (dimensions *uint32, err error) {
- return safeArrayGetDim(sac.Array)
-}
-
-func (sac *SafeArrayConversion) GetSize() (length *uint32, err error) {
- return safeArrayGetElementSize(sac.Array)
-}
-
-func (sac *SafeArrayConversion) TotalElements(index uint32) (totalElements int64, err error) {
- if index < 1 {
- index = 1
- }
-
- // Get array bounds
- var LowerBounds int64
- var UpperBounds int64
-
- LowerBounds, err = safeArrayGetLBound(sac.Array, index)
- if err != nil {
- return
- }
-
- UpperBounds, err = safeArrayGetUBound(sac.Array, index)
- if err != nil {
- return
- }
-
- totalElements = UpperBounds - LowerBounds + 1
- return
-}
-
-// Release Safe Array memory
-func (sac *SafeArrayConversion) Release() {
- safeArrayDestroy(sac.Array)
-}
diff --git a/vendor/github.com/go-ole/go-ole/safearrayslices.go b/vendor/github.com/go-ole/go-ole/safearrayslices.go
deleted file mode 100644
index a9fa885..0000000
--- a/vendor/github.com/go-ole/go-ole/safearrayslices.go
+++ /dev/null
@@ -1,33 +0,0 @@
-// +build windows
-
-package ole
-
-import (
- "unsafe"
-)
-
-func safeArrayFromByteSlice(slice []byte) *SafeArray {
- array, _ := safeArrayCreateVector(VT_UI1, 0, uint32(len(slice)))
-
- if array == nil {
- panic("Could not convert []byte to SAFEARRAY")
- }
-
- for i, v := range slice {
- safeArrayPutElement(array, int64(i), uintptr(unsafe.Pointer(&v)))
- }
- return array
-}
-
-func safeArrayFromStringSlice(slice []string) *SafeArray {
- array, _ := safeArrayCreateVector(VT_BSTR, 0, uint32(len(slice)))
-
- if array == nil {
- panic("Could not convert []string to SAFEARRAY")
- }
- // SysAllocStringLen(s)
- for i, v := range slice {
- safeArrayPutElement(array, int64(i), uintptr(unsafe.Pointer(SysAllocStringLen(v))))
- }
- return array
-}
diff --git a/vendor/github.com/go-ole/go-ole/utility.go b/vendor/github.com/go-ole/go-ole/utility.go
deleted file mode 100644
index 99ee82d..0000000
--- a/vendor/github.com/go-ole/go-ole/utility.go
+++ /dev/null
@@ -1,101 +0,0 @@
-package ole
-
-import (
- "unicode/utf16"
- "unsafe"
-)
-
-// ClassIDFrom retrieves class ID whether given is program ID or application string.
-//
-// Helper that provides check against both Class ID from Program ID and Class ID from string. It is
-// faster, if you know which you are using, to use the individual functions, but this will check
-// against available functions for you.
-func ClassIDFrom(programID string) (classID *GUID, err error) {
- classID, err = CLSIDFromProgID(programID)
- if err != nil {
- classID, err = CLSIDFromString(programID)
- if err != nil {
- return
- }
- }
- return
-}
-
-// BytePtrToString converts byte pointer to a Go string.
-func BytePtrToString(p *byte) string {
- a := (*[10000]uint8)(unsafe.Pointer(p))
- i := 0
- for a[i] != 0 {
- i++
- }
- return string(a[:i])
-}
-
-// UTF16PtrToString is alias for LpOleStrToString.
-//
-// Kept for compatibility reasons.
-func UTF16PtrToString(p *uint16) string {
- return LpOleStrToString(p)
-}
-
-// LpOleStrToString converts COM Unicode to Go string.
-func LpOleStrToString(p *uint16) string {
- if p == nil {
- return ""
- }
-
- length := lpOleStrLen(p)
- a := make([]uint16, length)
-
- ptr := unsafe.Pointer(p)
-
- for i := 0; i < int(length); i++ {
- a[i] = *(*uint16)(ptr)
- ptr = unsafe.Pointer(uintptr(ptr) + 2)
- }
-
- return string(utf16.Decode(a))
-}
-
-// BstrToString converts COM binary string to Go string.
-func BstrToString(p *uint16) string {
- if p == nil {
- return ""
- }
- length := SysStringLen((*int16)(unsafe.Pointer(p)))
- a := make([]uint16, length)
-
- ptr := unsafe.Pointer(p)
-
- for i := 0; i < int(length); i++ {
- a[i] = *(*uint16)(ptr)
- ptr = unsafe.Pointer(uintptr(ptr) + 2)
- }
- return string(utf16.Decode(a))
-}
-
-// lpOleStrLen returns the length of Unicode string.
-func lpOleStrLen(p *uint16) (length int64) {
- if p == nil {
- return 0
- }
-
- ptr := unsafe.Pointer(p)
-
- for i := 0; ; i++ {
- if 0 == *(*uint16)(ptr) {
- length = int64(i)
- break
- }
- ptr = unsafe.Pointer(uintptr(ptr) + 2)
- }
- return
-}
-
-// convertHresultToError converts syscall to error, if call is unsuccessful.
-func convertHresultToError(hr uintptr, r2 uintptr, ignore error) (err error) {
- if hr != 0 {
- err = NewError(hr)
- }
- return
-}
diff --git a/vendor/github.com/go-ole/go-ole/variables.go b/vendor/github.com/go-ole/go-ole/variables.go
deleted file mode 100644
index ebe00f1..0000000
--- a/vendor/github.com/go-ole/go-ole/variables.go
+++ /dev/null
@@ -1,16 +0,0 @@
-// +build windows
-
-package ole
-
-import (
- "syscall"
-)
-
-var (
- modcombase = syscall.NewLazyDLL("combase.dll")
- modkernel32, _ = syscall.LoadDLL("kernel32.dll")
- modole32, _ = syscall.LoadDLL("ole32.dll")
- modoleaut32, _ = syscall.LoadDLL("oleaut32.dll")
- modmsvcrt, _ = syscall.LoadDLL("msvcrt.dll")
- moduser32, _ = syscall.LoadDLL("user32.dll")
-)
diff --git a/vendor/github.com/go-ole/go-ole/variant.go b/vendor/github.com/go-ole/go-ole/variant.go
deleted file mode 100644
index 3696972..0000000
--- a/vendor/github.com/go-ole/go-ole/variant.go
+++ /dev/null
@@ -1,105 +0,0 @@
-package ole
-
-import "unsafe"
-
-// NewVariant returns new variant based on type and value.
-func NewVariant(vt VT, val int64) VARIANT {
- return VARIANT{VT: vt, Val: val}
-}
-
-// ToIUnknown converts Variant to Unknown object.
-func (v *VARIANT) ToIUnknown() *IUnknown {
- if v.VT != VT_UNKNOWN {
- return nil
- }
- return (*IUnknown)(unsafe.Pointer(uintptr(v.Val)))
-}
-
-// ToIDispatch converts variant to dispatch object.
-func (v *VARIANT) ToIDispatch() *IDispatch {
- if v.VT != VT_DISPATCH {
- return nil
- }
- return (*IDispatch)(unsafe.Pointer(uintptr(v.Val)))
-}
-
-// ToArray converts variant to SafeArray helper.
-func (v *VARIANT) ToArray() *SafeArrayConversion {
- if v.VT != VT_SAFEARRAY {
- if v.VT&VT_ARRAY == 0 {
- return nil
- }
- }
- var safeArray *SafeArray = (*SafeArray)(unsafe.Pointer(uintptr(v.Val)))
- return &SafeArrayConversion{safeArray}
-}
-
-// ToString converts variant to Go string.
-func (v *VARIANT) ToString() string {
- if v.VT != VT_BSTR {
- return ""
- }
- return BstrToString(*(**uint16)(unsafe.Pointer(&v.Val)))
-}
-
-// Clear the memory of variant object.
-func (v *VARIANT) Clear() error {
- return VariantClear(v)
-}
-
-// Value returns variant value based on its type.
-//
-// Currently supported types: 2- and 4-byte integers, strings, bools.
-// Note that 64-bit integers, datetimes, and other types are stored as strings
-// and will be returned as strings.
-//
-// Needs to be further converted, because this returns an interface{}.
-func (v *VARIANT) Value() interface{} {
- switch v.VT {
- case VT_I1:
- return int8(v.Val)
- case VT_UI1:
- return uint8(v.Val)
- case VT_I2:
- return int16(v.Val)
- case VT_UI2:
- return uint16(v.Val)
- case VT_I4:
- return int32(v.Val)
- case VT_UI4:
- return uint32(v.Val)
- case VT_I8:
- return int64(v.Val)
- case VT_UI8:
- return uint64(v.Val)
- case VT_INT:
- return int(v.Val)
- case VT_UINT:
- return uint(v.Val)
- case VT_INT_PTR:
- return uintptr(v.Val) // TODO
- case VT_UINT_PTR:
- return uintptr(v.Val)
- case VT_R4:
- return *(*float32)(unsafe.Pointer(&v.Val))
- case VT_R8:
- return *(*float64)(unsafe.Pointer(&v.Val))
- case VT_BSTR:
- return v.ToString()
- case VT_DATE:
- // VT_DATE type will either return float64 or time.Time.
- d := float64(v.Val)
- date, err := GetVariantDate(d)
- if err != nil {
- return d
- }
- return date
- case VT_UNKNOWN:
- return v.ToIUnknown()
- case VT_DISPATCH:
- return v.ToIDispatch()
- case VT_BOOL:
- return v.Val != 0
- }
- return nil
-}
diff --git a/vendor/github.com/go-ole/go-ole/variant_386.go b/vendor/github.com/go-ole/go-ole/variant_386.go
deleted file mode 100644
index e73736b..0000000
--- a/vendor/github.com/go-ole/go-ole/variant_386.go
+++ /dev/null
@@ -1,11 +0,0 @@
-// +build 386
-
-package ole
-
-type VARIANT struct {
- VT VT // 2
- wReserved1 uint16 // 4
- wReserved2 uint16 // 6
- wReserved3 uint16 // 8
- Val int64 // 16
-}
diff --git a/vendor/github.com/go-ole/go-ole/variant_amd64.go b/vendor/github.com/go-ole/go-ole/variant_amd64.go
deleted file mode 100644
index dccdde1..0000000
--- a/vendor/github.com/go-ole/go-ole/variant_amd64.go
+++ /dev/null
@@ -1,12 +0,0 @@
-// +build amd64
-
-package ole
-
-type VARIANT struct {
- VT VT // 2
- wReserved1 uint16 // 4
- wReserved2 uint16 // 6
- wReserved3 uint16 // 8
- Val int64 // 16
- _ [8]byte // 24
-}
diff --git a/vendor/github.com/go-ole/go-ole/variant_s390x.go b/vendor/github.com/go-ole/go-ole/variant_s390x.go
deleted file mode 100644
index 9874ca6..0000000
--- a/vendor/github.com/go-ole/go-ole/variant_s390x.go
+++ /dev/null
@@ -1,12 +0,0 @@
-// +build s390x
-
-package ole
-
-type VARIANT struct {
- VT VT // 2
- wReserved1 uint16 // 4
- wReserved2 uint16 // 6
- wReserved3 uint16 // 8
- Val int64 // 16
- _ [8]byte // 24
-}
diff --git a/vendor/github.com/go-ole/go-ole/vt_string.go b/vendor/github.com/go-ole/go-ole/vt_string.go
deleted file mode 100644
index 729b4a0..0000000
--- a/vendor/github.com/go-ole/go-ole/vt_string.go
+++ /dev/null
@@ -1,58 +0,0 @@
-// generated by stringer -output vt_string.go -type VT; DO NOT EDIT
-
-package ole
-
-import "fmt"
-
-const (
- _VT_name_0 = "VT_EMPTYVT_NULLVT_I2VT_I4VT_R4VT_R8VT_CYVT_DATEVT_BSTRVT_DISPATCHVT_ERRORVT_BOOLVT_VARIANTVT_UNKNOWNVT_DECIMAL"
- _VT_name_1 = "VT_I1VT_UI1VT_UI2VT_UI4VT_I8VT_UI8VT_INTVT_UINTVT_VOIDVT_HRESULTVT_PTRVT_SAFEARRAYVT_CARRAYVT_USERDEFINEDVT_LPSTRVT_LPWSTR"
- _VT_name_2 = "VT_RECORDVT_INT_PTRVT_UINT_PTR"
- _VT_name_3 = "VT_FILETIMEVT_BLOBVT_STREAMVT_STORAGEVT_STREAMED_OBJECTVT_STORED_OBJECTVT_BLOB_OBJECTVT_CFVT_CLSID"
- _VT_name_4 = "VT_BSTR_BLOBVT_VECTOR"
- _VT_name_5 = "VT_ARRAY"
- _VT_name_6 = "VT_BYREF"
- _VT_name_7 = "VT_RESERVED"
- _VT_name_8 = "VT_ILLEGAL"
-)
-
-var (
- _VT_index_0 = [...]uint8{0, 8, 15, 20, 25, 30, 35, 40, 47, 54, 65, 73, 80, 90, 100, 110}
- _VT_index_1 = [...]uint8{0, 5, 11, 17, 23, 28, 34, 40, 47, 54, 64, 70, 82, 91, 105, 113, 122}
- _VT_index_2 = [...]uint8{0, 9, 19, 30}
- _VT_index_3 = [...]uint8{0, 11, 18, 27, 37, 55, 71, 85, 90, 98}
- _VT_index_4 = [...]uint8{0, 12, 21}
- _VT_index_5 = [...]uint8{0, 8}
- _VT_index_6 = [...]uint8{0, 8}
- _VT_index_7 = [...]uint8{0, 11}
- _VT_index_8 = [...]uint8{0, 10}
-)
-
-func (i VT) String() string {
- switch {
- case 0 <= i && i <= 14:
- return _VT_name_0[_VT_index_0[i]:_VT_index_0[i+1]]
- case 16 <= i && i <= 31:
- i -= 16
- return _VT_name_1[_VT_index_1[i]:_VT_index_1[i+1]]
- case 36 <= i && i <= 38:
- i -= 36
- return _VT_name_2[_VT_index_2[i]:_VT_index_2[i+1]]
- case 64 <= i && i <= 72:
- i -= 64
- return _VT_name_3[_VT_index_3[i]:_VT_index_3[i+1]]
- case 4095 <= i && i <= 4096:
- i -= 4095
- return _VT_name_4[_VT_index_4[i]:_VT_index_4[i+1]]
- case i == 8192:
- return _VT_name_5
- case i == 16384:
- return _VT_name_6
- case i == 32768:
- return _VT_name_7
- case i == 65535:
- return _VT_name_8
- default:
- return fmt.Sprintf("VT(%d)", i)
- }
-}
diff --git a/vendor/github.com/go-ole/go-ole/winrt.go b/vendor/github.com/go-ole/go-ole/winrt.go
deleted file mode 100644
index 4e9eca7..0000000
--- a/vendor/github.com/go-ole/go-ole/winrt.go
+++ /dev/null
@@ -1,99 +0,0 @@
-// +build windows
-
-package ole
-
-import (
- "reflect"
- "syscall"
- "unicode/utf8"
- "unsafe"
-)
-
-var (
- procRoInitialize = modcombase.NewProc("RoInitialize")
- procRoActivateInstance = modcombase.NewProc("RoActivateInstance")
- procRoGetActivationFactory = modcombase.NewProc("RoGetActivationFactory")
- procWindowsCreateString = modcombase.NewProc("WindowsCreateString")
- procWindowsDeleteString = modcombase.NewProc("WindowsDeleteString")
- procWindowsGetStringRawBuffer = modcombase.NewProc("WindowsGetStringRawBuffer")
-)
-
-func RoInitialize(thread_type uint32) (err error) {
- hr, _, _ := procRoInitialize.Call(uintptr(thread_type))
- if hr != 0 {
- err = NewError(hr)
- }
- return
-}
-
-func RoActivateInstance(clsid string) (ins *IInspectable, err error) {
- hClsid, err := NewHString(clsid)
- if err != nil {
- return nil, err
- }
- defer DeleteHString(hClsid)
-
- hr, _, _ := procRoActivateInstance.Call(
- uintptr(unsafe.Pointer(hClsid)),
- uintptr(unsafe.Pointer(&ins)))
- if hr != 0 {
- err = NewError(hr)
- }
- return
-}
-
-func RoGetActivationFactory(clsid string, iid *GUID) (ins *IInspectable, err error) {
- hClsid, err := NewHString(clsid)
- if err != nil {
- return nil, err
- }
- defer DeleteHString(hClsid)
-
- hr, _, _ := procRoGetActivationFactory.Call(
- uintptr(unsafe.Pointer(hClsid)),
- uintptr(unsafe.Pointer(iid)),
- uintptr(unsafe.Pointer(&ins)))
- if hr != 0 {
- err = NewError(hr)
- }
- return
-}
-
-// HString is handle string for pointers.
-type HString uintptr
-
-// NewHString returns a new HString for Go string.
-func NewHString(s string) (hstring HString, err error) {
- u16 := syscall.StringToUTF16Ptr(s)
- len := uint32(utf8.RuneCountInString(s))
- hr, _, _ := procWindowsCreateString.Call(
- uintptr(unsafe.Pointer(u16)),
- uintptr(len),
- uintptr(unsafe.Pointer(&hstring)))
- if hr != 0 {
- err = NewError(hr)
- }
- return
-}
-
-// DeleteHString deletes HString.
-func DeleteHString(hstring HString) (err error) {
- hr, _, _ := procWindowsDeleteString.Call(uintptr(hstring))
- if hr != 0 {
- err = NewError(hr)
- }
- return
-}
-
-// String returns Go string value of HString.
-func (h HString) String() string {
- var u16buf uintptr
- var u16len uint32
- u16buf, _, _ = procWindowsGetStringRawBuffer.Call(
- uintptr(h),
- uintptr(unsafe.Pointer(&u16len)))
-
- u16hdr := reflect.SliceHeader{Data: u16buf, Len: int(u16len), Cap: int(u16len)}
- u16 := *(*[]uint16)(unsafe.Pointer(&u16hdr))
- return syscall.UTF16ToString(u16)
-}
diff --git a/vendor/github.com/go-ole/go-ole/winrt_doc.go b/vendor/github.com/go-ole/go-ole/winrt_doc.go
deleted file mode 100644
index 52e6d74..0000000
--- a/vendor/github.com/go-ole/go-ole/winrt_doc.go
+++ /dev/null
@@ -1,36 +0,0 @@
-// +build !windows
-
-package ole
-
-// RoInitialize
-func RoInitialize(thread_type uint32) (err error) {
- return NewError(E_NOTIMPL)
-}
-
-// RoActivateInstance
-func RoActivateInstance(clsid string) (ins *IInspectable, err error) {
- return nil, NewError(E_NOTIMPL)
-}
-
-// RoGetActivationFactory
-func RoGetActivationFactory(clsid string, iid *GUID) (ins *IInspectable, err error) {
- return nil, NewError(E_NOTIMPL)
-}
-
-// HString is handle string for pointers.
-type HString uintptr
-
-// NewHString returns a new HString for Go string.
-func NewHString(s string) (hstring HString, err error) {
- return HString(uintptr(0)), NewError(E_NOTIMPL)
-}
-
-// DeleteHString deletes HString.
-func DeleteHString(hstring HString) (err error) {
- return NewError(E_NOTIMPL)
-}
-
-// String returns Go string value of HString.
-func (h HString) String() string {
- return ""
-}
diff --git a/vendor/github.com/mattn/go-runewidth/.travis.yml b/vendor/github.com/mattn/go-runewidth/.travis.yml
deleted file mode 100644
index 5c9c2a3..0000000
--- a/vendor/github.com/mattn/go-runewidth/.travis.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-language: go
-go:
- - tip
-before_install:
- - go get github.com/mattn/goveralls
- - go get golang.org/x/tools/cmd/cover
-script:
- - $HOME/gopath/bin/goveralls -repotoken lAKAWPzcGsD3A8yBX3BGGtRUdJ6CaGERL
diff --git a/vendor/github.com/mattn/go-runewidth/LICENSE b/vendor/github.com/mattn/go-runewidth/LICENSE
deleted file mode 100644
index 91b5cef..0000000
--- a/vendor/github.com/mattn/go-runewidth/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) 2016 Yasuhiro Matsumoto
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/vendor/github.com/mattn/go-runewidth/README.mkd b/vendor/github.com/mattn/go-runewidth/README.mkd
deleted file mode 100644
index 66663a9..0000000
--- a/vendor/github.com/mattn/go-runewidth/README.mkd
+++ /dev/null
@@ -1,27 +0,0 @@
-go-runewidth
-============
-
-[](https://travis-ci.org/mattn/go-runewidth)
-[](https://coveralls.io/r/mattn/go-runewidth?branch=HEAD)
-[](http://godoc.org/github.com/mattn/go-runewidth)
-[](https://goreportcard.com/report/github.com/mattn/go-runewidth)
-
-Provides functions to get fixed width of the character or string.
-
-Usage
------
-
-```go
-runewidth.StringWidth("つのだ☆HIRO") == 12
-```
-
-
-Author
-------
-
-Yasuhiro Matsumoto
-
-License
--------
-
-under the MIT License: http://mattn.mit-license.org/2013
diff --git a/vendor/github.com/mattn/go-runewidth/runewidth.go b/vendor/github.com/mattn/go-runewidth/runewidth.go
deleted file mode 100644
index 2164497..0000000
--- a/vendor/github.com/mattn/go-runewidth/runewidth.go
+++ /dev/null
@@ -1,1223 +0,0 @@
-package runewidth
-
-var (
- // EastAsianWidth will be set true if the current locale is CJK
- EastAsianWidth = IsEastAsian()
-
- // DefaultCondition is a condition in current locale
- DefaultCondition = &Condition{EastAsianWidth}
-)
-
-type interval struct {
- first rune
- last rune
-}
-
-type table []interval
-
-func inTables(r rune, ts ...table) bool {
- for _, t := range ts {
- if inTable(r, t) {
- return true
- }
- }
- return false
-}
-
-func inTable(r rune, t table) bool {
- // func (t table) IncludesRune(r rune) bool {
- if r < t[0].first {
- return false
- }
-
- bot := 0
- top := len(t) - 1
- for top >= bot {
- mid := (bot + top) / 2
-
- switch {
- case t[mid].last < r:
- bot = mid + 1
- case t[mid].first > r:
- top = mid - 1
- default:
- return true
- }
- }
-
- return false
-}
-
-var private = table{
- {0x00E000, 0x00F8FF}, {0x0F0000, 0x0FFFFD}, {0x100000, 0x10FFFD},
-}
-
-var nonprint = table{
- {0x0000, 0x001F}, {0x007F, 0x009F}, {0x00AD, 0x00AD},
- {0x070F, 0x070F}, {0x180B, 0x180E}, {0x200B, 0x200F},
- {0x202A, 0x202E}, {0x206A, 0x206F}, {0xD800, 0xDFFF},
- {0xFEFF, 0xFEFF}, {0xFFF9, 0xFFFB}, {0xFFFE, 0xFFFF},
-}
-
-var combining = table{
- {0x0300, 0x036F}, {0x0483, 0x0489}, {0x0591, 0x05BD},
- {0x05BF, 0x05BF}, {0x05C1, 0x05C2}, {0x05C4, 0x05C5},
- {0x05C7, 0x05C7}, {0x0610, 0x061A}, {0x064B, 0x065F},
- {0x0670, 0x0670}, {0x06D6, 0x06DC}, {0x06DF, 0x06E4},
- {0x06E7, 0x06E8}, {0x06EA, 0x06ED}, {0x0711, 0x0711},
- {0x0730, 0x074A}, {0x07A6, 0x07B0}, {0x07EB, 0x07F3},
- {0x0816, 0x0819}, {0x081B, 0x0823}, {0x0825, 0x0827},
- {0x0829, 0x082D}, {0x0859, 0x085B}, {0x08D4, 0x08E1},
- {0x08E3, 0x0903}, {0x093A, 0x093C}, {0x093E, 0x094F},
- {0x0951, 0x0957}, {0x0962, 0x0963}, {0x0981, 0x0983},
- {0x09BC, 0x09BC}, {0x09BE, 0x09C4}, {0x09C7, 0x09C8},
- {0x09CB, 0x09CD}, {0x09D7, 0x09D7}, {0x09E2, 0x09E3},
- {0x0A01, 0x0A03}, {0x0A3C, 0x0A3C}, {0x0A3E, 0x0A42},
- {0x0A47, 0x0A48}, {0x0A4B, 0x0A4D}, {0x0A51, 0x0A51},
- {0x0A70, 0x0A71}, {0x0A75, 0x0A75}, {0x0A81, 0x0A83},
- {0x0ABC, 0x0ABC}, {0x0ABE, 0x0AC5}, {0x0AC7, 0x0AC9},
- {0x0ACB, 0x0ACD}, {0x0AE2, 0x0AE3}, {0x0B01, 0x0B03},
- {0x0B3C, 0x0B3C}, {0x0B3E, 0x0B44}, {0x0B47, 0x0B48},
- {0x0B4B, 0x0B4D}, {0x0B56, 0x0B57}, {0x0B62, 0x0B63},
- {0x0B82, 0x0B82}, {0x0BBE, 0x0BC2}, {0x0BC6, 0x0BC8},
- {0x0BCA, 0x0BCD}, {0x0BD7, 0x0BD7}, {0x0C00, 0x0C03},
- {0x0C3E, 0x0C44}, {0x0C46, 0x0C48}, {0x0C4A, 0x0C4D},
- {0x0C55, 0x0C56}, {0x0C62, 0x0C63}, {0x0C81, 0x0C83},
- {0x0CBC, 0x0CBC}, {0x0CBE, 0x0CC4}, {0x0CC6, 0x0CC8},
- {0x0CCA, 0x0CCD}, {0x0CD5, 0x0CD6}, {0x0CE2, 0x0CE3},
- {0x0D01, 0x0D03}, {0x0D3E, 0x0D44}, {0x0D46, 0x0D48},
- {0x0D4A, 0x0D4D}, {0x0D57, 0x0D57}, {0x0D62, 0x0D63},
- {0x0D82, 0x0D83}, {0x0DCA, 0x0DCA}, {0x0DCF, 0x0DD4},
- {0x0DD6, 0x0DD6}, {0x0DD8, 0x0DDF}, {0x0DF2, 0x0DF3},
- {0x0E31, 0x0E31}, {0x0E34, 0x0E3A}, {0x0E47, 0x0E4E},
- {0x0EB1, 0x0EB1}, {0x0EB4, 0x0EB9}, {0x0EBB, 0x0EBC},
- {0x0EC8, 0x0ECD}, {0x0F18, 0x0F19}, {0x0F35, 0x0F35},
- {0x0F37, 0x0F37}, {0x0F39, 0x0F39}, {0x0F3E, 0x0F3F},
- {0x0F71, 0x0F84}, {0x0F86, 0x0F87}, {0x0F8D, 0x0F97},
- {0x0F99, 0x0FBC}, {0x0FC6, 0x0FC6}, {0x102B, 0x103E},
- {0x1056, 0x1059}, {0x105E, 0x1060}, {0x1062, 0x1064},
- {0x1067, 0x106D}, {0x1071, 0x1074}, {0x1082, 0x108D},
- {0x108F, 0x108F}, {0x109A, 0x109D}, {0x135D, 0x135F},
- {0x1712, 0x1714}, {0x1732, 0x1734}, {0x1752, 0x1753},
- {0x1772, 0x1773}, {0x17B4, 0x17D3}, {0x17DD, 0x17DD},
- {0x180B, 0x180D}, {0x1885, 0x1886}, {0x18A9, 0x18A9},
- {0x1920, 0x192B}, {0x1930, 0x193B}, {0x1A17, 0x1A1B},
- {0x1A55, 0x1A5E}, {0x1A60, 0x1A7C}, {0x1A7F, 0x1A7F},
- {0x1AB0, 0x1ABE}, {0x1B00, 0x1B04}, {0x1B34, 0x1B44},
- {0x1B6B, 0x1B73}, {0x1B80, 0x1B82}, {0x1BA1, 0x1BAD},
- {0x1BE6, 0x1BF3}, {0x1C24, 0x1C37}, {0x1CD0, 0x1CD2},
- {0x1CD4, 0x1CE8}, {0x1CED, 0x1CED}, {0x1CF2, 0x1CF4},
- {0x1CF8, 0x1CF9}, {0x1DC0, 0x1DF5}, {0x1DFB, 0x1DFF},
- {0x20D0, 0x20F0}, {0x2CEF, 0x2CF1}, {0x2D7F, 0x2D7F},
- {0x2DE0, 0x2DFF}, {0x302A, 0x302F}, {0x3099, 0x309A},
- {0xA66F, 0xA672}, {0xA674, 0xA67D}, {0xA69E, 0xA69F},
- {0xA6F0, 0xA6F1}, {0xA802, 0xA802}, {0xA806, 0xA806},
- {0xA80B, 0xA80B}, {0xA823, 0xA827}, {0xA880, 0xA881},
- {0xA8B4, 0xA8C5}, {0xA8E0, 0xA8F1}, {0xA926, 0xA92D},
- {0xA947, 0xA953}, {0xA980, 0xA983}, {0xA9B3, 0xA9C0},
- {0xA9E5, 0xA9E5}, {0xAA29, 0xAA36}, {0xAA43, 0xAA43},
- {0xAA4C, 0xAA4D}, {0xAA7B, 0xAA7D}, {0xAAB0, 0xAAB0},
- {0xAAB2, 0xAAB4}, {0xAAB7, 0xAAB8}, {0xAABE, 0xAABF},
- {0xAAC1, 0xAAC1}, {0xAAEB, 0xAAEF}, {0xAAF5, 0xAAF6},
- {0xABE3, 0xABEA}, {0xABEC, 0xABED}, {0xFB1E, 0xFB1E},
- {0xFE00, 0xFE0F}, {0xFE20, 0xFE2F}, {0x101FD, 0x101FD},
- {0x102E0, 0x102E0}, {0x10376, 0x1037A}, {0x10A01, 0x10A03},
- {0x10A05, 0x10A06}, {0x10A0C, 0x10A0F}, {0x10A38, 0x10A3A},
- {0x10A3F, 0x10A3F}, {0x10AE5, 0x10AE6}, {0x11000, 0x11002},
- {0x11038, 0x11046}, {0x1107F, 0x11082}, {0x110B0, 0x110BA},
- {0x11100, 0x11102}, {0x11127, 0x11134}, {0x11173, 0x11173},
- {0x11180, 0x11182}, {0x111B3, 0x111C0}, {0x111CA, 0x111CC},
- {0x1122C, 0x11237}, {0x1123E, 0x1123E}, {0x112DF, 0x112EA},
- {0x11300, 0x11303}, {0x1133C, 0x1133C}, {0x1133E, 0x11344},
- {0x11347, 0x11348}, {0x1134B, 0x1134D}, {0x11357, 0x11357},
- {0x11362, 0x11363}, {0x11366, 0x1136C}, {0x11370, 0x11374},
- {0x11435, 0x11446}, {0x114B0, 0x114C3}, {0x115AF, 0x115B5},
- {0x115B8, 0x115C0}, {0x115DC, 0x115DD}, {0x11630, 0x11640},
- {0x116AB, 0x116B7}, {0x1171D, 0x1172B}, {0x11C2F, 0x11C36},
- {0x11C38, 0x11C3F}, {0x11C92, 0x11CA7}, {0x11CA9, 0x11CB6},
- {0x16AF0, 0x16AF4}, {0x16B30, 0x16B36}, {0x16F51, 0x16F7E},
- {0x16F8F, 0x16F92}, {0x1BC9D, 0x1BC9E}, {0x1D165, 0x1D169},
- {0x1D16D, 0x1D172}, {0x1D17B, 0x1D182}, {0x1D185, 0x1D18B},
- {0x1D1AA, 0x1D1AD}, {0x1D242, 0x1D244}, {0x1DA00, 0x1DA36},
- {0x1DA3B, 0x1DA6C}, {0x1DA75, 0x1DA75}, {0x1DA84, 0x1DA84},
- {0x1DA9B, 0x1DA9F}, {0x1DAA1, 0x1DAAF}, {0x1E000, 0x1E006},
- {0x1E008, 0x1E018}, {0x1E01B, 0x1E021}, {0x1E023, 0x1E024},
- {0x1E026, 0x1E02A}, {0x1E8D0, 0x1E8D6}, {0x1E944, 0x1E94A},
- {0xE0100, 0xE01EF},
-}
-
-var doublewidth = table{
- {0x1100, 0x115F}, {0x231A, 0x231B}, {0x2329, 0x232A},
- {0x23E9, 0x23EC}, {0x23F0, 0x23F0}, {0x23F3, 0x23F3},
- {0x25FD, 0x25FE}, {0x2614, 0x2615}, {0x2648, 0x2653},
- {0x267F, 0x267F}, {0x2693, 0x2693}, {0x26A1, 0x26A1},
- {0x26AA, 0x26AB}, {0x26BD, 0x26BE}, {0x26C4, 0x26C5},
- {0x26CE, 0x26CE}, {0x26D4, 0x26D4}, {0x26EA, 0x26EA},
- {0x26F2, 0x26F3}, {0x26F5, 0x26F5}, {0x26FA, 0x26FA},
- {0x26FD, 0x26FD}, {0x2705, 0x2705}, {0x270A, 0x270B},
- {0x2728, 0x2728}, {0x274C, 0x274C}, {0x274E, 0x274E},
- {0x2753, 0x2755}, {0x2757, 0x2757}, {0x2795, 0x2797},
- {0x27B0, 0x27B0}, {0x27BF, 0x27BF}, {0x2B1B, 0x2B1C},
- {0x2B50, 0x2B50}, {0x2B55, 0x2B55}, {0x2E80, 0x2E99},
- {0x2E9B, 0x2EF3}, {0x2F00, 0x2FD5}, {0x2FF0, 0x2FFB},
- {0x3000, 0x303E}, {0x3041, 0x3096}, {0x3099, 0x30FF},
- {0x3105, 0x312D}, {0x3131, 0x318E}, {0x3190, 0x31BA},
- {0x31C0, 0x31E3}, {0x31F0, 0x321E}, {0x3220, 0x3247},
- {0x3250, 0x32FE}, {0x3300, 0x4DBF}, {0x4E00, 0xA48C},
- {0xA490, 0xA4C6}, {0xA960, 0xA97C}, {0xAC00, 0xD7A3},
- {0xF900, 0xFAFF}, {0xFE10, 0xFE19}, {0xFE30, 0xFE52},
- {0xFE54, 0xFE66}, {0xFE68, 0xFE6B}, {0xFF01, 0xFF60},
- {0xFFE0, 0xFFE6}, {0x16FE0, 0x16FE0}, {0x17000, 0x187EC},
- {0x18800, 0x18AF2}, {0x1B000, 0x1B001}, {0x1F004, 0x1F004},
- {0x1F0CF, 0x1F0CF}, {0x1F18E, 0x1F18E}, {0x1F191, 0x1F19A},
- {0x1F200, 0x1F202}, {0x1F210, 0x1F23B}, {0x1F240, 0x1F248},
- {0x1F250, 0x1F251}, {0x1F300, 0x1F320}, {0x1F32D, 0x1F335},
- {0x1F337, 0x1F37C}, {0x1F37E, 0x1F393}, {0x1F3A0, 0x1F3CA},
- {0x1F3CF, 0x1F3D3}, {0x1F3E0, 0x1F3F0}, {0x1F3F4, 0x1F3F4},
- {0x1F3F8, 0x1F43E}, {0x1F440, 0x1F440}, {0x1F442, 0x1F4FC},
- {0x1F4FF, 0x1F53D}, {0x1F54B, 0x1F54E}, {0x1F550, 0x1F567},
- {0x1F57A, 0x1F57A}, {0x1F595, 0x1F596}, {0x1F5A4, 0x1F5A4},
- {0x1F5FB, 0x1F64F}, {0x1F680, 0x1F6C5}, {0x1F6CC, 0x1F6CC},
- {0x1F6D0, 0x1F6D2}, {0x1F6EB, 0x1F6EC}, {0x1F6F4, 0x1F6F6},
- {0x1F910, 0x1F91E}, {0x1F920, 0x1F927}, {0x1F930, 0x1F930},
- {0x1F933, 0x1F93E}, {0x1F940, 0x1F94B}, {0x1F950, 0x1F95E},
- {0x1F980, 0x1F991}, {0x1F9C0, 0x1F9C0}, {0x20000, 0x2FFFD},
- {0x30000, 0x3FFFD},
-}
-
-var ambiguous = table{
- {0x00A1, 0x00A1}, {0x00A4, 0x00A4}, {0x00A7, 0x00A8},
- {0x00AA, 0x00AA}, {0x00AD, 0x00AE}, {0x00B0, 0x00B4},
- {0x00B6, 0x00BA}, {0x00BC, 0x00BF}, {0x00C6, 0x00C6},
- {0x00D0, 0x00D0}, {0x00D7, 0x00D8}, {0x00DE, 0x00E1},
- {0x00E6, 0x00E6}, {0x00E8, 0x00EA}, {0x00EC, 0x00ED},
- {0x00F0, 0x00F0}, {0x00F2, 0x00F3}, {0x00F7, 0x00FA},
- {0x00FC, 0x00FC}, {0x00FE, 0x00FE}, {0x0101, 0x0101},
- {0x0111, 0x0111}, {0x0113, 0x0113}, {0x011B, 0x011B},
- {0x0126, 0x0127}, {0x012B, 0x012B}, {0x0131, 0x0133},
- {0x0138, 0x0138}, {0x013F, 0x0142}, {0x0144, 0x0144},
- {0x0148, 0x014B}, {0x014D, 0x014D}, {0x0152, 0x0153},
- {0x0166, 0x0167}, {0x016B, 0x016B}, {0x01CE, 0x01CE},
- {0x01D0, 0x01D0}, {0x01D2, 0x01D2}, {0x01D4, 0x01D4},
- {0x01D6, 0x01D6}, {0x01D8, 0x01D8}, {0x01DA, 0x01DA},
- {0x01DC, 0x01DC}, {0x0251, 0x0251}, {0x0261, 0x0261},
- {0x02C4, 0x02C4}, {0x02C7, 0x02C7}, {0x02C9, 0x02CB},
- {0x02CD, 0x02CD}, {0x02D0, 0x02D0}, {0x02D8, 0x02DB},
- {0x02DD, 0x02DD}, {0x02DF, 0x02DF}, {0x0300, 0x036F},
- {0x0391, 0x03A1}, {0x03A3, 0x03A9}, {0x03B1, 0x03C1},
- {0x03C3, 0x03C9}, {0x0401, 0x0401}, {0x0410, 0x044F},
- {0x0451, 0x0451}, {0x2010, 0x2010}, {0x2013, 0x2016},
- {0x2018, 0x2019}, {0x201C, 0x201D}, {0x2020, 0x2022},
- {0x2024, 0x2027}, {0x2030, 0x2030}, {0x2032, 0x2033},
- {0x2035, 0x2035}, {0x203B, 0x203B}, {0x203E, 0x203E},
- {0x2074, 0x2074}, {0x207F, 0x207F}, {0x2081, 0x2084},
- {0x20AC, 0x20AC}, {0x2103, 0x2103}, {0x2105, 0x2105},
- {0x2109, 0x2109}, {0x2113, 0x2113}, {0x2116, 0x2116},
- {0x2121, 0x2122}, {0x2126, 0x2126}, {0x212B, 0x212B},
- {0x2153, 0x2154}, {0x215B, 0x215E}, {0x2160, 0x216B},
- {0x2170, 0x2179}, {0x2189, 0x2189}, {0x2190, 0x2199},
- {0x21B8, 0x21B9}, {0x21D2, 0x21D2}, {0x21D4, 0x21D4},
- {0x21E7, 0x21E7}, {0x2200, 0x2200}, {0x2202, 0x2203},
- {0x2207, 0x2208}, {0x220B, 0x220B}, {0x220F, 0x220F},
- {0x2211, 0x2211}, {0x2215, 0x2215}, {0x221A, 0x221A},
- {0x221D, 0x2220}, {0x2223, 0x2223}, {0x2225, 0x2225},
- {0x2227, 0x222C}, {0x222E, 0x222E}, {0x2234, 0x2237},
- {0x223C, 0x223D}, {0x2248, 0x2248}, {0x224C, 0x224C},
- {0x2252, 0x2252}, {0x2260, 0x2261}, {0x2264, 0x2267},
- {0x226A, 0x226B}, {0x226E, 0x226F}, {0x2282, 0x2283},
- {0x2286, 0x2287}, {0x2295, 0x2295}, {0x2299, 0x2299},
- {0x22A5, 0x22A5}, {0x22BF, 0x22BF}, {0x2312, 0x2312},
- {0x2460, 0x24E9}, {0x24EB, 0x254B}, {0x2550, 0x2573},
- {0x2580, 0x258F}, {0x2592, 0x2595}, {0x25A0, 0x25A1},
- {0x25A3, 0x25A9}, {0x25B2, 0x25B3}, {0x25B6, 0x25B7},
- {0x25BC, 0x25BD}, {0x25C0, 0x25C1}, {0x25C6, 0x25C8},
- {0x25CB, 0x25CB}, {0x25CE, 0x25D1}, {0x25E2, 0x25E5},
- {0x25EF, 0x25EF}, {0x2605, 0x2606}, {0x2609, 0x2609},
- {0x260E, 0x260F}, {0x261C, 0x261C}, {0x261E, 0x261E},
- {0x2640, 0x2640}, {0x2642, 0x2642}, {0x2660, 0x2661},
- {0x2663, 0x2665}, {0x2667, 0x266A}, {0x266C, 0x266D},
- {0x266F, 0x266F}, {0x269E, 0x269F}, {0x26BF, 0x26BF},
- {0x26C6, 0x26CD}, {0x26CF, 0x26D3}, {0x26D5, 0x26E1},
- {0x26E3, 0x26E3}, {0x26E8, 0x26E9}, {0x26EB, 0x26F1},
- {0x26F4, 0x26F4}, {0x26F6, 0x26F9}, {0x26FB, 0x26FC},
- {0x26FE, 0x26FF}, {0x273D, 0x273D}, {0x2776, 0x277F},
- {0x2B56, 0x2B59}, {0x3248, 0x324F}, {0xE000, 0xF8FF},
- {0xFE00, 0xFE0F}, {0xFFFD, 0xFFFD}, {0x1F100, 0x1F10A},
- {0x1F110, 0x1F12D}, {0x1F130, 0x1F169}, {0x1F170, 0x1F18D},
- {0x1F18F, 0x1F190}, {0x1F19B, 0x1F1AC}, {0xE0100, 0xE01EF},
- {0xF0000, 0xFFFFD}, {0x100000, 0x10FFFD},
-}
-
-var emoji = table{
- {0x1F1E6, 0x1F1FF}, {0x1F321, 0x1F321}, {0x1F324, 0x1F32C},
- {0x1F336, 0x1F336}, {0x1F37D, 0x1F37D}, {0x1F396, 0x1F397},
- {0x1F399, 0x1F39B}, {0x1F39E, 0x1F39F}, {0x1F3CB, 0x1F3CE},
- {0x1F3D4, 0x1F3DF}, {0x1F3F3, 0x1F3F5}, {0x1F3F7, 0x1F3F7},
- {0x1F43F, 0x1F43F}, {0x1F441, 0x1F441}, {0x1F4FD, 0x1F4FD},
- {0x1F549, 0x1F54A}, {0x1F56F, 0x1F570}, {0x1F573, 0x1F579},
- {0x1F587, 0x1F587}, {0x1F58A, 0x1F58D}, {0x1F590, 0x1F590},
- {0x1F5A5, 0x1F5A5}, {0x1F5A8, 0x1F5A8}, {0x1F5B1, 0x1F5B2},
- {0x1F5BC, 0x1F5BC}, {0x1F5C2, 0x1F5C4}, {0x1F5D1, 0x1F5D3},
- {0x1F5DC, 0x1F5DE}, {0x1F5E1, 0x1F5E1}, {0x1F5E3, 0x1F5E3},
- {0x1F5E8, 0x1F5E8}, {0x1F5EF, 0x1F5EF}, {0x1F5F3, 0x1F5F3},
- {0x1F5FA, 0x1F5FA}, {0x1F6CB, 0x1F6CF}, {0x1F6E0, 0x1F6E5},
- {0x1F6E9, 0x1F6E9}, {0x1F6F0, 0x1F6F0}, {0x1F6F3, 0x1F6F3},
-}
-
-var notassigned = table{
- {0x0378, 0x0379}, {0x0380, 0x0383}, {0x038B, 0x038B},
- {0x038D, 0x038D}, {0x03A2, 0x03A2}, {0x0530, 0x0530},
- {0x0557, 0x0558}, {0x0560, 0x0560}, {0x0588, 0x0588},
- {0x058B, 0x058C}, {0x0590, 0x0590}, {0x05C8, 0x05CF},
- {0x05EB, 0x05EF}, {0x05F5, 0x05FF}, {0x061D, 0x061D},
- {0x070E, 0x070E}, {0x074B, 0x074C}, {0x07B2, 0x07BF},
- {0x07FB, 0x07FF}, {0x082E, 0x082F}, {0x083F, 0x083F},
- {0x085C, 0x085D}, {0x085F, 0x089F}, {0x08B5, 0x08B5},
- {0x08BE, 0x08D3}, {0x0984, 0x0984}, {0x098D, 0x098E},
- {0x0991, 0x0992}, {0x09A9, 0x09A9}, {0x09B1, 0x09B1},
- {0x09B3, 0x09B5}, {0x09BA, 0x09BB}, {0x09C5, 0x09C6},
- {0x09C9, 0x09CA}, {0x09CF, 0x09D6}, {0x09D8, 0x09DB},
- {0x09DE, 0x09DE}, {0x09E4, 0x09E5}, {0x09FC, 0x0A00},
- {0x0A04, 0x0A04}, {0x0A0B, 0x0A0E}, {0x0A11, 0x0A12},
- {0x0A29, 0x0A29}, {0x0A31, 0x0A31}, {0x0A34, 0x0A34},
- {0x0A37, 0x0A37}, {0x0A3A, 0x0A3B}, {0x0A3D, 0x0A3D},
- {0x0A43, 0x0A46}, {0x0A49, 0x0A4A}, {0x0A4E, 0x0A50},
- {0x0A52, 0x0A58}, {0x0A5D, 0x0A5D}, {0x0A5F, 0x0A65},
- {0x0A76, 0x0A80}, {0x0A84, 0x0A84}, {0x0A8E, 0x0A8E},
- {0x0A92, 0x0A92}, {0x0AA9, 0x0AA9}, {0x0AB1, 0x0AB1},
- {0x0AB4, 0x0AB4}, {0x0ABA, 0x0ABB}, {0x0AC6, 0x0AC6},
- {0x0ACA, 0x0ACA}, {0x0ACE, 0x0ACF}, {0x0AD1, 0x0ADF},
- {0x0AE4, 0x0AE5}, {0x0AF2, 0x0AF8}, {0x0AFA, 0x0B00},
- {0x0B04, 0x0B04}, {0x0B0D, 0x0B0E}, {0x0B11, 0x0B12},
- {0x0B29, 0x0B29}, {0x0B31, 0x0B31}, {0x0B34, 0x0B34},
- {0x0B3A, 0x0B3B}, {0x0B45, 0x0B46}, {0x0B49, 0x0B4A},
- {0x0B4E, 0x0B55}, {0x0B58, 0x0B5B}, {0x0B5E, 0x0B5E},
- {0x0B64, 0x0B65}, {0x0B78, 0x0B81}, {0x0B84, 0x0B84},
- {0x0B8B, 0x0B8D}, {0x0B91, 0x0B91}, {0x0B96, 0x0B98},
- {0x0B9B, 0x0B9B}, {0x0B9D, 0x0B9D}, {0x0BA0, 0x0BA2},
- {0x0BA5, 0x0BA7}, {0x0BAB, 0x0BAD}, {0x0BBA, 0x0BBD},
- {0x0BC3, 0x0BC5}, {0x0BC9, 0x0BC9}, {0x0BCE, 0x0BCF},
- {0x0BD1, 0x0BD6}, {0x0BD8, 0x0BE5}, {0x0BFB, 0x0BFF},
- {0x0C04, 0x0C04}, {0x0C0D, 0x0C0D}, {0x0C11, 0x0C11},
- {0x0C29, 0x0C29}, {0x0C3A, 0x0C3C}, {0x0C45, 0x0C45},
- {0x0C49, 0x0C49}, {0x0C4E, 0x0C54}, {0x0C57, 0x0C57},
- {0x0C5B, 0x0C5F}, {0x0C64, 0x0C65}, {0x0C70, 0x0C77},
- {0x0C84, 0x0C84}, {0x0C8D, 0x0C8D}, {0x0C91, 0x0C91},
- {0x0CA9, 0x0CA9}, {0x0CB4, 0x0CB4}, {0x0CBA, 0x0CBB},
- {0x0CC5, 0x0CC5}, {0x0CC9, 0x0CC9}, {0x0CCE, 0x0CD4},
- {0x0CD7, 0x0CDD}, {0x0CDF, 0x0CDF}, {0x0CE4, 0x0CE5},
- {0x0CF0, 0x0CF0}, {0x0CF3, 0x0D00}, {0x0D04, 0x0D04},
- {0x0D0D, 0x0D0D}, {0x0D11, 0x0D11}, {0x0D3B, 0x0D3C},
- {0x0D45, 0x0D45}, {0x0D49, 0x0D49}, {0x0D50, 0x0D53},
- {0x0D64, 0x0D65}, {0x0D80, 0x0D81}, {0x0D84, 0x0D84},
- {0x0D97, 0x0D99}, {0x0DB2, 0x0DB2}, {0x0DBC, 0x0DBC},
- {0x0DBE, 0x0DBF}, {0x0DC7, 0x0DC9}, {0x0DCB, 0x0DCE},
- {0x0DD5, 0x0DD5}, {0x0DD7, 0x0DD7}, {0x0DE0, 0x0DE5},
- {0x0DF0, 0x0DF1}, {0x0DF5, 0x0E00}, {0x0E3B, 0x0E3E},
- {0x0E5C, 0x0E80}, {0x0E83, 0x0E83}, {0x0E85, 0x0E86},
- {0x0E89, 0x0E89}, {0x0E8B, 0x0E8C}, {0x0E8E, 0x0E93},
- {0x0E98, 0x0E98}, {0x0EA0, 0x0EA0}, {0x0EA4, 0x0EA4},
- {0x0EA6, 0x0EA6}, {0x0EA8, 0x0EA9}, {0x0EAC, 0x0EAC},
- {0x0EBA, 0x0EBA}, {0x0EBE, 0x0EBF}, {0x0EC5, 0x0EC5},
- {0x0EC7, 0x0EC7}, {0x0ECE, 0x0ECF}, {0x0EDA, 0x0EDB},
- {0x0EE0, 0x0EFF}, {0x0F48, 0x0F48}, {0x0F6D, 0x0F70},
- {0x0F98, 0x0F98}, {0x0FBD, 0x0FBD}, {0x0FCD, 0x0FCD},
- {0x0FDB, 0x0FFF}, {0x10C6, 0x10C6}, {0x10C8, 0x10CC},
- {0x10CE, 0x10CF}, {0x1249, 0x1249}, {0x124E, 0x124F},
- {0x1257, 0x1257}, {0x1259, 0x1259}, {0x125E, 0x125F},
- {0x1289, 0x1289}, {0x128E, 0x128F}, {0x12B1, 0x12B1},
- {0x12B6, 0x12B7}, {0x12BF, 0x12BF}, {0x12C1, 0x12C1},
- {0x12C6, 0x12C7}, {0x12D7, 0x12D7}, {0x1311, 0x1311},
- {0x1316, 0x1317}, {0x135B, 0x135C}, {0x137D, 0x137F},
- {0x139A, 0x139F}, {0x13F6, 0x13F7}, {0x13FE, 0x13FF},
- {0x169D, 0x169F}, {0x16F9, 0x16FF}, {0x170D, 0x170D},
- {0x1715, 0x171F}, {0x1737, 0x173F}, {0x1754, 0x175F},
- {0x176D, 0x176D}, {0x1771, 0x1771}, {0x1774, 0x177F},
- {0x17DE, 0x17DF}, {0x17EA, 0x17EF}, {0x17FA, 0x17FF},
- {0x180F, 0x180F}, {0x181A, 0x181F}, {0x1878, 0x187F},
- {0x18AB, 0x18AF}, {0x18F6, 0x18FF}, {0x191F, 0x191F},
- {0x192C, 0x192F}, {0x193C, 0x193F}, {0x1941, 0x1943},
- {0x196E, 0x196F}, {0x1975, 0x197F}, {0x19AC, 0x19AF},
- {0x19CA, 0x19CF}, {0x19DB, 0x19DD}, {0x1A1C, 0x1A1D},
- {0x1A5F, 0x1A5F}, {0x1A7D, 0x1A7E}, {0x1A8A, 0x1A8F},
- {0x1A9A, 0x1A9F}, {0x1AAE, 0x1AAF}, {0x1ABF, 0x1AFF},
- {0x1B4C, 0x1B4F}, {0x1B7D, 0x1B7F}, {0x1BF4, 0x1BFB},
- {0x1C38, 0x1C3A}, {0x1C4A, 0x1C4C}, {0x1C89, 0x1CBF},
- {0x1CC8, 0x1CCF}, {0x1CF7, 0x1CF7}, {0x1CFA, 0x1CFF},
- {0x1DF6, 0x1DFA}, {0x1F16, 0x1F17}, {0x1F1E, 0x1F1F},
- {0x1F46, 0x1F47}, {0x1F4E, 0x1F4F}, {0x1F58, 0x1F58},
- {0x1F5A, 0x1F5A}, {0x1F5C, 0x1F5C}, {0x1F5E, 0x1F5E},
- {0x1F7E, 0x1F7F}, {0x1FB5, 0x1FB5}, {0x1FC5, 0x1FC5},
- {0x1FD4, 0x1FD5}, {0x1FDC, 0x1FDC}, {0x1FF0, 0x1FF1},
- {0x1FF5, 0x1FF5}, {0x1FFF, 0x1FFF}, {0x2065, 0x2065},
- {0x2072, 0x2073}, {0x208F, 0x208F}, {0x209D, 0x209F},
- {0x20BF, 0x20CF}, {0x20F1, 0x20FF}, {0x218C, 0x218F},
- {0x23FF, 0x23FF}, {0x2427, 0x243F}, {0x244B, 0x245F},
- {0x2B74, 0x2B75}, {0x2B96, 0x2B97}, {0x2BBA, 0x2BBC},
- {0x2BC9, 0x2BC9}, {0x2BD2, 0x2BEB}, {0x2BF0, 0x2BFF},
- {0x2C2F, 0x2C2F}, {0x2C5F, 0x2C5F}, {0x2CF4, 0x2CF8},
- {0x2D26, 0x2D26}, {0x2D28, 0x2D2C}, {0x2D2E, 0x2D2F},
- {0x2D68, 0x2D6E}, {0x2D71, 0x2D7E}, {0x2D97, 0x2D9F},
- {0x2DA7, 0x2DA7}, {0x2DAF, 0x2DAF}, {0x2DB7, 0x2DB7},
- {0x2DBF, 0x2DBF}, {0x2DC7, 0x2DC7}, {0x2DCF, 0x2DCF},
- {0x2DD7, 0x2DD7}, {0x2DDF, 0x2DDF}, {0x2E45, 0x2E7F},
- {0x2E9A, 0x2E9A}, {0x2EF4, 0x2EFF}, {0x2FD6, 0x2FEF},
- {0x2FFC, 0x2FFF}, {0x3040, 0x3040}, {0x3097, 0x3098},
- {0x3100, 0x3104}, {0x312E, 0x3130}, {0x318F, 0x318F},
- {0x31BB, 0x31BF}, {0x31E4, 0x31EF}, {0x321F, 0x321F},
- {0x32FF, 0x32FF}, {0x4DB6, 0x4DBF}, {0x9FD6, 0x9FFF},
- {0xA48D, 0xA48F}, {0xA4C7, 0xA4CF}, {0xA62C, 0xA63F},
- {0xA6F8, 0xA6FF}, {0xA7AF, 0xA7AF}, {0xA7B8, 0xA7F6},
- {0xA82C, 0xA82F}, {0xA83A, 0xA83F}, {0xA878, 0xA87F},
- {0xA8C6, 0xA8CD}, {0xA8DA, 0xA8DF}, {0xA8FE, 0xA8FF},
- {0xA954, 0xA95E}, {0xA97D, 0xA97F}, {0xA9CE, 0xA9CE},
- {0xA9DA, 0xA9DD}, {0xA9FF, 0xA9FF}, {0xAA37, 0xAA3F},
- {0xAA4E, 0xAA4F}, {0xAA5A, 0xAA5B}, {0xAAC3, 0xAADA},
- {0xAAF7, 0xAB00}, {0xAB07, 0xAB08}, {0xAB0F, 0xAB10},
- {0xAB17, 0xAB1F}, {0xAB27, 0xAB27}, {0xAB2F, 0xAB2F},
- {0xAB66, 0xAB6F}, {0xABEE, 0xABEF}, {0xABFA, 0xABFF},
- {0xD7A4, 0xD7AF}, {0xD7C7, 0xD7CA}, {0xD7FC, 0xD7FF},
- {0xFA6E, 0xFA6F}, {0xFADA, 0xFAFF}, {0xFB07, 0xFB12},
- {0xFB18, 0xFB1C}, {0xFB37, 0xFB37}, {0xFB3D, 0xFB3D},
- {0xFB3F, 0xFB3F}, {0xFB42, 0xFB42}, {0xFB45, 0xFB45},
- {0xFBC2, 0xFBD2}, {0xFD40, 0xFD4F}, {0xFD90, 0xFD91},
- {0xFDC8, 0xFDEF}, {0xFDFE, 0xFDFF}, {0xFE1A, 0xFE1F},
- {0xFE53, 0xFE53}, {0xFE67, 0xFE67}, {0xFE6C, 0xFE6F},
- {0xFE75, 0xFE75}, {0xFEFD, 0xFEFE}, {0xFF00, 0xFF00},
- {0xFFBF, 0xFFC1}, {0xFFC8, 0xFFC9}, {0xFFD0, 0xFFD1},
- {0xFFD8, 0xFFD9}, {0xFFDD, 0xFFDF}, {0xFFE7, 0xFFE7},
- {0xFFEF, 0xFFF8}, {0xFFFE, 0xFFFF}, {0x1000C, 0x1000C},
- {0x10027, 0x10027}, {0x1003B, 0x1003B}, {0x1003E, 0x1003E},
- {0x1004E, 0x1004F}, {0x1005E, 0x1007F}, {0x100FB, 0x100FF},
- {0x10103, 0x10106}, {0x10134, 0x10136}, {0x1018F, 0x1018F},
- {0x1019C, 0x1019F}, {0x101A1, 0x101CF}, {0x101FE, 0x1027F},
- {0x1029D, 0x1029F}, {0x102D1, 0x102DF}, {0x102FC, 0x102FF},
- {0x10324, 0x1032F}, {0x1034B, 0x1034F}, {0x1037B, 0x1037F},
- {0x1039E, 0x1039E}, {0x103C4, 0x103C7}, {0x103D6, 0x103FF},
- {0x1049E, 0x1049F}, {0x104AA, 0x104AF}, {0x104D4, 0x104D7},
- {0x104FC, 0x104FF}, {0x10528, 0x1052F}, {0x10564, 0x1056E},
- {0x10570, 0x105FF}, {0x10737, 0x1073F}, {0x10756, 0x1075F},
- {0x10768, 0x107FF}, {0x10806, 0x10807}, {0x10809, 0x10809},
- {0x10836, 0x10836}, {0x10839, 0x1083B}, {0x1083D, 0x1083E},
- {0x10856, 0x10856}, {0x1089F, 0x108A6}, {0x108B0, 0x108DF},
- {0x108F3, 0x108F3}, {0x108F6, 0x108FA}, {0x1091C, 0x1091E},
- {0x1093A, 0x1093E}, {0x10940, 0x1097F}, {0x109B8, 0x109BB},
- {0x109D0, 0x109D1}, {0x10A04, 0x10A04}, {0x10A07, 0x10A0B},
- {0x10A14, 0x10A14}, {0x10A18, 0x10A18}, {0x10A34, 0x10A37},
- {0x10A3B, 0x10A3E}, {0x10A48, 0x10A4F}, {0x10A59, 0x10A5F},
- {0x10AA0, 0x10ABF}, {0x10AE7, 0x10AEA}, {0x10AF7, 0x10AFF},
- {0x10B36, 0x10B38}, {0x10B56, 0x10B57}, {0x10B73, 0x10B77},
- {0x10B92, 0x10B98}, {0x10B9D, 0x10BA8}, {0x10BB0, 0x10BFF},
- {0x10C49, 0x10C7F}, {0x10CB3, 0x10CBF}, {0x10CF3, 0x10CF9},
- {0x10D00, 0x10E5F}, {0x10E7F, 0x10FFF}, {0x1104E, 0x11051},
- {0x11070, 0x1107E}, {0x110C2, 0x110CF}, {0x110E9, 0x110EF},
- {0x110FA, 0x110FF}, {0x11135, 0x11135}, {0x11144, 0x1114F},
- {0x11177, 0x1117F}, {0x111CE, 0x111CF}, {0x111E0, 0x111E0},
- {0x111F5, 0x111FF}, {0x11212, 0x11212}, {0x1123F, 0x1127F},
- {0x11287, 0x11287}, {0x11289, 0x11289}, {0x1128E, 0x1128E},
- {0x1129E, 0x1129E}, {0x112AA, 0x112AF}, {0x112EB, 0x112EF},
- {0x112FA, 0x112FF}, {0x11304, 0x11304}, {0x1130D, 0x1130E},
- {0x11311, 0x11312}, {0x11329, 0x11329}, {0x11331, 0x11331},
- {0x11334, 0x11334}, {0x1133A, 0x1133B}, {0x11345, 0x11346},
- {0x11349, 0x1134A}, {0x1134E, 0x1134F}, {0x11351, 0x11356},
- {0x11358, 0x1135C}, {0x11364, 0x11365}, {0x1136D, 0x1136F},
- {0x11375, 0x113FF}, {0x1145A, 0x1145A}, {0x1145C, 0x1145C},
- {0x1145E, 0x1147F}, {0x114C8, 0x114CF}, {0x114DA, 0x1157F},
- {0x115B6, 0x115B7}, {0x115DE, 0x115FF}, {0x11645, 0x1164F},
- {0x1165A, 0x1165F}, {0x1166D, 0x1167F}, {0x116B8, 0x116BF},
- {0x116CA, 0x116FF}, {0x1171A, 0x1171C}, {0x1172C, 0x1172F},
- {0x11740, 0x1189F}, {0x118F3, 0x118FE}, {0x11900, 0x11ABF},
- {0x11AF9, 0x11BFF}, {0x11C09, 0x11C09}, {0x11C37, 0x11C37},
- {0x11C46, 0x11C4F}, {0x11C6D, 0x11C6F}, {0x11C90, 0x11C91},
- {0x11CA8, 0x11CA8}, {0x11CB7, 0x11FFF}, {0x1239A, 0x123FF},
- {0x1246F, 0x1246F}, {0x12475, 0x1247F}, {0x12544, 0x12FFF},
- {0x1342F, 0x143FF}, {0x14647, 0x167FF}, {0x16A39, 0x16A3F},
- {0x16A5F, 0x16A5F}, {0x16A6A, 0x16A6D}, {0x16A70, 0x16ACF},
- {0x16AEE, 0x16AEF}, {0x16AF6, 0x16AFF}, {0x16B46, 0x16B4F},
- {0x16B5A, 0x16B5A}, {0x16B62, 0x16B62}, {0x16B78, 0x16B7C},
- {0x16B90, 0x16EFF}, {0x16F45, 0x16F4F}, {0x16F7F, 0x16F8E},
- {0x16FA0, 0x16FDF}, {0x16FE1, 0x16FFF}, {0x187ED, 0x187FF},
- {0x18AF3, 0x1AFFF}, {0x1B002, 0x1BBFF}, {0x1BC6B, 0x1BC6F},
- {0x1BC7D, 0x1BC7F}, {0x1BC89, 0x1BC8F}, {0x1BC9A, 0x1BC9B},
- {0x1BCA4, 0x1CFFF}, {0x1D0F6, 0x1D0FF}, {0x1D127, 0x1D128},
- {0x1D1E9, 0x1D1FF}, {0x1D246, 0x1D2FF}, {0x1D357, 0x1D35F},
- {0x1D372, 0x1D3FF}, {0x1D455, 0x1D455}, {0x1D49D, 0x1D49D},
- {0x1D4A0, 0x1D4A1}, {0x1D4A3, 0x1D4A4}, {0x1D4A7, 0x1D4A8},
- {0x1D4AD, 0x1D4AD}, {0x1D4BA, 0x1D4BA}, {0x1D4BC, 0x1D4BC},
- {0x1D4C4, 0x1D4C4}, {0x1D506, 0x1D506}, {0x1D50B, 0x1D50C},
- {0x1D515, 0x1D515}, {0x1D51D, 0x1D51D}, {0x1D53A, 0x1D53A},
- {0x1D53F, 0x1D53F}, {0x1D545, 0x1D545}, {0x1D547, 0x1D549},
- {0x1D551, 0x1D551}, {0x1D6A6, 0x1D6A7}, {0x1D7CC, 0x1D7CD},
- {0x1DA8C, 0x1DA9A}, {0x1DAA0, 0x1DAA0}, {0x1DAB0, 0x1DFFF},
- {0x1E007, 0x1E007}, {0x1E019, 0x1E01A}, {0x1E022, 0x1E022},
- {0x1E025, 0x1E025}, {0x1E02B, 0x1E7FF}, {0x1E8C5, 0x1E8C6},
- {0x1E8D7, 0x1E8FF}, {0x1E94B, 0x1E94F}, {0x1E95A, 0x1E95D},
- {0x1E960, 0x1EDFF}, {0x1EE04, 0x1EE04}, {0x1EE20, 0x1EE20},
- {0x1EE23, 0x1EE23}, {0x1EE25, 0x1EE26}, {0x1EE28, 0x1EE28},
- {0x1EE33, 0x1EE33}, {0x1EE38, 0x1EE38}, {0x1EE3A, 0x1EE3A},
- {0x1EE3C, 0x1EE41}, {0x1EE43, 0x1EE46}, {0x1EE48, 0x1EE48},
- {0x1EE4A, 0x1EE4A}, {0x1EE4C, 0x1EE4C}, {0x1EE50, 0x1EE50},
- {0x1EE53, 0x1EE53}, {0x1EE55, 0x1EE56}, {0x1EE58, 0x1EE58},
- {0x1EE5A, 0x1EE5A}, {0x1EE5C, 0x1EE5C}, {0x1EE5E, 0x1EE5E},
- {0x1EE60, 0x1EE60}, {0x1EE63, 0x1EE63}, {0x1EE65, 0x1EE66},
- {0x1EE6B, 0x1EE6B}, {0x1EE73, 0x1EE73}, {0x1EE78, 0x1EE78},
- {0x1EE7D, 0x1EE7D}, {0x1EE7F, 0x1EE7F}, {0x1EE8A, 0x1EE8A},
- {0x1EE9C, 0x1EEA0}, {0x1EEA4, 0x1EEA4}, {0x1EEAA, 0x1EEAA},
- {0x1EEBC, 0x1EEEF}, {0x1EEF2, 0x1EFFF}, {0x1F02C, 0x1F02F},
- {0x1F094, 0x1F09F}, {0x1F0AF, 0x1F0B0}, {0x1F0C0, 0x1F0C0},
- {0x1F0D0, 0x1F0D0}, {0x1F0F6, 0x1F0FF}, {0x1F10D, 0x1F10F},
- {0x1F12F, 0x1F12F}, {0x1F16C, 0x1F16F}, {0x1F1AD, 0x1F1E5},
- {0x1F203, 0x1F20F}, {0x1F23C, 0x1F23F}, {0x1F249, 0x1F24F},
- {0x1F252, 0x1F2FF}, {0x1F6D3, 0x1F6DF}, {0x1F6ED, 0x1F6EF},
- {0x1F6F7, 0x1F6FF}, {0x1F774, 0x1F77F}, {0x1F7D5, 0x1F7FF},
- {0x1F80C, 0x1F80F}, {0x1F848, 0x1F84F}, {0x1F85A, 0x1F85F},
- {0x1F888, 0x1F88F}, {0x1F8AE, 0x1F90F}, {0x1F91F, 0x1F91F},
- {0x1F928, 0x1F92F}, {0x1F931, 0x1F932}, {0x1F93F, 0x1F93F},
- {0x1F94C, 0x1F94F}, {0x1F95F, 0x1F97F}, {0x1F992, 0x1F9BF},
- {0x1F9C1, 0x1FFFF}, {0x2A6D7, 0x2A6FF}, {0x2B735, 0x2B73F},
- {0x2B81E, 0x2B81F}, {0x2CEA2, 0x2F7FF}, {0x2FA1E, 0xE0000},
- {0xE0002, 0xE001F}, {0xE0080, 0xE00FF}, {0xE01F0, 0xEFFFF},
- {0xFFFFE, 0xFFFFF},
-}
-
-var neutral = table{
- {0x0000, 0x001F}, {0x007F, 0x007F}, {0x0080, 0x009F},
- {0x00A0, 0x00A0}, {0x00A9, 0x00A9}, {0x00AB, 0x00AB},
- {0x00B5, 0x00B5}, {0x00BB, 0x00BB}, {0x00C0, 0x00C5},
- {0x00C7, 0x00CF}, {0x00D1, 0x00D6}, {0x00D9, 0x00DD},
- {0x00E2, 0x00E5}, {0x00E7, 0x00E7}, {0x00EB, 0x00EB},
- {0x00EE, 0x00EF}, {0x00F1, 0x00F1}, {0x00F4, 0x00F6},
- {0x00FB, 0x00FB}, {0x00FD, 0x00FD}, {0x00FF, 0x00FF},
- {0x0100, 0x0100}, {0x0102, 0x0110}, {0x0112, 0x0112},
- {0x0114, 0x011A}, {0x011C, 0x0125}, {0x0128, 0x012A},
- {0x012C, 0x0130}, {0x0134, 0x0137}, {0x0139, 0x013E},
- {0x0143, 0x0143}, {0x0145, 0x0147}, {0x014C, 0x014C},
- {0x014E, 0x0151}, {0x0154, 0x0165}, {0x0168, 0x016A},
- {0x016C, 0x017F}, {0x0180, 0x01BA}, {0x01BB, 0x01BB},
- {0x01BC, 0x01BF}, {0x01C0, 0x01C3}, {0x01C4, 0x01CD},
- {0x01CF, 0x01CF}, {0x01D1, 0x01D1}, {0x01D3, 0x01D3},
- {0x01D5, 0x01D5}, {0x01D7, 0x01D7}, {0x01D9, 0x01D9},
- {0x01DB, 0x01DB}, {0x01DD, 0x024F}, {0x0250, 0x0250},
- {0x0252, 0x0260}, {0x0262, 0x0293}, {0x0294, 0x0294},
- {0x0295, 0x02AF}, {0x02B0, 0x02C1}, {0x02C2, 0x02C3},
- {0x02C5, 0x02C5}, {0x02C6, 0x02C6}, {0x02C8, 0x02C8},
- {0x02CC, 0x02CC}, {0x02CE, 0x02CF}, {0x02D1, 0x02D1},
- {0x02D2, 0x02D7}, {0x02DC, 0x02DC}, {0x02DE, 0x02DE},
- {0x02E0, 0x02E4}, {0x02E5, 0x02EB}, {0x02EC, 0x02EC},
- {0x02ED, 0x02ED}, {0x02EE, 0x02EE}, {0x02EF, 0x02FF},
- {0x0370, 0x0373}, {0x0374, 0x0374}, {0x0375, 0x0375},
- {0x0376, 0x0377}, {0x037A, 0x037A}, {0x037B, 0x037D},
- {0x037E, 0x037E}, {0x037F, 0x037F}, {0x0384, 0x0385},
- {0x0386, 0x0386}, {0x0387, 0x0387}, {0x0388, 0x038A},
- {0x038C, 0x038C}, {0x038E, 0x0390}, {0x03AA, 0x03B0},
- {0x03C2, 0x03C2}, {0x03CA, 0x03F5}, {0x03F6, 0x03F6},
- {0x03F7, 0x03FF}, {0x0400, 0x0400}, {0x0402, 0x040F},
- {0x0450, 0x0450}, {0x0452, 0x0481}, {0x0482, 0x0482},
- {0x0483, 0x0487}, {0x0488, 0x0489}, {0x048A, 0x04FF},
- {0x0500, 0x052F}, {0x0531, 0x0556}, {0x0559, 0x0559},
- {0x055A, 0x055F}, {0x0561, 0x0587}, {0x0589, 0x0589},
- {0x058A, 0x058A}, {0x058D, 0x058E}, {0x058F, 0x058F},
- {0x0591, 0x05BD}, {0x05BE, 0x05BE}, {0x05BF, 0x05BF},
- {0x05C0, 0x05C0}, {0x05C1, 0x05C2}, {0x05C3, 0x05C3},
- {0x05C4, 0x05C5}, {0x05C6, 0x05C6}, {0x05C7, 0x05C7},
- {0x05D0, 0x05EA}, {0x05F0, 0x05F2}, {0x05F3, 0x05F4},
- {0x0600, 0x0605}, {0x0606, 0x0608}, {0x0609, 0x060A},
- {0x060B, 0x060B}, {0x060C, 0x060D}, {0x060E, 0x060F},
- {0x0610, 0x061A}, {0x061B, 0x061B}, {0x061C, 0x061C},
- {0x061E, 0x061F}, {0x0620, 0x063F}, {0x0640, 0x0640},
- {0x0641, 0x064A}, {0x064B, 0x065F}, {0x0660, 0x0669},
- {0x066A, 0x066D}, {0x066E, 0x066F}, {0x0670, 0x0670},
- {0x0671, 0x06D3}, {0x06D4, 0x06D4}, {0x06D5, 0x06D5},
- {0x06D6, 0x06DC}, {0x06DD, 0x06DD}, {0x06DE, 0x06DE},
- {0x06DF, 0x06E4}, {0x06E5, 0x06E6}, {0x06E7, 0x06E8},
- {0x06E9, 0x06E9}, {0x06EA, 0x06ED}, {0x06EE, 0x06EF},
- {0x06F0, 0x06F9}, {0x06FA, 0x06FC}, {0x06FD, 0x06FE},
- {0x06FF, 0x06FF}, {0x0700, 0x070D}, {0x070F, 0x070F},
- {0x0710, 0x0710}, {0x0711, 0x0711}, {0x0712, 0x072F},
- {0x0730, 0x074A}, {0x074D, 0x074F}, {0x0750, 0x077F},
- {0x0780, 0x07A5}, {0x07A6, 0x07B0}, {0x07B1, 0x07B1},
- {0x07C0, 0x07C9}, {0x07CA, 0x07EA}, {0x07EB, 0x07F3},
- {0x07F4, 0x07F5}, {0x07F6, 0x07F6}, {0x07F7, 0x07F9},
- {0x07FA, 0x07FA}, {0x0800, 0x0815}, {0x0816, 0x0819},
- {0x081A, 0x081A}, {0x081B, 0x0823}, {0x0824, 0x0824},
- {0x0825, 0x0827}, {0x0828, 0x0828}, {0x0829, 0x082D},
- {0x0830, 0x083E}, {0x0840, 0x0858}, {0x0859, 0x085B},
- {0x085E, 0x085E}, {0x08A0, 0x08B4}, {0x08B6, 0x08BD},
- {0x08D4, 0x08E1}, {0x08E2, 0x08E2}, {0x08E3, 0x08FF},
- {0x0900, 0x0902}, {0x0903, 0x0903}, {0x0904, 0x0939},
- {0x093A, 0x093A}, {0x093B, 0x093B}, {0x093C, 0x093C},
- {0x093D, 0x093D}, {0x093E, 0x0940}, {0x0941, 0x0948},
- {0x0949, 0x094C}, {0x094D, 0x094D}, {0x094E, 0x094F},
- {0x0950, 0x0950}, {0x0951, 0x0957}, {0x0958, 0x0961},
- {0x0962, 0x0963}, {0x0964, 0x0965}, {0x0966, 0x096F},
- {0x0970, 0x0970}, {0x0971, 0x0971}, {0x0972, 0x097F},
- {0x0980, 0x0980}, {0x0981, 0x0981}, {0x0982, 0x0983},
- {0x0985, 0x098C}, {0x098F, 0x0990}, {0x0993, 0x09A8},
- {0x09AA, 0x09B0}, {0x09B2, 0x09B2}, {0x09B6, 0x09B9},
- {0x09BC, 0x09BC}, {0x09BD, 0x09BD}, {0x09BE, 0x09C0},
- {0x09C1, 0x09C4}, {0x09C7, 0x09C8}, {0x09CB, 0x09CC},
- {0x09CD, 0x09CD}, {0x09CE, 0x09CE}, {0x09D7, 0x09D7},
- {0x09DC, 0x09DD}, {0x09DF, 0x09E1}, {0x09E2, 0x09E3},
- {0x09E6, 0x09EF}, {0x09F0, 0x09F1}, {0x09F2, 0x09F3},
- {0x09F4, 0x09F9}, {0x09FA, 0x09FA}, {0x09FB, 0x09FB},
- {0x0A01, 0x0A02}, {0x0A03, 0x0A03}, {0x0A05, 0x0A0A},
- {0x0A0F, 0x0A10}, {0x0A13, 0x0A28}, {0x0A2A, 0x0A30},
- {0x0A32, 0x0A33}, {0x0A35, 0x0A36}, {0x0A38, 0x0A39},
- {0x0A3C, 0x0A3C}, {0x0A3E, 0x0A40}, {0x0A41, 0x0A42},
- {0x0A47, 0x0A48}, {0x0A4B, 0x0A4D}, {0x0A51, 0x0A51},
- {0x0A59, 0x0A5C}, {0x0A5E, 0x0A5E}, {0x0A66, 0x0A6F},
- {0x0A70, 0x0A71}, {0x0A72, 0x0A74}, {0x0A75, 0x0A75},
- {0x0A81, 0x0A82}, {0x0A83, 0x0A83}, {0x0A85, 0x0A8D},
- {0x0A8F, 0x0A91}, {0x0A93, 0x0AA8}, {0x0AAA, 0x0AB0},
- {0x0AB2, 0x0AB3}, {0x0AB5, 0x0AB9}, {0x0ABC, 0x0ABC},
- {0x0ABD, 0x0ABD}, {0x0ABE, 0x0AC0}, {0x0AC1, 0x0AC5},
- {0x0AC7, 0x0AC8}, {0x0AC9, 0x0AC9}, {0x0ACB, 0x0ACC},
- {0x0ACD, 0x0ACD}, {0x0AD0, 0x0AD0}, {0x0AE0, 0x0AE1},
- {0x0AE2, 0x0AE3}, {0x0AE6, 0x0AEF}, {0x0AF0, 0x0AF0},
- {0x0AF1, 0x0AF1}, {0x0AF9, 0x0AF9}, {0x0B01, 0x0B01},
- {0x0B02, 0x0B03}, {0x0B05, 0x0B0C}, {0x0B0F, 0x0B10},
- {0x0B13, 0x0B28}, {0x0B2A, 0x0B30}, {0x0B32, 0x0B33},
- {0x0B35, 0x0B39}, {0x0B3C, 0x0B3C}, {0x0B3D, 0x0B3D},
- {0x0B3E, 0x0B3E}, {0x0B3F, 0x0B3F}, {0x0B40, 0x0B40},
- {0x0B41, 0x0B44}, {0x0B47, 0x0B48}, {0x0B4B, 0x0B4C},
- {0x0B4D, 0x0B4D}, {0x0B56, 0x0B56}, {0x0B57, 0x0B57},
- {0x0B5C, 0x0B5D}, {0x0B5F, 0x0B61}, {0x0B62, 0x0B63},
- {0x0B66, 0x0B6F}, {0x0B70, 0x0B70}, {0x0B71, 0x0B71},
- {0x0B72, 0x0B77}, {0x0B82, 0x0B82}, {0x0B83, 0x0B83},
- {0x0B85, 0x0B8A}, {0x0B8E, 0x0B90}, {0x0B92, 0x0B95},
- {0x0B99, 0x0B9A}, {0x0B9C, 0x0B9C}, {0x0B9E, 0x0B9F},
- {0x0BA3, 0x0BA4}, {0x0BA8, 0x0BAA}, {0x0BAE, 0x0BB9},
- {0x0BBE, 0x0BBF}, {0x0BC0, 0x0BC0}, {0x0BC1, 0x0BC2},
- {0x0BC6, 0x0BC8}, {0x0BCA, 0x0BCC}, {0x0BCD, 0x0BCD},
- {0x0BD0, 0x0BD0}, {0x0BD7, 0x0BD7}, {0x0BE6, 0x0BEF},
- {0x0BF0, 0x0BF2}, {0x0BF3, 0x0BF8}, {0x0BF9, 0x0BF9},
- {0x0BFA, 0x0BFA}, {0x0C00, 0x0C00}, {0x0C01, 0x0C03},
- {0x0C05, 0x0C0C}, {0x0C0E, 0x0C10}, {0x0C12, 0x0C28},
- {0x0C2A, 0x0C39}, {0x0C3D, 0x0C3D}, {0x0C3E, 0x0C40},
- {0x0C41, 0x0C44}, {0x0C46, 0x0C48}, {0x0C4A, 0x0C4D},
- {0x0C55, 0x0C56}, {0x0C58, 0x0C5A}, {0x0C60, 0x0C61},
- {0x0C62, 0x0C63}, {0x0C66, 0x0C6F}, {0x0C78, 0x0C7E},
- {0x0C7F, 0x0C7F}, {0x0C80, 0x0C80}, {0x0C81, 0x0C81},
- {0x0C82, 0x0C83}, {0x0C85, 0x0C8C}, {0x0C8E, 0x0C90},
- {0x0C92, 0x0CA8}, {0x0CAA, 0x0CB3}, {0x0CB5, 0x0CB9},
- {0x0CBC, 0x0CBC}, {0x0CBD, 0x0CBD}, {0x0CBE, 0x0CBE},
- {0x0CBF, 0x0CBF}, {0x0CC0, 0x0CC4}, {0x0CC6, 0x0CC6},
- {0x0CC7, 0x0CC8}, {0x0CCA, 0x0CCB}, {0x0CCC, 0x0CCD},
- {0x0CD5, 0x0CD6}, {0x0CDE, 0x0CDE}, {0x0CE0, 0x0CE1},
- {0x0CE2, 0x0CE3}, {0x0CE6, 0x0CEF}, {0x0CF1, 0x0CF2},
- {0x0D01, 0x0D01}, {0x0D02, 0x0D03}, {0x0D05, 0x0D0C},
- {0x0D0E, 0x0D10}, {0x0D12, 0x0D3A}, {0x0D3D, 0x0D3D},
- {0x0D3E, 0x0D40}, {0x0D41, 0x0D44}, {0x0D46, 0x0D48},
- {0x0D4A, 0x0D4C}, {0x0D4D, 0x0D4D}, {0x0D4E, 0x0D4E},
- {0x0D4F, 0x0D4F}, {0x0D54, 0x0D56}, {0x0D57, 0x0D57},
- {0x0D58, 0x0D5E}, {0x0D5F, 0x0D61}, {0x0D62, 0x0D63},
- {0x0D66, 0x0D6F}, {0x0D70, 0x0D78}, {0x0D79, 0x0D79},
- {0x0D7A, 0x0D7F}, {0x0D82, 0x0D83}, {0x0D85, 0x0D96},
- {0x0D9A, 0x0DB1}, {0x0DB3, 0x0DBB}, {0x0DBD, 0x0DBD},
- {0x0DC0, 0x0DC6}, {0x0DCA, 0x0DCA}, {0x0DCF, 0x0DD1},
- {0x0DD2, 0x0DD4}, {0x0DD6, 0x0DD6}, {0x0DD8, 0x0DDF},
- {0x0DE6, 0x0DEF}, {0x0DF2, 0x0DF3}, {0x0DF4, 0x0DF4},
- {0x0E01, 0x0E30}, {0x0E31, 0x0E31}, {0x0E32, 0x0E33},
- {0x0E34, 0x0E3A}, {0x0E3F, 0x0E3F}, {0x0E40, 0x0E45},
- {0x0E46, 0x0E46}, {0x0E47, 0x0E4E}, {0x0E4F, 0x0E4F},
- {0x0E50, 0x0E59}, {0x0E5A, 0x0E5B}, {0x0E81, 0x0E82},
- {0x0E84, 0x0E84}, {0x0E87, 0x0E88}, {0x0E8A, 0x0E8A},
- {0x0E8D, 0x0E8D}, {0x0E94, 0x0E97}, {0x0E99, 0x0E9F},
- {0x0EA1, 0x0EA3}, {0x0EA5, 0x0EA5}, {0x0EA7, 0x0EA7},
- {0x0EAA, 0x0EAB}, {0x0EAD, 0x0EB0}, {0x0EB1, 0x0EB1},
- {0x0EB2, 0x0EB3}, {0x0EB4, 0x0EB9}, {0x0EBB, 0x0EBC},
- {0x0EBD, 0x0EBD}, {0x0EC0, 0x0EC4}, {0x0EC6, 0x0EC6},
- {0x0EC8, 0x0ECD}, {0x0ED0, 0x0ED9}, {0x0EDC, 0x0EDF},
- {0x0F00, 0x0F00}, {0x0F01, 0x0F03}, {0x0F04, 0x0F12},
- {0x0F13, 0x0F13}, {0x0F14, 0x0F14}, {0x0F15, 0x0F17},
- {0x0F18, 0x0F19}, {0x0F1A, 0x0F1F}, {0x0F20, 0x0F29},
- {0x0F2A, 0x0F33}, {0x0F34, 0x0F34}, {0x0F35, 0x0F35},
- {0x0F36, 0x0F36}, {0x0F37, 0x0F37}, {0x0F38, 0x0F38},
- {0x0F39, 0x0F39}, {0x0F3A, 0x0F3A}, {0x0F3B, 0x0F3B},
- {0x0F3C, 0x0F3C}, {0x0F3D, 0x0F3D}, {0x0F3E, 0x0F3F},
- {0x0F40, 0x0F47}, {0x0F49, 0x0F6C}, {0x0F71, 0x0F7E},
- {0x0F7F, 0x0F7F}, {0x0F80, 0x0F84}, {0x0F85, 0x0F85},
- {0x0F86, 0x0F87}, {0x0F88, 0x0F8C}, {0x0F8D, 0x0F97},
- {0x0F99, 0x0FBC}, {0x0FBE, 0x0FC5}, {0x0FC6, 0x0FC6},
- {0x0FC7, 0x0FCC}, {0x0FCE, 0x0FCF}, {0x0FD0, 0x0FD4},
- {0x0FD5, 0x0FD8}, {0x0FD9, 0x0FDA}, {0x1000, 0x102A},
- {0x102B, 0x102C}, {0x102D, 0x1030}, {0x1031, 0x1031},
- {0x1032, 0x1037}, {0x1038, 0x1038}, {0x1039, 0x103A},
- {0x103B, 0x103C}, {0x103D, 0x103E}, {0x103F, 0x103F},
- {0x1040, 0x1049}, {0x104A, 0x104F}, {0x1050, 0x1055},
- {0x1056, 0x1057}, {0x1058, 0x1059}, {0x105A, 0x105D},
- {0x105E, 0x1060}, {0x1061, 0x1061}, {0x1062, 0x1064},
- {0x1065, 0x1066}, {0x1067, 0x106D}, {0x106E, 0x1070},
- {0x1071, 0x1074}, {0x1075, 0x1081}, {0x1082, 0x1082},
- {0x1083, 0x1084}, {0x1085, 0x1086}, {0x1087, 0x108C},
- {0x108D, 0x108D}, {0x108E, 0x108E}, {0x108F, 0x108F},
- {0x1090, 0x1099}, {0x109A, 0x109C}, {0x109D, 0x109D},
- {0x109E, 0x109F}, {0x10A0, 0x10C5}, {0x10C7, 0x10C7},
- {0x10CD, 0x10CD}, {0x10D0, 0x10FA}, {0x10FB, 0x10FB},
- {0x10FC, 0x10FC}, {0x10FD, 0x10FF}, {0x1160, 0x11FF},
- {0x1200, 0x1248}, {0x124A, 0x124D}, {0x1250, 0x1256},
- {0x1258, 0x1258}, {0x125A, 0x125D}, {0x1260, 0x1288},
- {0x128A, 0x128D}, {0x1290, 0x12B0}, {0x12B2, 0x12B5},
- {0x12B8, 0x12BE}, {0x12C0, 0x12C0}, {0x12C2, 0x12C5},
- {0x12C8, 0x12D6}, {0x12D8, 0x1310}, {0x1312, 0x1315},
- {0x1318, 0x135A}, {0x135D, 0x135F}, {0x1360, 0x1368},
- {0x1369, 0x137C}, {0x1380, 0x138F}, {0x1390, 0x1399},
- {0x13A0, 0x13F5}, {0x13F8, 0x13FD}, {0x1400, 0x1400},
- {0x1401, 0x166C}, {0x166D, 0x166E}, {0x166F, 0x167F},
- {0x1680, 0x1680}, {0x1681, 0x169A}, {0x169B, 0x169B},
- {0x169C, 0x169C}, {0x16A0, 0x16EA}, {0x16EB, 0x16ED},
- {0x16EE, 0x16F0}, {0x16F1, 0x16F8}, {0x1700, 0x170C},
- {0x170E, 0x1711}, {0x1712, 0x1714}, {0x1720, 0x1731},
- {0x1732, 0x1734}, {0x1735, 0x1736}, {0x1740, 0x1751},
- {0x1752, 0x1753}, {0x1760, 0x176C}, {0x176E, 0x1770},
- {0x1772, 0x1773}, {0x1780, 0x17B3}, {0x17B4, 0x17B5},
- {0x17B6, 0x17B6}, {0x17B7, 0x17BD}, {0x17BE, 0x17C5},
- {0x17C6, 0x17C6}, {0x17C7, 0x17C8}, {0x17C9, 0x17D3},
- {0x17D4, 0x17D6}, {0x17D7, 0x17D7}, {0x17D8, 0x17DA},
- {0x17DB, 0x17DB}, {0x17DC, 0x17DC}, {0x17DD, 0x17DD},
- {0x17E0, 0x17E9}, {0x17F0, 0x17F9}, {0x1800, 0x1805},
- {0x1806, 0x1806}, {0x1807, 0x180A}, {0x180B, 0x180D},
- {0x180E, 0x180E}, {0x1810, 0x1819}, {0x1820, 0x1842},
- {0x1843, 0x1843}, {0x1844, 0x1877}, {0x1880, 0x1884},
- {0x1885, 0x1886}, {0x1887, 0x18A8}, {0x18A9, 0x18A9},
- {0x18AA, 0x18AA}, {0x18B0, 0x18F5}, {0x1900, 0x191E},
- {0x1920, 0x1922}, {0x1923, 0x1926}, {0x1927, 0x1928},
- {0x1929, 0x192B}, {0x1930, 0x1931}, {0x1932, 0x1932},
- {0x1933, 0x1938}, {0x1939, 0x193B}, {0x1940, 0x1940},
- {0x1944, 0x1945}, {0x1946, 0x194F}, {0x1950, 0x196D},
- {0x1970, 0x1974}, {0x1980, 0x19AB}, {0x19B0, 0x19C9},
- {0x19D0, 0x19D9}, {0x19DA, 0x19DA}, {0x19DE, 0x19DF},
- {0x19E0, 0x19FF}, {0x1A00, 0x1A16}, {0x1A17, 0x1A18},
- {0x1A19, 0x1A1A}, {0x1A1B, 0x1A1B}, {0x1A1E, 0x1A1F},
- {0x1A20, 0x1A54}, {0x1A55, 0x1A55}, {0x1A56, 0x1A56},
- {0x1A57, 0x1A57}, {0x1A58, 0x1A5E}, {0x1A60, 0x1A60},
- {0x1A61, 0x1A61}, {0x1A62, 0x1A62}, {0x1A63, 0x1A64},
- {0x1A65, 0x1A6C}, {0x1A6D, 0x1A72}, {0x1A73, 0x1A7C},
- {0x1A7F, 0x1A7F}, {0x1A80, 0x1A89}, {0x1A90, 0x1A99},
- {0x1AA0, 0x1AA6}, {0x1AA7, 0x1AA7}, {0x1AA8, 0x1AAD},
- {0x1AB0, 0x1ABD}, {0x1ABE, 0x1ABE}, {0x1B00, 0x1B03},
- {0x1B04, 0x1B04}, {0x1B05, 0x1B33}, {0x1B34, 0x1B34},
- {0x1B35, 0x1B35}, {0x1B36, 0x1B3A}, {0x1B3B, 0x1B3B},
- {0x1B3C, 0x1B3C}, {0x1B3D, 0x1B41}, {0x1B42, 0x1B42},
- {0x1B43, 0x1B44}, {0x1B45, 0x1B4B}, {0x1B50, 0x1B59},
- {0x1B5A, 0x1B60}, {0x1B61, 0x1B6A}, {0x1B6B, 0x1B73},
- {0x1B74, 0x1B7C}, {0x1B80, 0x1B81}, {0x1B82, 0x1B82},
- {0x1B83, 0x1BA0}, {0x1BA1, 0x1BA1}, {0x1BA2, 0x1BA5},
- {0x1BA6, 0x1BA7}, {0x1BA8, 0x1BA9}, {0x1BAA, 0x1BAA},
- {0x1BAB, 0x1BAD}, {0x1BAE, 0x1BAF}, {0x1BB0, 0x1BB9},
- {0x1BBA, 0x1BBF}, {0x1BC0, 0x1BE5}, {0x1BE6, 0x1BE6},
- {0x1BE7, 0x1BE7}, {0x1BE8, 0x1BE9}, {0x1BEA, 0x1BEC},
- {0x1BED, 0x1BED}, {0x1BEE, 0x1BEE}, {0x1BEF, 0x1BF1},
- {0x1BF2, 0x1BF3}, {0x1BFC, 0x1BFF}, {0x1C00, 0x1C23},
- {0x1C24, 0x1C2B}, {0x1C2C, 0x1C33}, {0x1C34, 0x1C35},
- {0x1C36, 0x1C37}, {0x1C3B, 0x1C3F}, {0x1C40, 0x1C49},
- {0x1C4D, 0x1C4F}, {0x1C50, 0x1C59}, {0x1C5A, 0x1C77},
- {0x1C78, 0x1C7D}, {0x1C7E, 0x1C7F}, {0x1C80, 0x1C88},
- {0x1CC0, 0x1CC7}, {0x1CD0, 0x1CD2}, {0x1CD3, 0x1CD3},
- {0x1CD4, 0x1CE0}, {0x1CE1, 0x1CE1}, {0x1CE2, 0x1CE8},
- {0x1CE9, 0x1CEC}, {0x1CED, 0x1CED}, {0x1CEE, 0x1CF1},
- {0x1CF2, 0x1CF3}, {0x1CF4, 0x1CF4}, {0x1CF5, 0x1CF6},
- {0x1CF8, 0x1CF9}, {0x1D00, 0x1D2B}, {0x1D2C, 0x1D6A},
- {0x1D6B, 0x1D77}, {0x1D78, 0x1D78}, {0x1D79, 0x1D7F},
- {0x1D80, 0x1D9A}, {0x1D9B, 0x1DBF}, {0x1DC0, 0x1DF5},
- {0x1DFB, 0x1DFF}, {0x1E00, 0x1EFF}, {0x1F00, 0x1F15},
- {0x1F18, 0x1F1D}, {0x1F20, 0x1F45}, {0x1F48, 0x1F4D},
- {0x1F50, 0x1F57}, {0x1F59, 0x1F59}, {0x1F5B, 0x1F5B},
- {0x1F5D, 0x1F5D}, {0x1F5F, 0x1F7D}, {0x1F80, 0x1FB4},
- {0x1FB6, 0x1FBC}, {0x1FBD, 0x1FBD}, {0x1FBE, 0x1FBE},
- {0x1FBF, 0x1FC1}, {0x1FC2, 0x1FC4}, {0x1FC6, 0x1FCC},
- {0x1FCD, 0x1FCF}, {0x1FD0, 0x1FD3}, {0x1FD6, 0x1FDB},
- {0x1FDD, 0x1FDF}, {0x1FE0, 0x1FEC}, {0x1FED, 0x1FEF},
- {0x1FF2, 0x1FF4}, {0x1FF6, 0x1FFC}, {0x1FFD, 0x1FFE},
- {0x2000, 0x200A}, {0x200B, 0x200F}, {0x2011, 0x2012},
- {0x2017, 0x2017}, {0x201A, 0x201A}, {0x201B, 0x201B},
- {0x201E, 0x201E}, {0x201F, 0x201F}, {0x2023, 0x2023},
- {0x2028, 0x2028}, {0x2029, 0x2029}, {0x202A, 0x202E},
- {0x202F, 0x202F}, {0x2031, 0x2031}, {0x2034, 0x2034},
- {0x2036, 0x2038}, {0x2039, 0x2039}, {0x203A, 0x203A},
- {0x203C, 0x203D}, {0x203F, 0x2040}, {0x2041, 0x2043},
- {0x2044, 0x2044}, {0x2045, 0x2045}, {0x2046, 0x2046},
- {0x2047, 0x2051}, {0x2052, 0x2052}, {0x2053, 0x2053},
- {0x2054, 0x2054}, {0x2055, 0x205E}, {0x205F, 0x205F},
- {0x2060, 0x2064}, {0x2066, 0x206F}, {0x2070, 0x2070},
- {0x2071, 0x2071}, {0x2075, 0x2079}, {0x207A, 0x207C},
- {0x207D, 0x207D}, {0x207E, 0x207E}, {0x2080, 0x2080},
- {0x2085, 0x2089}, {0x208A, 0x208C}, {0x208D, 0x208D},
- {0x208E, 0x208E}, {0x2090, 0x209C}, {0x20A0, 0x20A8},
- {0x20AA, 0x20AB}, {0x20AD, 0x20BE}, {0x20D0, 0x20DC},
- {0x20DD, 0x20E0}, {0x20E1, 0x20E1}, {0x20E2, 0x20E4},
- {0x20E5, 0x20F0}, {0x2100, 0x2101}, {0x2102, 0x2102},
- {0x2104, 0x2104}, {0x2106, 0x2106}, {0x2107, 0x2107},
- {0x2108, 0x2108}, {0x210A, 0x2112}, {0x2114, 0x2114},
- {0x2115, 0x2115}, {0x2117, 0x2117}, {0x2118, 0x2118},
- {0x2119, 0x211D}, {0x211E, 0x2120}, {0x2123, 0x2123},
- {0x2124, 0x2124}, {0x2125, 0x2125}, {0x2127, 0x2127},
- {0x2128, 0x2128}, {0x2129, 0x2129}, {0x212A, 0x212A},
- {0x212C, 0x212D}, {0x212E, 0x212E}, {0x212F, 0x2134},
- {0x2135, 0x2138}, {0x2139, 0x2139}, {0x213A, 0x213B},
- {0x213C, 0x213F}, {0x2140, 0x2144}, {0x2145, 0x2149},
- {0x214A, 0x214A}, {0x214B, 0x214B}, {0x214C, 0x214D},
- {0x214E, 0x214E}, {0x214F, 0x214F}, {0x2150, 0x2152},
- {0x2155, 0x215A}, {0x215F, 0x215F}, {0x216C, 0x216F},
- {0x217A, 0x2182}, {0x2183, 0x2184}, {0x2185, 0x2188},
- {0x218A, 0x218B}, {0x219A, 0x219B}, {0x219C, 0x219F},
- {0x21A0, 0x21A0}, {0x21A1, 0x21A2}, {0x21A3, 0x21A3},
- {0x21A4, 0x21A5}, {0x21A6, 0x21A6}, {0x21A7, 0x21AD},
- {0x21AE, 0x21AE}, {0x21AF, 0x21B7}, {0x21BA, 0x21CD},
- {0x21CE, 0x21CF}, {0x21D0, 0x21D1}, {0x21D3, 0x21D3},
- {0x21D5, 0x21E6}, {0x21E8, 0x21F3}, {0x21F4, 0x21FF},
- {0x2201, 0x2201}, {0x2204, 0x2206}, {0x2209, 0x220A},
- {0x220C, 0x220E}, {0x2210, 0x2210}, {0x2212, 0x2214},
- {0x2216, 0x2219}, {0x221B, 0x221C}, {0x2221, 0x2222},
- {0x2224, 0x2224}, {0x2226, 0x2226}, {0x222D, 0x222D},
- {0x222F, 0x2233}, {0x2238, 0x223B}, {0x223E, 0x2247},
- {0x2249, 0x224B}, {0x224D, 0x2251}, {0x2253, 0x225F},
- {0x2262, 0x2263}, {0x2268, 0x2269}, {0x226C, 0x226D},
- {0x2270, 0x2281}, {0x2284, 0x2285}, {0x2288, 0x2294},
- {0x2296, 0x2298}, {0x229A, 0x22A4}, {0x22A6, 0x22BE},
- {0x22C0, 0x22FF}, {0x2300, 0x2307}, {0x2308, 0x2308},
- {0x2309, 0x2309}, {0x230A, 0x230A}, {0x230B, 0x230B},
- {0x230C, 0x2311}, {0x2313, 0x2319}, {0x231C, 0x231F},
- {0x2320, 0x2321}, {0x2322, 0x2328}, {0x232B, 0x237B},
- {0x237C, 0x237C}, {0x237D, 0x239A}, {0x239B, 0x23B3},
- {0x23B4, 0x23DB}, {0x23DC, 0x23E1}, {0x23E2, 0x23E8},
- {0x23ED, 0x23EF}, {0x23F1, 0x23F2}, {0x23F4, 0x23FE},
- {0x2400, 0x2426}, {0x2440, 0x244A}, {0x24EA, 0x24EA},
- {0x254C, 0x254F}, {0x2574, 0x257F}, {0x2590, 0x2591},
- {0x2596, 0x259F}, {0x25A2, 0x25A2}, {0x25AA, 0x25B1},
- {0x25B4, 0x25B5}, {0x25B8, 0x25BB}, {0x25BE, 0x25BF},
- {0x25C2, 0x25C5}, {0x25C9, 0x25CA}, {0x25CC, 0x25CD},
- {0x25D2, 0x25E1}, {0x25E6, 0x25EE}, {0x25F0, 0x25F7},
- {0x25F8, 0x25FC}, {0x25FF, 0x25FF}, {0x2600, 0x2604},
- {0x2607, 0x2608}, {0x260A, 0x260D}, {0x2610, 0x2613},
- {0x2616, 0x261B}, {0x261D, 0x261D}, {0x261F, 0x263F},
- {0x2641, 0x2641}, {0x2643, 0x2647}, {0x2654, 0x265F},
- {0x2662, 0x2662}, {0x2666, 0x2666}, {0x266B, 0x266B},
- {0x266E, 0x266E}, {0x2670, 0x267E}, {0x2680, 0x2692},
- {0x2694, 0x269D}, {0x26A0, 0x26A0}, {0x26A2, 0x26A9},
- {0x26AC, 0x26BC}, {0x26C0, 0x26C3}, {0x26E2, 0x26E2},
- {0x26E4, 0x26E7}, {0x2700, 0x2704}, {0x2706, 0x2709},
- {0x270C, 0x2727}, {0x2729, 0x273C}, {0x273E, 0x274B},
- {0x274D, 0x274D}, {0x274F, 0x2752}, {0x2756, 0x2756},
- {0x2758, 0x2767}, {0x2768, 0x2768}, {0x2769, 0x2769},
- {0x276A, 0x276A}, {0x276B, 0x276B}, {0x276C, 0x276C},
- {0x276D, 0x276D}, {0x276E, 0x276E}, {0x276F, 0x276F},
- {0x2770, 0x2770}, {0x2771, 0x2771}, {0x2772, 0x2772},
- {0x2773, 0x2773}, {0x2774, 0x2774}, {0x2775, 0x2775},
- {0x2780, 0x2793}, {0x2794, 0x2794}, {0x2798, 0x27AF},
- {0x27B1, 0x27BE}, {0x27C0, 0x27C4}, {0x27C5, 0x27C5},
- {0x27C6, 0x27C6}, {0x27C7, 0x27E5}, {0x27EE, 0x27EE},
- {0x27EF, 0x27EF}, {0x27F0, 0x27FF}, {0x2800, 0x28FF},
- {0x2900, 0x297F}, {0x2980, 0x2982}, {0x2983, 0x2983},
- {0x2984, 0x2984}, {0x2987, 0x2987}, {0x2988, 0x2988},
- {0x2989, 0x2989}, {0x298A, 0x298A}, {0x298B, 0x298B},
- {0x298C, 0x298C}, {0x298D, 0x298D}, {0x298E, 0x298E},
- {0x298F, 0x298F}, {0x2990, 0x2990}, {0x2991, 0x2991},
- {0x2992, 0x2992}, {0x2993, 0x2993}, {0x2994, 0x2994},
- {0x2995, 0x2995}, {0x2996, 0x2996}, {0x2997, 0x2997},
- {0x2998, 0x2998}, {0x2999, 0x29D7}, {0x29D8, 0x29D8},
- {0x29D9, 0x29D9}, {0x29DA, 0x29DA}, {0x29DB, 0x29DB},
- {0x29DC, 0x29FB}, {0x29FC, 0x29FC}, {0x29FD, 0x29FD},
- {0x29FE, 0x29FF}, {0x2A00, 0x2AFF}, {0x2B00, 0x2B1A},
- {0x2B1D, 0x2B2F}, {0x2B30, 0x2B44}, {0x2B45, 0x2B46},
- {0x2B47, 0x2B4C}, {0x2B4D, 0x2B4F}, {0x2B51, 0x2B54},
- {0x2B5A, 0x2B73}, {0x2B76, 0x2B95}, {0x2B98, 0x2BB9},
- {0x2BBD, 0x2BC8}, {0x2BCA, 0x2BD1}, {0x2BEC, 0x2BEF},
- {0x2C00, 0x2C2E}, {0x2C30, 0x2C5E}, {0x2C60, 0x2C7B},
- {0x2C7C, 0x2C7D}, {0x2C7E, 0x2C7F}, {0x2C80, 0x2CE4},
- {0x2CE5, 0x2CEA}, {0x2CEB, 0x2CEE}, {0x2CEF, 0x2CF1},
- {0x2CF2, 0x2CF3}, {0x2CF9, 0x2CFC}, {0x2CFD, 0x2CFD},
- {0x2CFE, 0x2CFF}, {0x2D00, 0x2D25}, {0x2D27, 0x2D27},
- {0x2D2D, 0x2D2D}, {0x2D30, 0x2D67}, {0x2D6F, 0x2D6F},
- {0x2D70, 0x2D70}, {0x2D7F, 0x2D7F}, {0x2D80, 0x2D96},
- {0x2DA0, 0x2DA6}, {0x2DA8, 0x2DAE}, {0x2DB0, 0x2DB6},
- {0x2DB8, 0x2DBE}, {0x2DC0, 0x2DC6}, {0x2DC8, 0x2DCE},
- {0x2DD0, 0x2DD6}, {0x2DD8, 0x2DDE}, {0x2DE0, 0x2DFF},
- {0x2E00, 0x2E01}, {0x2E02, 0x2E02}, {0x2E03, 0x2E03},
- {0x2E04, 0x2E04}, {0x2E05, 0x2E05}, {0x2E06, 0x2E08},
- {0x2E09, 0x2E09}, {0x2E0A, 0x2E0A}, {0x2E0B, 0x2E0B},
- {0x2E0C, 0x2E0C}, {0x2E0D, 0x2E0D}, {0x2E0E, 0x2E16},
- {0x2E17, 0x2E17}, {0x2E18, 0x2E19}, {0x2E1A, 0x2E1A},
- {0x2E1B, 0x2E1B}, {0x2E1C, 0x2E1C}, {0x2E1D, 0x2E1D},
- {0x2E1E, 0x2E1F}, {0x2E20, 0x2E20}, {0x2E21, 0x2E21},
- {0x2E22, 0x2E22}, {0x2E23, 0x2E23}, {0x2E24, 0x2E24},
- {0x2E25, 0x2E25}, {0x2E26, 0x2E26}, {0x2E27, 0x2E27},
- {0x2E28, 0x2E28}, {0x2E29, 0x2E29}, {0x2E2A, 0x2E2E},
- {0x2E2F, 0x2E2F}, {0x2E30, 0x2E39}, {0x2E3A, 0x2E3B},
- {0x2E3C, 0x2E3F}, {0x2E40, 0x2E40}, {0x2E41, 0x2E41},
- {0x2E42, 0x2E42}, {0x2E43, 0x2E44}, {0x303F, 0x303F},
- {0x4DC0, 0x4DFF}, {0xA4D0, 0xA4F7}, {0xA4F8, 0xA4FD},
- {0xA4FE, 0xA4FF}, {0xA500, 0xA60B}, {0xA60C, 0xA60C},
- {0xA60D, 0xA60F}, {0xA610, 0xA61F}, {0xA620, 0xA629},
- {0xA62A, 0xA62B}, {0xA640, 0xA66D}, {0xA66E, 0xA66E},
- {0xA66F, 0xA66F}, {0xA670, 0xA672}, {0xA673, 0xA673},
- {0xA674, 0xA67D}, {0xA67E, 0xA67E}, {0xA67F, 0xA67F},
- {0xA680, 0xA69B}, {0xA69C, 0xA69D}, {0xA69E, 0xA69F},
- {0xA6A0, 0xA6E5}, {0xA6E6, 0xA6EF}, {0xA6F0, 0xA6F1},
- {0xA6F2, 0xA6F7}, {0xA700, 0xA716}, {0xA717, 0xA71F},
- {0xA720, 0xA721}, {0xA722, 0xA76F}, {0xA770, 0xA770},
- {0xA771, 0xA787}, {0xA788, 0xA788}, {0xA789, 0xA78A},
- {0xA78B, 0xA78E}, {0xA78F, 0xA78F}, {0xA790, 0xA7AE},
- {0xA7B0, 0xA7B7}, {0xA7F7, 0xA7F7}, {0xA7F8, 0xA7F9},
- {0xA7FA, 0xA7FA}, {0xA7FB, 0xA7FF}, {0xA800, 0xA801},
- {0xA802, 0xA802}, {0xA803, 0xA805}, {0xA806, 0xA806},
- {0xA807, 0xA80A}, {0xA80B, 0xA80B}, {0xA80C, 0xA822},
- {0xA823, 0xA824}, {0xA825, 0xA826}, {0xA827, 0xA827},
- {0xA828, 0xA82B}, {0xA830, 0xA835}, {0xA836, 0xA837},
- {0xA838, 0xA838}, {0xA839, 0xA839}, {0xA840, 0xA873},
- {0xA874, 0xA877}, {0xA880, 0xA881}, {0xA882, 0xA8B3},
- {0xA8B4, 0xA8C3}, {0xA8C4, 0xA8C5}, {0xA8CE, 0xA8CF},
- {0xA8D0, 0xA8D9}, {0xA8E0, 0xA8F1}, {0xA8F2, 0xA8F7},
- {0xA8F8, 0xA8FA}, {0xA8FB, 0xA8FB}, {0xA8FC, 0xA8FC},
- {0xA8FD, 0xA8FD}, {0xA900, 0xA909}, {0xA90A, 0xA925},
- {0xA926, 0xA92D}, {0xA92E, 0xA92F}, {0xA930, 0xA946},
- {0xA947, 0xA951}, {0xA952, 0xA953}, {0xA95F, 0xA95F},
- {0xA980, 0xA982}, {0xA983, 0xA983}, {0xA984, 0xA9B2},
- {0xA9B3, 0xA9B3}, {0xA9B4, 0xA9B5}, {0xA9B6, 0xA9B9},
- {0xA9BA, 0xA9BB}, {0xA9BC, 0xA9BC}, {0xA9BD, 0xA9C0},
- {0xA9C1, 0xA9CD}, {0xA9CF, 0xA9CF}, {0xA9D0, 0xA9D9},
- {0xA9DE, 0xA9DF}, {0xA9E0, 0xA9E4}, {0xA9E5, 0xA9E5},
- {0xA9E6, 0xA9E6}, {0xA9E7, 0xA9EF}, {0xA9F0, 0xA9F9},
- {0xA9FA, 0xA9FE}, {0xAA00, 0xAA28}, {0xAA29, 0xAA2E},
- {0xAA2F, 0xAA30}, {0xAA31, 0xAA32}, {0xAA33, 0xAA34},
- {0xAA35, 0xAA36}, {0xAA40, 0xAA42}, {0xAA43, 0xAA43},
- {0xAA44, 0xAA4B}, {0xAA4C, 0xAA4C}, {0xAA4D, 0xAA4D},
- {0xAA50, 0xAA59}, {0xAA5C, 0xAA5F}, {0xAA60, 0xAA6F},
- {0xAA70, 0xAA70}, {0xAA71, 0xAA76}, {0xAA77, 0xAA79},
- {0xAA7A, 0xAA7A}, {0xAA7B, 0xAA7B}, {0xAA7C, 0xAA7C},
- {0xAA7D, 0xAA7D}, {0xAA7E, 0xAA7F}, {0xAA80, 0xAAAF},
- {0xAAB0, 0xAAB0}, {0xAAB1, 0xAAB1}, {0xAAB2, 0xAAB4},
- {0xAAB5, 0xAAB6}, {0xAAB7, 0xAAB8}, {0xAAB9, 0xAABD},
- {0xAABE, 0xAABF}, {0xAAC0, 0xAAC0}, {0xAAC1, 0xAAC1},
- {0xAAC2, 0xAAC2}, {0xAADB, 0xAADC}, {0xAADD, 0xAADD},
- {0xAADE, 0xAADF}, {0xAAE0, 0xAAEA}, {0xAAEB, 0xAAEB},
- {0xAAEC, 0xAAED}, {0xAAEE, 0xAAEF}, {0xAAF0, 0xAAF1},
- {0xAAF2, 0xAAF2}, {0xAAF3, 0xAAF4}, {0xAAF5, 0xAAF5},
- {0xAAF6, 0xAAF6}, {0xAB01, 0xAB06}, {0xAB09, 0xAB0E},
- {0xAB11, 0xAB16}, {0xAB20, 0xAB26}, {0xAB28, 0xAB2E},
- {0xAB30, 0xAB5A}, {0xAB5B, 0xAB5B}, {0xAB5C, 0xAB5F},
- {0xAB60, 0xAB65}, {0xAB70, 0xABBF}, {0xABC0, 0xABE2},
- {0xABE3, 0xABE4}, {0xABE5, 0xABE5}, {0xABE6, 0xABE7},
- {0xABE8, 0xABE8}, {0xABE9, 0xABEA}, {0xABEB, 0xABEB},
- {0xABEC, 0xABEC}, {0xABED, 0xABED}, {0xABF0, 0xABF9},
- {0xD7B0, 0xD7C6}, {0xD7CB, 0xD7FB}, {0xD800, 0xDB7F},
- {0xDB80, 0xDBFF}, {0xDC00, 0xDFFF}, {0xFB00, 0xFB06},
- {0xFB13, 0xFB17}, {0xFB1D, 0xFB1D}, {0xFB1E, 0xFB1E},
- {0xFB1F, 0xFB28}, {0xFB29, 0xFB29}, {0xFB2A, 0xFB36},
- {0xFB38, 0xFB3C}, {0xFB3E, 0xFB3E}, {0xFB40, 0xFB41},
- {0xFB43, 0xFB44}, {0xFB46, 0xFB4F}, {0xFB50, 0xFBB1},
- {0xFBB2, 0xFBC1}, {0xFBD3, 0xFD3D}, {0xFD3E, 0xFD3E},
- {0xFD3F, 0xFD3F}, {0xFD50, 0xFD8F}, {0xFD92, 0xFDC7},
- {0xFDF0, 0xFDFB}, {0xFDFC, 0xFDFC}, {0xFDFD, 0xFDFD},
- {0xFE20, 0xFE2F}, {0xFE70, 0xFE74}, {0xFE76, 0xFEFC},
- {0xFEFF, 0xFEFF}, {0xFFF9, 0xFFFB}, {0xFFFC, 0xFFFC},
- {0x10000, 0x1000B}, {0x1000D, 0x10026}, {0x10028, 0x1003A},
- {0x1003C, 0x1003D}, {0x1003F, 0x1004D}, {0x10050, 0x1005D},
- {0x10080, 0x100FA}, {0x10100, 0x10102}, {0x10107, 0x10133},
- {0x10137, 0x1013F}, {0x10140, 0x10174}, {0x10175, 0x10178},
- {0x10179, 0x10189}, {0x1018A, 0x1018B}, {0x1018C, 0x1018E},
- {0x10190, 0x1019B}, {0x101A0, 0x101A0}, {0x101D0, 0x101FC},
- {0x101FD, 0x101FD}, {0x10280, 0x1029C}, {0x102A0, 0x102D0},
- {0x102E0, 0x102E0}, {0x102E1, 0x102FB}, {0x10300, 0x1031F},
- {0x10320, 0x10323}, {0x10330, 0x10340}, {0x10341, 0x10341},
- {0x10342, 0x10349}, {0x1034A, 0x1034A}, {0x10350, 0x10375},
- {0x10376, 0x1037A}, {0x10380, 0x1039D}, {0x1039F, 0x1039F},
- {0x103A0, 0x103C3}, {0x103C8, 0x103CF}, {0x103D0, 0x103D0},
- {0x103D1, 0x103D5}, {0x10400, 0x1044F}, {0x10450, 0x1047F},
- {0x10480, 0x1049D}, {0x104A0, 0x104A9}, {0x104B0, 0x104D3},
- {0x104D8, 0x104FB}, {0x10500, 0x10527}, {0x10530, 0x10563},
- {0x1056F, 0x1056F}, {0x10600, 0x10736}, {0x10740, 0x10755},
- {0x10760, 0x10767}, {0x10800, 0x10805}, {0x10808, 0x10808},
- {0x1080A, 0x10835}, {0x10837, 0x10838}, {0x1083C, 0x1083C},
- {0x1083F, 0x1083F}, {0x10840, 0x10855}, {0x10857, 0x10857},
- {0x10858, 0x1085F}, {0x10860, 0x10876}, {0x10877, 0x10878},
- {0x10879, 0x1087F}, {0x10880, 0x1089E}, {0x108A7, 0x108AF},
- {0x108E0, 0x108F2}, {0x108F4, 0x108F5}, {0x108FB, 0x108FF},
- {0x10900, 0x10915}, {0x10916, 0x1091B}, {0x1091F, 0x1091F},
- {0x10920, 0x10939}, {0x1093F, 0x1093F}, {0x10980, 0x1099F},
- {0x109A0, 0x109B7}, {0x109BC, 0x109BD}, {0x109BE, 0x109BF},
- {0x109C0, 0x109CF}, {0x109D2, 0x109FF}, {0x10A00, 0x10A00},
- {0x10A01, 0x10A03}, {0x10A05, 0x10A06}, {0x10A0C, 0x10A0F},
- {0x10A10, 0x10A13}, {0x10A15, 0x10A17}, {0x10A19, 0x10A33},
- {0x10A38, 0x10A3A}, {0x10A3F, 0x10A3F}, {0x10A40, 0x10A47},
- {0x10A50, 0x10A58}, {0x10A60, 0x10A7C}, {0x10A7D, 0x10A7E},
- {0x10A7F, 0x10A7F}, {0x10A80, 0x10A9C}, {0x10A9D, 0x10A9F},
- {0x10AC0, 0x10AC7}, {0x10AC8, 0x10AC8}, {0x10AC9, 0x10AE4},
- {0x10AE5, 0x10AE6}, {0x10AEB, 0x10AEF}, {0x10AF0, 0x10AF6},
- {0x10B00, 0x10B35}, {0x10B39, 0x10B3F}, {0x10B40, 0x10B55},
- {0x10B58, 0x10B5F}, {0x10B60, 0x10B72}, {0x10B78, 0x10B7F},
- {0x10B80, 0x10B91}, {0x10B99, 0x10B9C}, {0x10BA9, 0x10BAF},
- {0x10C00, 0x10C48}, {0x10C80, 0x10CB2}, {0x10CC0, 0x10CF2},
- {0x10CFA, 0x10CFF}, {0x10E60, 0x10E7E}, {0x11000, 0x11000},
- {0x11001, 0x11001}, {0x11002, 0x11002}, {0x11003, 0x11037},
- {0x11038, 0x11046}, {0x11047, 0x1104D}, {0x11052, 0x11065},
- {0x11066, 0x1106F}, {0x1107F, 0x1107F}, {0x11080, 0x11081},
- {0x11082, 0x11082}, {0x11083, 0x110AF}, {0x110B0, 0x110B2},
- {0x110B3, 0x110B6}, {0x110B7, 0x110B8}, {0x110B9, 0x110BA},
- {0x110BB, 0x110BC}, {0x110BD, 0x110BD}, {0x110BE, 0x110C1},
- {0x110D0, 0x110E8}, {0x110F0, 0x110F9}, {0x11100, 0x11102},
- {0x11103, 0x11126}, {0x11127, 0x1112B}, {0x1112C, 0x1112C},
- {0x1112D, 0x11134}, {0x11136, 0x1113F}, {0x11140, 0x11143},
- {0x11150, 0x11172}, {0x11173, 0x11173}, {0x11174, 0x11175},
- {0x11176, 0x11176}, {0x11180, 0x11181}, {0x11182, 0x11182},
- {0x11183, 0x111B2}, {0x111B3, 0x111B5}, {0x111B6, 0x111BE},
- {0x111BF, 0x111C0}, {0x111C1, 0x111C4}, {0x111C5, 0x111C9},
- {0x111CA, 0x111CC}, {0x111CD, 0x111CD}, {0x111D0, 0x111D9},
- {0x111DA, 0x111DA}, {0x111DB, 0x111DB}, {0x111DC, 0x111DC},
- {0x111DD, 0x111DF}, {0x111E1, 0x111F4}, {0x11200, 0x11211},
- {0x11213, 0x1122B}, {0x1122C, 0x1122E}, {0x1122F, 0x11231},
- {0x11232, 0x11233}, {0x11234, 0x11234}, {0x11235, 0x11235},
- {0x11236, 0x11237}, {0x11238, 0x1123D}, {0x1123E, 0x1123E},
- {0x11280, 0x11286}, {0x11288, 0x11288}, {0x1128A, 0x1128D},
- {0x1128F, 0x1129D}, {0x1129F, 0x112A8}, {0x112A9, 0x112A9},
- {0x112B0, 0x112DE}, {0x112DF, 0x112DF}, {0x112E0, 0x112E2},
- {0x112E3, 0x112EA}, {0x112F0, 0x112F9}, {0x11300, 0x11301},
- {0x11302, 0x11303}, {0x11305, 0x1130C}, {0x1130F, 0x11310},
- {0x11313, 0x11328}, {0x1132A, 0x11330}, {0x11332, 0x11333},
- {0x11335, 0x11339}, {0x1133C, 0x1133C}, {0x1133D, 0x1133D},
- {0x1133E, 0x1133F}, {0x11340, 0x11340}, {0x11341, 0x11344},
- {0x11347, 0x11348}, {0x1134B, 0x1134D}, {0x11350, 0x11350},
- {0x11357, 0x11357}, {0x1135D, 0x11361}, {0x11362, 0x11363},
- {0x11366, 0x1136C}, {0x11370, 0x11374}, {0x11400, 0x11434},
- {0x11435, 0x11437}, {0x11438, 0x1143F}, {0x11440, 0x11441},
- {0x11442, 0x11444}, {0x11445, 0x11445}, {0x11446, 0x11446},
- {0x11447, 0x1144A}, {0x1144B, 0x1144F}, {0x11450, 0x11459},
- {0x1145B, 0x1145B}, {0x1145D, 0x1145D}, {0x11480, 0x114AF},
- {0x114B0, 0x114B2}, {0x114B3, 0x114B8}, {0x114B9, 0x114B9},
- {0x114BA, 0x114BA}, {0x114BB, 0x114BE}, {0x114BF, 0x114C0},
- {0x114C1, 0x114C1}, {0x114C2, 0x114C3}, {0x114C4, 0x114C5},
- {0x114C6, 0x114C6}, {0x114C7, 0x114C7}, {0x114D0, 0x114D9},
- {0x11580, 0x115AE}, {0x115AF, 0x115B1}, {0x115B2, 0x115B5},
- {0x115B8, 0x115BB}, {0x115BC, 0x115BD}, {0x115BE, 0x115BE},
- {0x115BF, 0x115C0}, {0x115C1, 0x115D7}, {0x115D8, 0x115DB},
- {0x115DC, 0x115DD}, {0x11600, 0x1162F}, {0x11630, 0x11632},
- {0x11633, 0x1163A}, {0x1163B, 0x1163C}, {0x1163D, 0x1163D},
- {0x1163E, 0x1163E}, {0x1163F, 0x11640}, {0x11641, 0x11643},
- {0x11644, 0x11644}, {0x11650, 0x11659}, {0x11660, 0x1166C},
- {0x11680, 0x116AA}, {0x116AB, 0x116AB}, {0x116AC, 0x116AC},
- {0x116AD, 0x116AD}, {0x116AE, 0x116AF}, {0x116B0, 0x116B5},
- {0x116B6, 0x116B6}, {0x116B7, 0x116B7}, {0x116C0, 0x116C9},
- {0x11700, 0x11719}, {0x1171D, 0x1171F}, {0x11720, 0x11721},
- {0x11722, 0x11725}, {0x11726, 0x11726}, {0x11727, 0x1172B},
- {0x11730, 0x11739}, {0x1173A, 0x1173B}, {0x1173C, 0x1173E},
- {0x1173F, 0x1173F}, {0x118A0, 0x118DF}, {0x118E0, 0x118E9},
- {0x118EA, 0x118F2}, {0x118FF, 0x118FF}, {0x11AC0, 0x11AF8},
- {0x11C00, 0x11C08}, {0x11C0A, 0x11C2E}, {0x11C2F, 0x11C2F},
- {0x11C30, 0x11C36}, {0x11C38, 0x11C3D}, {0x11C3E, 0x11C3E},
- {0x11C3F, 0x11C3F}, {0x11C40, 0x11C40}, {0x11C41, 0x11C45},
- {0x11C50, 0x11C59}, {0x11C5A, 0x11C6C}, {0x11C70, 0x11C71},
- {0x11C72, 0x11C8F}, {0x11C92, 0x11CA7}, {0x11CA9, 0x11CA9},
- {0x11CAA, 0x11CB0}, {0x11CB1, 0x11CB1}, {0x11CB2, 0x11CB3},
- {0x11CB4, 0x11CB4}, {0x11CB5, 0x11CB6}, {0x12000, 0x12399},
- {0x12400, 0x1246E}, {0x12470, 0x12474}, {0x12480, 0x12543},
- {0x13000, 0x1342E}, {0x14400, 0x14646}, {0x16800, 0x16A38},
- {0x16A40, 0x16A5E}, {0x16A60, 0x16A69}, {0x16A6E, 0x16A6F},
- {0x16AD0, 0x16AED}, {0x16AF0, 0x16AF4}, {0x16AF5, 0x16AF5},
- {0x16B00, 0x16B2F}, {0x16B30, 0x16B36}, {0x16B37, 0x16B3B},
- {0x16B3C, 0x16B3F}, {0x16B40, 0x16B43}, {0x16B44, 0x16B44},
- {0x16B45, 0x16B45}, {0x16B50, 0x16B59}, {0x16B5B, 0x16B61},
- {0x16B63, 0x16B77}, {0x16B7D, 0x16B8F}, {0x16F00, 0x16F44},
- {0x16F50, 0x16F50}, {0x16F51, 0x16F7E}, {0x16F8F, 0x16F92},
- {0x16F93, 0x16F9F}, {0x1BC00, 0x1BC6A}, {0x1BC70, 0x1BC7C},
- {0x1BC80, 0x1BC88}, {0x1BC90, 0x1BC99}, {0x1BC9C, 0x1BC9C},
- {0x1BC9D, 0x1BC9E}, {0x1BC9F, 0x1BC9F}, {0x1BCA0, 0x1BCA3},
- {0x1D000, 0x1D0F5}, {0x1D100, 0x1D126}, {0x1D129, 0x1D164},
- {0x1D165, 0x1D166}, {0x1D167, 0x1D169}, {0x1D16A, 0x1D16C},
- {0x1D16D, 0x1D172}, {0x1D173, 0x1D17A}, {0x1D17B, 0x1D182},
- {0x1D183, 0x1D184}, {0x1D185, 0x1D18B}, {0x1D18C, 0x1D1A9},
- {0x1D1AA, 0x1D1AD}, {0x1D1AE, 0x1D1E8}, {0x1D200, 0x1D241},
- {0x1D242, 0x1D244}, {0x1D245, 0x1D245}, {0x1D300, 0x1D356},
- {0x1D360, 0x1D371}, {0x1D400, 0x1D454}, {0x1D456, 0x1D49C},
- {0x1D49E, 0x1D49F}, {0x1D4A2, 0x1D4A2}, {0x1D4A5, 0x1D4A6},
- {0x1D4A9, 0x1D4AC}, {0x1D4AE, 0x1D4B9}, {0x1D4BB, 0x1D4BB},
- {0x1D4BD, 0x1D4C3}, {0x1D4C5, 0x1D505}, {0x1D507, 0x1D50A},
- {0x1D50D, 0x1D514}, {0x1D516, 0x1D51C}, {0x1D51E, 0x1D539},
- {0x1D53B, 0x1D53E}, {0x1D540, 0x1D544}, {0x1D546, 0x1D546},
- {0x1D54A, 0x1D550}, {0x1D552, 0x1D6A5}, {0x1D6A8, 0x1D6C0},
- {0x1D6C1, 0x1D6C1}, {0x1D6C2, 0x1D6DA}, {0x1D6DB, 0x1D6DB},
- {0x1D6DC, 0x1D6FA}, {0x1D6FB, 0x1D6FB}, {0x1D6FC, 0x1D714},
- {0x1D715, 0x1D715}, {0x1D716, 0x1D734}, {0x1D735, 0x1D735},
- {0x1D736, 0x1D74E}, {0x1D74F, 0x1D74F}, {0x1D750, 0x1D76E},
- {0x1D76F, 0x1D76F}, {0x1D770, 0x1D788}, {0x1D789, 0x1D789},
- {0x1D78A, 0x1D7A8}, {0x1D7A9, 0x1D7A9}, {0x1D7AA, 0x1D7C2},
- {0x1D7C3, 0x1D7C3}, {0x1D7C4, 0x1D7CB}, {0x1D7CE, 0x1D7FF},
- {0x1D800, 0x1D9FF}, {0x1DA00, 0x1DA36}, {0x1DA37, 0x1DA3A},
- {0x1DA3B, 0x1DA6C}, {0x1DA6D, 0x1DA74}, {0x1DA75, 0x1DA75},
- {0x1DA76, 0x1DA83}, {0x1DA84, 0x1DA84}, {0x1DA85, 0x1DA86},
- {0x1DA87, 0x1DA8B}, {0x1DA9B, 0x1DA9F}, {0x1DAA1, 0x1DAAF},
- {0x1E000, 0x1E006}, {0x1E008, 0x1E018}, {0x1E01B, 0x1E021},
- {0x1E023, 0x1E024}, {0x1E026, 0x1E02A}, {0x1E800, 0x1E8C4},
- {0x1E8C7, 0x1E8CF}, {0x1E8D0, 0x1E8D6}, {0x1E900, 0x1E943},
- {0x1E944, 0x1E94A}, {0x1E950, 0x1E959}, {0x1E95E, 0x1E95F},
- {0x1EE00, 0x1EE03}, {0x1EE05, 0x1EE1F}, {0x1EE21, 0x1EE22},
- {0x1EE24, 0x1EE24}, {0x1EE27, 0x1EE27}, {0x1EE29, 0x1EE32},
- {0x1EE34, 0x1EE37}, {0x1EE39, 0x1EE39}, {0x1EE3B, 0x1EE3B},
- {0x1EE42, 0x1EE42}, {0x1EE47, 0x1EE47}, {0x1EE49, 0x1EE49},
- {0x1EE4B, 0x1EE4B}, {0x1EE4D, 0x1EE4F}, {0x1EE51, 0x1EE52},
- {0x1EE54, 0x1EE54}, {0x1EE57, 0x1EE57}, {0x1EE59, 0x1EE59},
- {0x1EE5B, 0x1EE5B}, {0x1EE5D, 0x1EE5D}, {0x1EE5F, 0x1EE5F},
- {0x1EE61, 0x1EE62}, {0x1EE64, 0x1EE64}, {0x1EE67, 0x1EE6A},
- {0x1EE6C, 0x1EE72}, {0x1EE74, 0x1EE77}, {0x1EE79, 0x1EE7C},
- {0x1EE7E, 0x1EE7E}, {0x1EE80, 0x1EE89}, {0x1EE8B, 0x1EE9B},
- {0x1EEA1, 0x1EEA3}, {0x1EEA5, 0x1EEA9}, {0x1EEAB, 0x1EEBB},
- {0x1EEF0, 0x1EEF1}, {0x1F000, 0x1F003}, {0x1F005, 0x1F02B},
- {0x1F030, 0x1F093}, {0x1F0A0, 0x1F0AE}, {0x1F0B1, 0x1F0BF},
- {0x1F0C1, 0x1F0CE}, {0x1F0D1, 0x1F0F5}, {0x1F10B, 0x1F10C},
- {0x1F12E, 0x1F12E}, {0x1F16A, 0x1F16B}, {0x1F1E6, 0x1F1FF},
- {0x1F321, 0x1F32C}, {0x1F336, 0x1F336}, {0x1F37D, 0x1F37D},
- {0x1F394, 0x1F39F}, {0x1F3CB, 0x1F3CE}, {0x1F3D4, 0x1F3DF},
- {0x1F3F1, 0x1F3F3}, {0x1F3F5, 0x1F3F7}, {0x1F43F, 0x1F43F},
- {0x1F441, 0x1F441}, {0x1F4FD, 0x1F4FE}, {0x1F53E, 0x1F54A},
- {0x1F54F, 0x1F54F}, {0x1F568, 0x1F579}, {0x1F57B, 0x1F594},
- {0x1F597, 0x1F5A3}, {0x1F5A5, 0x1F5FA}, {0x1F650, 0x1F67F},
- {0x1F6C6, 0x1F6CB}, {0x1F6CD, 0x1F6CF}, {0x1F6E0, 0x1F6EA},
- {0x1F6F0, 0x1F6F3}, {0x1F700, 0x1F773}, {0x1F780, 0x1F7D4},
- {0x1F800, 0x1F80B}, {0x1F810, 0x1F847}, {0x1F850, 0x1F859},
- {0x1F860, 0x1F887}, {0x1F890, 0x1F8AD}, {0xE0001, 0xE0001},
- {0xE0020, 0xE007F},
-}
-
-// Condition have flag EastAsianWidth whether the current locale is CJK or not.
-type Condition struct {
- EastAsianWidth bool
-}
-
-// NewCondition return new instance of Condition which is current locale.
-func NewCondition() *Condition {
- return &Condition{EastAsianWidth}
-}
-
-// RuneWidth returns the number of cells in r.
-// See http://www.unicode.org/reports/tr11/
-func (c *Condition) RuneWidth(r rune) int {
- switch {
- case r < 0 || r > 0x10FFFF ||
- inTables(r, nonprint, combining, notassigned):
- return 0
- case (c.EastAsianWidth && IsAmbiguousWidth(r)) ||
- inTables(r, doublewidth, emoji):
- return 2
- default:
- return 1
- }
-}
-
-// StringWidth return width as you can see
-func (c *Condition) StringWidth(s string) (width int) {
- for _, r := range []rune(s) {
- width += c.RuneWidth(r)
- }
- return width
-}
-
-// Truncate return string truncated with w cells
-func (c *Condition) Truncate(s string, w int, tail string) string {
- if c.StringWidth(s) <= w {
- return s
- }
- r := []rune(s)
- tw := c.StringWidth(tail)
- w -= tw
- width := 0
- i := 0
- for ; i < len(r); i++ {
- cw := c.RuneWidth(r[i])
- if width+cw > w {
- break
- }
- width += cw
- }
- return string(r[0:i]) + tail
-}
-
-// Wrap return string wrapped with w cells
-func (c *Condition) Wrap(s string, w int) string {
- width := 0
- out := ""
- for _, r := range []rune(s) {
- cw := RuneWidth(r)
- if r == '\n' {
- out += string(r)
- width = 0
- continue
- } else if width+cw > w {
- out += "\n"
- width = 0
- out += string(r)
- width += cw
- continue
- }
- out += string(r)
- width += cw
- }
- return out
-}
-
-// FillLeft return string filled in left by spaces in w cells
-func (c *Condition) FillLeft(s string, w int) string {
- width := c.StringWidth(s)
- count := w - width
- if count > 0 {
- b := make([]byte, count)
- for i := range b {
- b[i] = ' '
- }
- return string(b) + s
- }
- return s
-}
-
-// FillRight return string filled in left by spaces in w cells
-func (c *Condition) FillRight(s string, w int) string {
- width := c.StringWidth(s)
- count := w - width
- if count > 0 {
- b := make([]byte, count)
- for i := range b {
- b[i] = ' '
- }
- return s + string(b)
- }
- return s
-}
-
-// RuneWidth returns the number of cells in r.
-// See http://www.unicode.org/reports/tr11/
-func RuneWidth(r rune) int {
- return DefaultCondition.RuneWidth(r)
-}
-
-// IsAmbiguousWidth returns whether is ambiguous width or not.
-func IsAmbiguousWidth(r rune) bool {
- return inTables(r, private, ambiguous)
-}
-
-// IsNeutralWidth returns whether is neutral width or not.
-func IsNeutralWidth(r rune) bool {
- return inTable(r, neutral)
-}
-
-// StringWidth return width as you can see
-func StringWidth(s string) (width int) {
- return DefaultCondition.StringWidth(s)
-}
-
-// Truncate return string truncated with w cells
-func Truncate(s string, w int, tail string) string {
- return DefaultCondition.Truncate(s, w, tail)
-}
-
-// Wrap return string wrapped with w cells
-func Wrap(s string, w int) string {
- return DefaultCondition.Wrap(s, w)
-}
-
-// FillLeft return string filled in left by spaces in w cells
-func FillLeft(s string, w int) string {
- return DefaultCondition.FillLeft(s, w)
-}
-
-// FillRight return string filled in left by spaces in w cells
-func FillRight(s string, w int) string {
- return DefaultCondition.FillRight(s, w)
-}
diff --git a/vendor/github.com/mattn/go-runewidth/runewidth_js.go b/vendor/github.com/mattn/go-runewidth/runewidth_js.go
deleted file mode 100644
index 0ce32c5..0000000
--- a/vendor/github.com/mattn/go-runewidth/runewidth_js.go
+++ /dev/null
@@ -1,8 +0,0 @@
-// +build js
-
-package runewidth
-
-func IsEastAsian() bool {
- // TODO: Implement this for the web. Detect east asian in a compatible way, and return true.
- return false
-}
diff --git a/vendor/github.com/mattn/go-runewidth/runewidth_posix.go b/vendor/github.com/mattn/go-runewidth/runewidth_posix.go
deleted file mode 100644
index c579e9a..0000000
--- a/vendor/github.com/mattn/go-runewidth/runewidth_posix.go
+++ /dev/null
@@ -1,77 +0,0 @@
-// +build !windows,!js
-
-package runewidth
-
-import (
- "os"
- "regexp"
- "strings"
-)
-
-var reLoc = regexp.MustCompile(`^[a-z][a-z][a-z]?(?:_[A-Z][A-Z])?\.(.+)`)
-
-var mblenTable = map[string]int{
- "utf-8": 6,
- "utf8": 6,
- "jis": 8,
- "eucjp": 3,
- "euckr": 2,
- "euccn": 2,
- "sjis": 2,
- "cp932": 2,
- "cp51932": 2,
- "cp936": 2,
- "cp949": 2,
- "cp950": 2,
- "big5": 2,
- "gbk": 2,
- "gb2312": 2,
-}
-
-func isEastAsian(locale string) bool {
- charset := strings.ToLower(locale)
- r := reLoc.FindStringSubmatch(locale)
- if len(r) == 2 {
- charset = strings.ToLower(r[1])
- }
-
- if strings.HasSuffix(charset, "@cjk_narrow") {
- return false
- }
-
- for pos, b := range []byte(charset) {
- if b == '@' {
- charset = charset[:pos]
- break
- }
- }
- max := 1
- if m, ok := mblenTable[charset]; ok {
- max = m
- }
- if max > 1 && (charset[0] != 'u' ||
- strings.HasPrefix(locale, "ja") ||
- strings.HasPrefix(locale, "ko") ||
- strings.HasPrefix(locale, "zh")) {
- return true
- }
- return false
-}
-
-// IsEastAsian return true if the current locale is CJK
-func IsEastAsian() bool {
- locale := os.Getenv("LC_CTYPE")
- if locale == "" {
- locale = os.Getenv("LANG")
- }
-
- // ignore C locale
- if locale == "POSIX" || locale == "C" {
- return false
- }
- if len(locale) > 1 && locale[0] == 'C' && (locale[1] == '.' || locale[1] == '-') {
- return false
- }
-
- return isEastAsian(locale)
-}
diff --git a/vendor/github.com/mattn/go-runewidth/runewidth_windows.go b/vendor/github.com/mattn/go-runewidth/runewidth_windows.go
deleted file mode 100644
index 0258876..0000000
--- a/vendor/github.com/mattn/go-runewidth/runewidth_windows.go
+++ /dev/null
@@ -1,25 +0,0 @@
-package runewidth
-
-import (
- "syscall"
-)
-
-var (
- kernel32 = syscall.NewLazyDLL("kernel32")
- procGetConsoleOutputCP = kernel32.NewProc("GetConsoleOutputCP")
-)
-
-// IsEastAsian return true if the current locale is CJK
-func IsEastAsian() bool {
- r1, _, _ := procGetConsoleOutputCP.Call()
- if r1 == 0 {
- return false
- }
-
- switch int(r1) {
- case 932, 51932, 936, 949, 950:
- return true
- }
-
- return false
-}
diff --git a/vendor/github.com/nsf/termbox-go/AUTHORS b/vendor/github.com/nsf/termbox-go/AUTHORS
deleted file mode 100644
index fe26fb0..0000000
--- a/vendor/github.com/nsf/termbox-go/AUTHORS
+++ /dev/null
@@ -1,4 +0,0 @@
-# Please keep this file sorted.
-
-Georg Reinke
-nsf
diff --git a/vendor/github.com/nsf/termbox-go/LICENSE b/vendor/github.com/nsf/termbox-go/LICENSE
deleted file mode 100644
index d9bc068..0000000
--- a/vendor/github.com/nsf/termbox-go/LICENSE
+++ /dev/null
@@ -1,19 +0,0 @@
-Copyright (C) 2012 termbox-go authors
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
diff --git a/vendor/github.com/nsf/termbox-go/README.md b/vendor/github.com/nsf/termbox-go/README.md
deleted file mode 100644
index fcc493d..0000000
--- a/vendor/github.com/nsf/termbox-go/README.md
+++ /dev/null
@@ -1,38 +0,0 @@
-[](http://godoc.org/github.com/nsf/termbox-go)
-
-## Termbox
-Termbox is a library that provides a minimalistic API which allows the programmer to write text-based user interfaces. The library is crossplatform and has both terminal-based implementations on *nix operating systems and a winapi console based implementation for windows operating systems. The basic idea is an abstraction of the greatest common subset of features available on all major terminals and other terminal-like APIs in a minimalistic fashion. Small API means it is easy to implement, test, maintain and learn it, that's what makes the termbox a distinct library in its area.
-
-### Installation
-Install and update this go package with `go get -u github.com/nsf/termbox-go`
-
-### Examples
-For examples of what can be done take a look at demos in the _demos directory. You can try them with go run: `go run _demos/keyboard.go`
-
-There are also some interesting projects using termbox-go:
- - [godit](https://github.com/nsf/godit) is an emacsish lightweight text editor written using termbox.
- - [gomatrix](https://github.com/GeertJohan/gomatrix) connects to The Matrix and displays its data streams in your terminal.
- - [gotetris](https://github.com/jjinux/gotetris) is an implementation of Tetris.
- - [sokoban-go](https://github.com/rn2dy/sokoban-go) is an implementation of sokoban game.
- - [hecate](https://github.com/evanmiller/hecate) is a hex editor designed by Satan.
- - [httopd](https://github.com/verdverm/httopd) is top for httpd logs.
- - [mop](https://github.com/mop-tracker/mop) is stock market tracker for hackers.
- - [termui](https://github.com/gizak/termui) is a terminal dashboard.
- - [termloop](https://github.com/JoelOtter/termloop) is a terminal game engine.
- - [xterm-color-chart](https://github.com/kutuluk/xterm-color-chart) is a XTerm 256 color chart.
- - [gocui](https://github.com/jroimartin/gocui) is a minimalist Go library aimed at creating console user interfaces.
- - [dry](https://github.com/moncho/dry) is an interactive cli to manage Docker containers.
- - [pxl](https://github.com/ichinaski/pxl) displays images in the terminal.
- - [snake-game](https://github.com/DyegoCosta/snake-game) is an implementation of the Snake game.
- - [gone](https://github.com/guillaumebreton/gone) is a CLI pomodoro® timer.
- - [Spoof.go](https://github.com/sabey/spoofgo) controllable movement spoofing from the cli
- - [lf](https://github.com/gokcehan/lf) is a terminal file manager
- - [rat](https://github.com/ericfreese/rat) lets you compose shell commands to build terminal applications.
- - [httplab](https://github.com/gchaincl/httplab) An interactive web server.
- - [tetris](https://github.com/MichaelS11/tetris) Go Tetris with AI option
- - [wot](https://github.com/kyu-suke/wot) Wait time during command is completed.
- - [2048-go](https://github.com/1984weed/2048-go) is 2048 in Go
- - [jv](https://github.com/maxzender/jv) helps you view JSON on the command-line.
- - [pinger](https://github.com/hirose31/pinger) helps you to monitor numerous hosts using ICMP ECHO_REQUEST.
- - [vixl44](https://github.com/sebashwa/vixl44) lets you create pixel art inside your terminal using vim movements
- - [zterm](https://github.com/varunrau/zterm) is a typing game inspired by http://zty.pe/
diff --git a/vendor/github.com/nsf/termbox-go/api.go b/vendor/github.com/nsf/termbox-go/api.go
deleted file mode 100644
index d530ab5..0000000
--- a/vendor/github.com/nsf/termbox-go/api.go
+++ /dev/null
@@ -1,489 +0,0 @@
-// +build !windows
-
-package termbox
-
-import "github.com/mattn/go-runewidth"
-import "fmt"
-import "os"
-import "os/signal"
-import "syscall"
-import "runtime"
-import "time"
-
-// public API
-
-// Initializes termbox library. This function should be called before any other functions.
-// After successful initialization, the library must be finalized using 'Close' function.
-//
-// Example usage:
-// err := termbox.Init()
-// if err != nil {
-// panic(err)
-// }
-// defer termbox.Close()
-func Init() error {
- var err error
-
- out, err = os.OpenFile("/dev/tty", syscall.O_WRONLY, 0)
- if err != nil {
- return err
- }
- in, err = syscall.Open("/dev/tty", syscall.O_RDONLY, 0)
- if err != nil {
- return err
- }
-
- err = setup_term()
- if err != nil {
- return fmt.Errorf("termbox: error while reading terminfo data: %v", err)
- }
-
- signal.Notify(sigwinch, syscall.SIGWINCH)
- signal.Notify(sigio, syscall.SIGIO)
-
- _, err = fcntl(in, syscall.F_SETFL, syscall.O_ASYNC|syscall.O_NONBLOCK)
- if err != nil {
- return err
- }
- _, err = fcntl(in, syscall.F_SETOWN, syscall.Getpid())
- if runtime.GOOS != "darwin" && err != nil {
- return err
- }
- err = tcgetattr(out.Fd(), &orig_tios)
- if err != nil {
- return err
- }
-
- tios := orig_tios
- tios.Iflag &^= syscall_IGNBRK | syscall_BRKINT | syscall_PARMRK |
- syscall_ISTRIP | syscall_INLCR | syscall_IGNCR |
- syscall_ICRNL | syscall_IXON
- tios.Lflag &^= syscall_ECHO | syscall_ECHONL | syscall_ICANON |
- syscall_ISIG | syscall_IEXTEN
- tios.Cflag &^= syscall_CSIZE | syscall_PARENB
- tios.Cflag |= syscall_CS8
- tios.Cc[syscall_VMIN] = 1
- tios.Cc[syscall_VTIME] = 0
-
- err = tcsetattr(out.Fd(), &tios)
- if err != nil {
- return err
- }
-
- out.WriteString(funcs[t_enter_ca])
- out.WriteString(funcs[t_enter_keypad])
- out.WriteString(funcs[t_hide_cursor])
- out.WriteString(funcs[t_clear_screen])
-
- termw, termh = get_term_size(out.Fd())
- back_buffer.init(termw, termh)
- front_buffer.init(termw, termh)
- back_buffer.clear()
- front_buffer.clear()
-
- go func() {
- buf := make([]byte, 128)
- for {
- select {
- case <-sigio:
- for {
- n, err := syscall.Read(in, buf)
- if err == syscall.EAGAIN || err == syscall.EWOULDBLOCK {
- break
- }
- select {
- case input_comm <- input_event{buf[:n], err}:
- ie := <-input_comm
- buf = ie.data[:128]
- case <-quit:
- return
- }
- }
- case <-quit:
- return
- }
- }
- }()
-
- IsInit = true
- return nil
-}
-
-// Interrupt an in-progress call to PollEvent by causing it to return
-// EventInterrupt. Note that this function will block until the PollEvent
-// function has successfully been interrupted.
-func Interrupt() {
- interrupt_comm <- struct{}{}
-}
-
-// Finalizes termbox library, should be called after successful initialization
-// when termbox's functionality isn't required anymore.
-func Close() {
- quit <- 1
- out.WriteString(funcs[t_show_cursor])
- out.WriteString(funcs[t_sgr0])
- out.WriteString(funcs[t_clear_screen])
- out.WriteString(funcs[t_exit_ca])
- out.WriteString(funcs[t_exit_keypad])
- out.WriteString(funcs[t_exit_mouse])
- tcsetattr(out.Fd(), &orig_tios)
-
- out.Close()
- syscall.Close(in)
-
- // reset the state, so that on next Init() it will work again
- termw = 0
- termh = 0
- input_mode = InputEsc
- out = nil
- in = 0
- lastfg = attr_invalid
- lastbg = attr_invalid
- lastx = coord_invalid
- lasty = coord_invalid
- cursor_x = cursor_hidden
- cursor_y = cursor_hidden
- foreground = ColorDefault
- background = ColorDefault
- IsInit = false
-}
-
-// Synchronizes the internal back buffer with the terminal.
-func Flush() error {
- // invalidate cursor position
- lastx = coord_invalid
- lasty = coord_invalid
-
- update_size_maybe()
-
- for y := 0; y < front_buffer.height; y++ {
- line_offset := y * front_buffer.width
- for x := 0; x < front_buffer.width; {
- cell_offset := line_offset + x
- back := &back_buffer.cells[cell_offset]
- front := &front_buffer.cells[cell_offset]
- if back.Ch < ' ' {
- back.Ch = ' '
- }
- w := runewidth.RuneWidth(back.Ch)
- if w == 0 || w == 2 && runewidth.IsAmbiguousWidth(back.Ch) {
- w = 1
- }
- if *back == *front {
- x += w
- continue
- }
- *front = *back
- send_attr(back.Fg, back.Bg)
-
- if w == 2 && x == front_buffer.width-1 {
- // there's not enough space for 2-cells rune,
- // let's just put a space in there
- send_char(x, y, ' ')
- } else {
- send_char(x, y, back.Ch)
- if w == 2 {
- next := cell_offset + 1
- front_buffer.cells[next] = Cell{
- Ch: 0,
- Fg: back.Fg,
- Bg: back.Bg,
- }
- }
- }
- x += w
- }
- }
- if !is_cursor_hidden(cursor_x, cursor_y) {
- write_cursor(cursor_x, cursor_y)
- }
- return flush()
-}
-
-// Sets the position of the cursor. See also HideCursor().
-func SetCursor(x, y int) {
- if is_cursor_hidden(cursor_x, cursor_y) && !is_cursor_hidden(x, y) {
- outbuf.WriteString(funcs[t_show_cursor])
- }
-
- if !is_cursor_hidden(cursor_x, cursor_y) && is_cursor_hidden(x, y) {
- outbuf.WriteString(funcs[t_hide_cursor])
- }
-
- cursor_x, cursor_y = x, y
- if !is_cursor_hidden(cursor_x, cursor_y) {
- write_cursor(cursor_x, cursor_y)
- }
-}
-
-// The shortcut for SetCursor(-1, -1).
-func HideCursor() {
- SetCursor(cursor_hidden, cursor_hidden)
-}
-
-// Changes cell's parameters in the internal back buffer at the specified
-// position.
-func SetCell(x, y int, ch rune, fg, bg Attribute) {
- if x < 0 || x >= back_buffer.width {
- return
- }
- if y < 0 || y >= back_buffer.height {
- return
- }
-
- back_buffer.cells[y*back_buffer.width+x] = Cell{ch, fg, bg}
-}
-
-// Returns a slice into the termbox's back buffer. You can get its dimensions
-// using 'Size' function. The slice remains valid as long as no 'Clear' or
-// 'Flush' function calls were made after call to this function.
-func CellBuffer() []Cell {
- return back_buffer.cells
-}
-
-// After getting a raw event from PollRawEvent function call, you can parse it
-// again into an ordinary one using termbox logic. That is parse an event as
-// termbox would do it. Returned event in addition to usual Event struct fields
-// sets N field to the amount of bytes used within 'data' slice. If the length
-// of 'data' slice is zero or event cannot be parsed for some other reason, the
-// function will return a special event type: EventNone.
-//
-// IMPORTANT: EventNone may contain a non-zero N, which means you should skip
-// these bytes, because termbox cannot recognize them.
-//
-// NOTE: This API is experimental and may change in future.
-func ParseEvent(data []byte) Event {
- event := Event{Type: EventKey}
- status := extract_event(data, &event, false)
- if status != event_extracted {
- return Event{Type: EventNone, N: event.N}
- }
- return event
-}
-
-// Wait for an event and return it. This is a blocking function call. Instead
-// of EventKey and EventMouse it returns EventRaw events. Raw event is written
-// into `data` slice and Event's N field is set to the amount of bytes written.
-// The minimum required length of the 'data' slice is 1. This requirement may
-// vary on different platforms.
-//
-// NOTE: This API is experimental and may change in future.
-func PollRawEvent(data []byte) Event {
- if len(data) == 0 {
- panic("len(data) >= 1 is a requirement")
- }
-
- var event Event
- if extract_raw_event(data, &event) {
- return event
- }
-
- for {
- select {
- case ev := <-input_comm:
- if ev.err != nil {
- return Event{Type: EventError, Err: ev.err}
- }
-
- inbuf = append(inbuf, ev.data...)
- input_comm <- ev
- if extract_raw_event(data, &event) {
- return event
- }
- case <-interrupt_comm:
- event.Type = EventInterrupt
- return event
-
- case <-sigwinch:
- event.Type = EventResize
- event.Width, event.Height = get_term_size(out.Fd())
- return event
- }
- }
-}
-
-// Wait for an event and return it. This is a blocking function call.
-func PollEvent() Event {
- // Constant governing macOS specific behavior. See https://github.com/nsf/termbox-go/issues/132
- // This is an arbitrary delay which hopefully will be enough time for any lagging
- // partial escape sequences to come through.
- const esc_wait_delay = 100 * time.Millisecond
-
- var event Event
- var esc_wait_timer *time.Timer
- var esc_timeout <-chan time.Time
-
- // try to extract event from input buffer, return on success
- event.Type = EventKey
- status := extract_event(inbuf, &event, true)
- if event.N != 0 {
- copy(inbuf, inbuf[event.N:])
- inbuf = inbuf[:len(inbuf)-event.N]
- }
- if status == event_extracted {
- return event
- } else if status == esc_wait {
- esc_wait_timer = time.NewTimer(esc_wait_delay)
- esc_timeout = esc_wait_timer.C
- }
-
- for {
- select {
- case ev := <-input_comm:
- if esc_wait_timer != nil {
- if !esc_wait_timer.Stop() {
- <-esc_wait_timer.C
- }
- esc_wait_timer = nil
- }
-
- if ev.err != nil {
- return Event{Type: EventError, Err: ev.err}
- }
-
- inbuf = append(inbuf, ev.data...)
- input_comm <- ev
- status := extract_event(inbuf, &event, true)
- if event.N != 0 {
- copy(inbuf, inbuf[event.N:])
- inbuf = inbuf[:len(inbuf)-event.N]
- }
- if status == event_extracted {
- return event
- } else if status == esc_wait {
- esc_wait_timer = time.NewTimer(esc_wait_delay)
- esc_timeout = esc_wait_timer.C
- }
- case <-esc_timeout:
- esc_wait_timer = nil
-
- status := extract_event(inbuf, &event, false)
- if event.N != 0 {
- copy(inbuf, inbuf[event.N:])
- inbuf = inbuf[:len(inbuf)-event.N]
- }
- if status == event_extracted {
- return event
- }
- case <-interrupt_comm:
- event.Type = EventInterrupt
- return event
-
- case <-sigwinch:
- event.Type = EventResize
- event.Width, event.Height = get_term_size(out.Fd())
- return event
- }
- }
-}
-
-// Returns the size of the internal back buffer (which is mostly the same as
-// terminal's window size in characters). But it doesn't always match the size
-// of the terminal window, after the terminal size has changed, the internal
-// back buffer will get in sync only after Clear or Flush function calls.
-func Size() (width int, height int) {
- return termw, termh
-}
-
-// Clears the internal back buffer.
-func Clear(fg, bg Attribute) error {
- foreground, background = fg, bg
- err := update_size_maybe()
- back_buffer.clear()
- return err
-}
-
-// Sets termbox input mode. Termbox has two input modes:
-//
-// 1. Esc input mode. When ESC sequence is in the buffer and it doesn't match
-// any known sequence. ESC means KeyEsc. This is the default input mode.
-//
-// 2. Alt input mode. When ESC sequence is in the buffer and it doesn't match
-// any known sequence. ESC enables ModAlt modifier for the next keyboard event.
-//
-// Both input modes can be OR'ed with Mouse mode. Setting Mouse mode bit up will
-// enable mouse button press/release and drag events.
-//
-// If 'mode' is InputCurrent, returns the current input mode. See also Input*
-// constants.
-func SetInputMode(mode InputMode) InputMode {
- if mode == InputCurrent {
- return input_mode
- }
- if mode&(InputEsc|InputAlt) == 0 {
- mode |= InputEsc
- }
- if mode&(InputEsc|InputAlt) == InputEsc|InputAlt {
- mode &^= InputAlt
- }
- if mode&InputMouse != 0 {
- out.WriteString(funcs[t_enter_mouse])
- } else {
- out.WriteString(funcs[t_exit_mouse])
- }
-
- input_mode = mode
- return input_mode
-}
-
-// Sets the termbox output mode. Termbox has four output options:
-//
-// 1. OutputNormal => [1..8]
-// This mode provides 8 different colors:
-// black, red, green, yellow, blue, magenta, cyan, white
-// Shortcut: ColorBlack, ColorRed, ...
-// Attributes: AttrBold, AttrUnderline, AttrReverse
-//
-// Example usage:
-// SetCell(x, y, '@', ColorBlack | AttrBold, ColorRed);
-//
-// 2. Output256 => [1..256]
-// In this mode you can leverage the 256 terminal mode:
-// 0x01 - 0x08: the 8 colors as in OutputNormal
-// 0x09 - 0x10: Color* | AttrBold
-// 0x11 - 0xe8: 216 different colors
-// 0xe9 - 0x1ff: 24 different shades of grey
-//
-// Example usage:
-// SetCell(x, y, '@', 184, 240);
-// SetCell(x, y, '@', 0xb8, 0xf0);
-//
-// 3. Output216 => [1..216]
-// This mode supports the 3rd range of the 256 mode only.
-// But you don't need to provide an offset.
-//
-// 4. OutputGrayscale => [1..26]
-// This mode supports the 4th range of the 256 mode
-// and black and white colors from 3th range of the 256 mode
-// But you don't need to provide an offset.
-//
-// In all modes, 0x00 represents the default color.
-//
-// `go run _demos/output.go` to see its impact on your terminal.
-//
-// If 'mode' is OutputCurrent, it returns the current output mode.
-//
-// Note that this may return a different OutputMode than the one requested,
-// as the requested mode may not be available on the target platform.
-func SetOutputMode(mode OutputMode) OutputMode {
- if mode == OutputCurrent {
- return output_mode
- }
-
- output_mode = mode
- return output_mode
-}
-
-// Sync comes handy when something causes desync between termbox's understanding
-// of a terminal buffer and the reality. Such as a third party process. Sync
-// forces a complete resync between the termbox and a terminal, it may not be
-// visually pretty though.
-func Sync() error {
- front_buffer.clear()
- err := send_clear()
- if err != nil {
- return err
- }
-
- return Flush()
-}
diff --git a/vendor/github.com/nsf/termbox-go/api_common.go b/vendor/github.com/nsf/termbox-go/api_common.go
deleted file mode 100644
index 5ca1371..0000000
--- a/vendor/github.com/nsf/termbox-go/api_common.go
+++ /dev/null
@@ -1,187 +0,0 @@
-// termbox is a library for creating cross-platform text-based interfaces
-package termbox
-
-// public API, common OS agnostic part
-
-type (
- InputMode int
- OutputMode int
- EventType uint8
- Modifier uint8
- Key uint16
- Attribute uint16
-)
-
-// This type represents a termbox event. The 'Mod', 'Key' and 'Ch' fields are
-// valid if 'Type' is EventKey. The 'Width' and 'Height' fields are valid if
-// 'Type' is EventResize. The 'Err' field is valid if 'Type' is EventError.
-type Event struct {
- Type EventType // one of Event* constants
- Mod Modifier // one of Mod* constants or 0
- Key Key // one of Key* constants, invalid if 'Ch' is not 0
- Ch rune // a unicode character
- Width int // width of the screen
- Height int // height of the screen
- Err error // error in case if input failed
- MouseX int // x coord of mouse
- MouseY int // y coord of mouse
- N int // number of bytes written when getting a raw event
-}
-
-// A cell, single conceptual entity on the screen. The screen is basically a 2d
-// array of cells. 'Ch' is a unicode character, 'Fg' and 'Bg' are foreground
-// and background attributes respectively.
-type Cell struct {
- Ch rune
- Fg Attribute
- Bg Attribute
-}
-
-// To know if termbox has been initialized or not
-var (
- IsInit bool = false
-)
-
-// Key constants, see Event.Key field.
-const (
- KeyF1 Key = 0xFFFF - iota
- KeyF2
- KeyF3
- KeyF4
- KeyF5
- KeyF6
- KeyF7
- KeyF8
- KeyF9
- KeyF10
- KeyF11
- KeyF12
- KeyInsert
- KeyDelete
- KeyHome
- KeyEnd
- KeyPgup
- KeyPgdn
- KeyArrowUp
- KeyArrowDown
- KeyArrowLeft
- KeyArrowRight
- key_min // see terminfo
- MouseLeft
- MouseMiddle
- MouseRight
- MouseRelease
- MouseWheelUp
- MouseWheelDown
-)
-
-const (
- KeyCtrlTilde Key = 0x00
- KeyCtrl2 Key = 0x00
- KeyCtrlSpace Key = 0x00
- KeyCtrlA Key = 0x01
- KeyCtrlB Key = 0x02
- KeyCtrlC Key = 0x03
- KeyCtrlD Key = 0x04
- KeyCtrlE Key = 0x05
- KeyCtrlF Key = 0x06
- KeyCtrlG Key = 0x07
- KeyBackspace Key = 0x08
- KeyCtrlH Key = 0x08
- KeyTab Key = 0x09
- KeyCtrlI Key = 0x09
- KeyCtrlJ Key = 0x0A
- KeyCtrlK Key = 0x0B
- KeyCtrlL Key = 0x0C
- KeyEnter Key = 0x0D
- KeyCtrlM Key = 0x0D
- KeyCtrlN Key = 0x0E
- KeyCtrlO Key = 0x0F
- KeyCtrlP Key = 0x10
- KeyCtrlQ Key = 0x11
- KeyCtrlR Key = 0x12
- KeyCtrlS Key = 0x13
- KeyCtrlT Key = 0x14
- KeyCtrlU Key = 0x15
- KeyCtrlV Key = 0x16
- KeyCtrlW Key = 0x17
- KeyCtrlX Key = 0x18
- KeyCtrlY Key = 0x19
- KeyCtrlZ Key = 0x1A
- KeyEsc Key = 0x1B
- KeyCtrlLsqBracket Key = 0x1B
- KeyCtrl3 Key = 0x1B
- KeyCtrl4 Key = 0x1C
- KeyCtrlBackslash Key = 0x1C
- KeyCtrl5 Key = 0x1D
- KeyCtrlRsqBracket Key = 0x1D
- KeyCtrl6 Key = 0x1E
- KeyCtrl7 Key = 0x1F
- KeyCtrlSlash Key = 0x1F
- KeyCtrlUnderscore Key = 0x1F
- KeySpace Key = 0x20
- KeyBackspace2 Key = 0x7F
- KeyCtrl8 Key = 0x7F
-)
-
-// Alt modifier constant, see Event.Mod field and SetInputMode function.
-const (
- ModAlt Modifier = 1 << iota
- ModMotion
-)
-
-// Cell colors, you can combine a color with multiple attributes using bitwise
-// OR ('|').
-const (
- ColorDefault Attribute = iota
- ColorBlack
- ColorRed
- ColorGreen
- ColorYellow
- ColorBlue
- ColorMagenta
- ColorCyan
- ColorWhite
-)
-
-// Cell attributes, it is possible to use multiple attributes by combining them
-// using bitwise OR ('|'). Although, colors cannot be combined. But you can
-// combine attributes and a single color.
-//
-// It's worth mentioning that some platforms don't support certain attributes.
-// For example windows console doesn't support AttrUnderline. And on some
-// terminals applying AttrBold to background may result in blinking text. Use
-// them with caution and test your code on various terminals.
-const (
- AttrBold Attribute = 1 << (iota + 9)
- AttrUnderline
- AttrReverse
-)
-
-// Input mode. See SetInputMode function.
-const (
- InputEsc InputMode = 1 << iota
- InputAlt
- InputMouse
- InputCurrent InputMode = 0
-)
-
-// Output mode. See SetOutputMode function.
-const (
- OutputCurrent OutputMode = iota
- OutputNormal
- Output256
- Output216
- OutputGrayscale
-)
-
-// Event type. See Event.Type field.
-const (
- EventKey EventType = iota
- EventResize
- EventMouse
- EventError
- EventInterrupt
- EventRaw
- EventNone
-)
diff --git a/vendor/github.com/nsf/termbox-go/api_windows.go b/vendor/github.com/nsf/termbox-go/api_windows.go
deleted file mode 100644
index 7def30a..0000000
--- a/vendor/github.com/nsf/termbox-go/api_windows.go
+++ /dev/null
@@ -1,239 +0,0 @@
-package termbox
-
-import (
- "syscall"
-)
-
-// public API
-
-// Initializes termbox library. This function should be called before any other functions.
-// After successful initialization, the library must be finalized using 'Close' function.
-//
-// Example usage:
-// err := termbox.Init()
-// if err != nil {
-// panic(err)
-// }
-// defer termbox.Close()
-func Init() error {
- var err error
-
- interrupt, err = create_event()
- if err != nil {
- return err
- }
-
- in, err = syscall.Open("CONIN$", syscall.O_RDWR, 0)
- if err != nil {
- return err
- }
- out, err = syscall.Open("CONOUT$", syscall.O_RDWR, 0)
- if err != nil {
- return err
- }
-
- err = get_console_mode(in, &orig_mode)
- if err != nil {
- return err
- }
-
- err = set_console_mode(in, enable_window_input)
- if err != nil {
- return err
- }
-
- orig_size = get_term_size(out)
- win_size := get_win_size(out)
-
- err = set_console_screen_buffer_size(out, win_size)
- if err != nil {
- return err
- }
-
- err = get_console_cursor_info(out, &orig_cursor_info)
- if err != nil {
- return err
- }
-
- show_cursor(false)
- term_size = get_term_size(out)
- back_buffer.init(int(term_size.x), int(term_size.y))
- front_buffer.init(int(term_size.x), int(term_size.y))
- back_buffer.clear()
- front_buffer.clear()
- clear()
-
- diffbuf = make([]diff_msg, 0, 32)
-
- go input_event_producer()
- IsInit = true
- return nil
-}
-
-// Finalizes termbox library, should be called after successful initialization
-// when termbox's functionality isn't required anymore.
-func Close() {
- // we ignore errors here, because we can't really do anything about them
- Clear(0, 0)
- Flush()
-
- // stop event producer
- cancel_comm <- true
- set_event(interrupt)
- select {
- case <-input_comm:
- default:
- }
- <-cancel_done_comm
-
- set_console_cursor_info(out, &orig_cursor_info)
- set_console_cursor_position(out, coord{})
- set_console_screen_buffer_size(out, orig_size)
- set_console_mode(in, orig_mode)
- syscall.Close(in)
- syscall.Close(out)
- syscall.Close(interrupt)
- IsInit = false
-}
-
-// Interrupt an in-progress call to PollEvent by causing it to return
-// EventInterrupt. Note that this function will block until the PollEvent
-// function has successfully been interrupted.
-func Interrupt() {
- interrupt_comm <- struct{}{}
-}
-
-// Synchronizes the internal back buffer with the terminal.
-func Flush() error {
- update_size_maybe()
- prepare_diff_messages()
- for _, diff := range diffbuf {
- r := small_rect{
- left: 0,
- top: diff.pos,
- right: term_size.x - 1,
- bottom: diff.pos + diff.lines - 1,
- }
- write_console_output(out, diff.chars, r)
- }
- if !is_cursor_hidden(cursor_x, cursor_y) {
- move_cursor(cursor_x, cursor_y)
- }
- return nil
-}
-
-// Sets the position of the cursor. See also HideCursor().
-func SetCursor(x, y int) {
- if is_cursor_hidden(cursor_x, cursor_y) && !is_cursor_hidden(x, y) {
- show_cursor(true)
- }
-
- if !is_cursor_hidden(cursor_x, cursor_y) && is_cursor_hidden(x, y) {
- show_cursor(false)
- }
-
- cursor_x, cursor_y = x, y
- if !is_cursor_hidden(cursor_x, cursor_y) {
- move_cursor(cursor_x, cursor_y)
- }
-}
-
-// The shortcut for SetCursor(-1, -1).
-func HideCursor() {
- SetCursor(cursor_hidden, cursor_hidden)
-}
-
-// Changes cell's parameters in the internal back buffer at the specified
-// position.
-func SetCell(x, y int, ch rune, fg, bg Attribute) {
- if x < 0 || x >= back_buffer.width {
- return
- }
- if y < 0 || y >= back_buffer.height {
- return
- }
-
- back_buffer.cells[y*back_buffer.width+x] = Cell{ch, fg, bg}
-}
-
-// Returns a slice into the termbox's back buffer. You can get its dimensions
-// using 'Size' function. The slice remains valid as long as no 'Clear' or
-// 'Flush' function calls were made after call to this function.
-func CellBuffer() []Cell {
- return back_buffer.cells
-}
-
-// Wait for an event and return it. This is a blocking function call.
-func PollEvent() Event {
- select {
- case ev := <-input_comm:
- return ev
- case <-interrupt_comm:
- return Event{Type: EventInterrupt}
- }
-}
-
-// Returns the size of the internal back buffer (which is mostly the same as
-// console's window size in characters). But it doesn't always match the size
-// of the console window, after the console size has changed, the internal back
-// buffer will get in sync only after Clear or Flush function calls.
-func Size() (int, int) {
- return int(term_size.x), int(term_size.y)
-}
-
-// Clears the internal back buffer.
-func Clear(fg, bg Attribute) error {
- foreground, background = fg, bg
- update_size_maybe()
- back_buffer.clear()
- return nil
-}
-
-// Sets termbox input mode. Termbox has two input modes:
-//
-// 1. Esc input mode. When ESC sequence is in the buffer and it doesn't match
-// any known sequence. ESC means KeyEsc. This is the default input mode.
-//
-// 2. Alt input mode. When ESC sequence is in the buffer and it doesn't match
-// any known sequence. ESC enables ModAlt modifier for the next keyboard event.
-//
-// Both input modes can be OR'ed with Mouse mode. Setting Mouse mode bit up will
-// enable mouse button press/release and drag events.
-//
-// If 'mode' is InputCurrent, returns the current input mode. See also Input*
-// constants.
-func SetInputMode(mode InputMode) InputMode {
- if mode == InputCurrent {
- return input_mode
- }
- if mode&InputMouse != 0 {
- err := set_console_mode(in, enable_window_input|enable_mouse_input|enable_extended_flags)
- if err != nil {
- panic(err)
- }
- } else {
- err := set_console_mode(in, enable_window_input)
- if err != nil {
- panic(err)
- }
- }
-
- input_mode = mode
- return input_mode
-}
-
-// Sets the termbox output mode.
-//
-// Windows console does not support extra colour modes,
-// so this will always set and return OutputNormal.
-func SetOutputMode(mode OutputMode) OutputMode {
- return OutputNormal
-}
-
-// Sync comes handy when something causes desync between termbox's understanding
-// of a terminal buffer and the reality. Such as a third party process. Sync
-// forces a complete resync between the termbox and a terminal, it may not be
-// visually pretty though. At the moment on Windows it does nothing.
-func Sync() error {
- return nil
-}
diff --git a/vendor/github.com/nsf/termbox-go/collect_terminfo.py b/vendor/github.com/nsf/termbox-go/collect_terminfo.py
deleted file mode 100644
index 5e50975..0000000
--- a/vendor/github.com/nsf/termbox-go/collect_terminfo.py
+++ /dev/null
@@ -1,110 +0,0 @@
-#!/usr/bin/env python
-
-import sys, os, subprocess
-
-def escaped(s):
- return repr(s)[1:-1]
-
-def tput(term, name):
- try:
- return subprocess.check_output(['tput', '-T%s' % term, name]).decode()
- except subprocess.CalledProcessError as e:
- return e.output.decode()
-
-
-def w(s):
- if s == None:
- return
- sys.stdout.write(s)
-
-terminals = {
- 'xterm' : 'xterm',
- 'rxvt-256color' : 'rxvt_256color',
- 'rxvt-unicode' : 'rxvt_unicode',
- 'linux' : 'linux',
- 'Eterm' : 'eterm',
- 'screen' : 'screen'
-}
-
-keys = [
- "F1", "kf1",
- "F2", "kf2",
- "F3", "kf3",
- "F4", "kf4",
- "F5", "kf5",
- "F6", "kf6",
- "F7", "kf7",
- "F8", "kf8",
- "F9", "kf9",
- "F10", "kf10",
- "F11", "kf11",
- "F12", "kf12",
- "INSERT", "kich1",
- "DELETE", "kdch1",
- "HOME", "khome",
- "END", "kend",
- "PGUP", "kpp",
- "PGDN", "knp",
- "KEY_UP", "kcuu1",
- "KEY_DOWN", "kcud1",
- "KEY_LEFT", "kcub1",
- "KEY_RIGHT", "kcuf1"
-]
-
-funcs = [
- "T_ENTER_CA", "smcup",
- "T_EXIT_CA", "rmcup",
- "T_SHOW_CURSOR", "cnorm",
- "T_HIDE_CURSOR", "civis",
- "T_CLEAR_SCREEN", "clear",
- "T_SGR0", "sgr0",
- "T_UNDERLINE", "smul",
- "T_BOLD", "bold",
- "T_BLINK", "blink",
- "T_REVERSE", "rev",
- "T_ENTER_KEYPAD", "smkx",
- "T_EXIT_KEYPAD", "rmkx"
-]
-
-def iter_pairs(iterable):
- iterable = iter(iterable)
- while True:
- yield (next(iterable), next(iterable))
-
-def do_term(term, nick):
- w("// %s\n" % term)
- w("var %s_keys = []string{\n\t" % nick)
- for k, v in iter_pairs(keys):
- w('"')
- w(escaped(tput(term, v)))
- w('",')
- w("\n}\n")
- w("var %s_funcs = []string{\n\t" % nick)
- for k,v in iter_pairs(funcs):
- w('"')
- if v == "sgr":
- w("\\033[3%d;4%dm")
- elif v == "cup":
- w("\\033[%d;%dH")
- else:
- w(escaped(tput(term, v)))
- w('", ')
- w("\n}\n\n")
-
-def do_terms(d):
- w("var terms = []struct {\n")
- w("\tname string\n")
- w("\tkeys []string\n")
- w("\tfuncs []string\n")
- w("}{\n")
- for k, v in d.items():
- w('\t{"%s", %s_keys, %s_funcs},\n' % (k, v, v))
- w("}\n\n")
-
-w("// +build !windows\n\npackage termbox\n\n")
-
-for k,v in terminals.items():
- do_term(k, v)
-
-do_terms(terminals)
-
diff --git a/vendor/github.com/nsf/termbox-go/escwait.go b/vendor/github.com/nsf/termbox-go/escwait.go
deleted file mode 100644
index b7bbb89..0000000
--- a/vendor/github.com/nsf/termbox-go/escwait.go
+++ /dev/null
@@ -1,11 +0,0 @@
-// +build !darwin
-
-package termbox
-
-// On all systems other than macOS, disable behavior which will wait before
-// deciding that the escape key was pressed, to account for partially send
-// escape sequences, especially with regard to lengthy mouse sequences.
-// See https://github.com/nsf/termbox-go/issues/132
-func enable_wait_for_escape_sequence() bool {
- return false
-}
diff --git a/vendor/github.com/nsf/termbox-go/escwait_darwin.go b/vendor/github.com/nsf/termbox-go/escwait_darwin.go
deleted file mode 100644
index dde69b6..0000000
--- a/vendor/github.com/nsf/termbox-go/escwait_darwin.go
+++ /dev/null
@@ -1,9 +0,0 @@
-package termbox
-
-// On macOS, enable behavior which will wait before deciding that the escape
-// key was pressed, to account for partially send escape sequences, especially
-// with regard to lengthy mouse sequences.
-// See https://github.com/nsf/termbox-go/issues/132
-func enable_wait_for_escape_sequence() bool {
- return true
-}
diff --git a/vendor/github.com/nsf/termbox-go/syscalls.go b/vendor/github.com/nsf/termbox-go/syscalls.go
deleted file mode 100644
index 4f52bb9..0000000
--- a/vendor/github.com/nsf/termbox-go/syscalls.go
+++ /dev/null
@@ -1,39 +0,0 @@
-// +build ignore
-
-package termbox
-
-/*
-#include
-#include
-*/
-import "C"
-
-type syscall_Termios C.struct_termios
-
-const (
- syscall_IGNBRK = C.IGNBRK
- syscall_BRKINT = C.BRKINT
- syscall_PARMRK = C.PARMRK
- syscall_ISTRIP = C.ISTRIP
- syscall_INLCR = C.INLCR
- syscall_IGNCR = C.IGNCR
- syscall_ICRNL = C.ICRNL
- syscall_IXON = C.IXON
- syscall_OPOST = C.OPOST
- syscall_ECHO = C.ECHO
- syscall_ECHONL = C.ECHONL
- syscall_ICANON = C.ICANON
- syscall_ISIG = C.ISIG
- syscall_IEXTEN = C.IEXTEN
- syscall_CSIZE = C.CSIZE
- syscall_PARENB = C.PARENB
- syscall_CS8 = C.CS8
- syscall_VMIN = C.VMIN
- syscall_VTIME = C.VTIME
-
- // on darwin change these to (on *bsd too?):
- // C.TIOCGETA
- // C.TIOCSETA
- syscall_TCGETS = C.TCGETS
- syscall_TCSETS = C.TCSETS
-)
diff --git a/vendor/github.com/nsf/termbox-go/syscalls_darwin.go b/vendor/github.com/nsf/termbox-go/syscalls_darwin.go
deleted file mode 100644
index 25b78f7..0000000
--- a/vendor/github.com/nsf/termbox-go/syscalls_darwin.go
+++ /dev/null
@@ -1,41 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs syscalls.go
-
-// +build !amd64
-
-package termbox
-
-type syscall_Termios struct {
- Iflag uint32
- Oflag uint32
- Cflag uint32
- Lflag uint32
- Cc [20]uint8
- Ispeed uint32
- Ospeed uint32
-}
-
-const (
- syscall_IGNBRK = 0x1
- syscall_BRKINT = 0x2
- syscall_PARMRK = 0x8
- syscall_ISTRIP = 0x20
- syscall_INLCR = 0x40
- syscall_IGNCR = 0x80
- syscall_ICRNL = 0x100
- syscall_IXON = 0x200
- syscall_OPOST = 0x1
- syscall_ECHO = 0x8
- syscall_ECHONL = 0x10
- syscall_ICANON = 0x100
- syscall_ISIG = 0x80
- syscall_IEXTEN = 0x400
- syscall_CSIZE = 0x300
- syscall_PARENB = 0x1000
- syscall_CS8 = 0x300
- syscall_VMIN = 0x10
- syscall_VTIME = 0x11
-
- syscall_TCGETS = 0x402c7413
- syscall_TCSETS = 0x802c7414
-)
diff --git a/vendor/github.com/nsf/termbox-go/syscalls_darwin_amd64.go b/vendor/github.com/nsf/termbox-go/syscalls_darwin_amd64.go
deleted file mode 100644
index 11f25be..0000000
--- a/vendor/github.com/nsf/termbox-go/syscalls_darwin_amd64.go
+++ /dev/null
@@ -1,40 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs syscalls.go
-
-package termbox
-
-type syscall_Termios struct {
- Iflag uint64
- Oflag uint64
- Cflag uint64
- Lflag uint64
- Cc [20]uint8
- Pad_cgo_0 [4]byte
- Ispeed uint64
- Ospeed uint64
-}
-
-const (
- syscall_IGNBRK = 0x1
- syscall_BRKINT = 0x2
- syscall_PARMRK = 0x8
- syscall_ISTRIP = 0x20
- syscall_INLCR = 0x40
- syscall_IGNCR = 0x80
- syscall_ICRNL = 0x100
- syscall_IXON = 0x200
- syscall_OPOST = 0x1
- syscall_ECHO = 0x8
- syscall_ECHONL = 0x10
- syscall_ICANON = 0x100
- syscall_ISIG = 0x80
- syscall_IEXTEN = 0x400
- syscall_CSIZE = 0x300
- syscall_PARENB = 0x1000
- syscall_CS8 = 0x300
- syscall_VMIN = 0x10
- syscall_VTIME = 0x11
-
- syscall_TCGETS = 0x40487413
- syscall_TCSETS = 0x80487414
-)
diff --git a/vendor/github.com/nsf/termbox-go/syscalls_dragonfly.go b/vendor/github.com/nsf/termbox-go/syscalls_dragonfly.go
deleted file mode 100644
index e03624e..0000000
--- a/vendor/github.com/nsf/termbox-go/syscalls_dragonfly.go
+++ /dev/null
@@ -1,39 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs syscalls.go
-
-package termbox
-
-type syscall_Termios struct {
- Iflag uint32
- Oflag uint32
- Cflag uint32
- Lflag uint32
- Cc [20]uint8
- Ispeed uint32
- Ospeed uint32
-}
-
-const (
- syscall_IGNBRK = 0x1
- syscall_BRKINT = 0x2
- syscall_PARMRK = 0x8
- syscall_ISTRIP = 0x20
- syscall_INLCR = 0x40
- syscall_IGNCR = 0x80
- syscall_ICRNL = 0x100
- syscall_IXON = 0x200
- syscall_OPOST = 0x1
- syscall_ECHO = 0x8
- syscall_ECHONL = 0x10
- syscall_ICANON = 0x100
- syscall_ISIG = 0x80
- syscall_IEXTEN = 0x400
- syscall_CSIZE = 0x300
- syscall_PARENB = 0x1000
- syscall_CS8 = 0x300
- syscall_VMIN = 0x10
- syscall_VTIME = 0x11
-
- syscall_TCGETS = 0x402c7413
- syscall_TCSETS = 0x802c7414
-)
diff --git a/vendor/github.com/nsf/termbox-go/syscalls_freebsd.go b/vendor/github.com/nsf/termbox-go/syscalls_freebsd.go
deleted file mode 100644
index e03624e..0000000
--- a/vendor/github.com/nsf/termbox-go/syscalls_freebsd.go
+++ /dev/null
@@ -1,39 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs syscalls.go
-
-package termbox
-
-type syscall_Termios struct {
- Iflag uint32
- Oflag uint32
- Cflag uint32
- Lflag uint32
- Cc [20]uint8
- Ispeed uint32
- Ospeed uint32
-}
-
-const (
- syscall_IGNBRK = 0x1
- syscall_BRKINT = 0x2
- syscall_PARMRK = 0x8
- syscall_ISTRIP = 0x20
- syscall_INLCR = 0x40
- syscall_IGNCR = 0x80
- syscall_ICRNL = 0x100
- syscall_IXON = 0x200
- syscall_OPOST = 0x1
- syscall_ECHO = 0x8
- syscall_ECHONL = 0x10
- syscall_ICANON = 0x100
- syscall_ISIG = 0x80
- syscall_IEXTEN = 0x400
- syscall_CSIZE = 0x300
- syscall_PARENB = 0x1000
- syscall_CS8 = 0x300
- syscall_VMIN = 0x10
- syscall_VTIME = 0x11
-
- syscall_TCGETS = 0x402c7413
- syscall_TCSETS = 0x802c7414
-)
diff --git a/vendor/github.com/nsf/termbox-go/syscalls_linux.go b/vendor/github.com/nsf/termbox-go/syscalls_linux.go
deleted file mode 100644
index b88960d..0000000
--- a/vendor/github.com/nsf/termbox-go/syscalls_linux.go
+++ /dev/null
@@ -1,33 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs syscalls.go
-
-package termbox
-
-import "syscall"
-
-type syscall_Termios syscall.Termios
-
-const (
- syscall_IGNBRK = syscall.IGNBRK
- syscall_BRKINT = syscall.BRKINT
- syscall_PARMRK = syscall.PARMRK
- syscall_ISTRIP = syscall.ISTRIP
- syscall_INLCR = syscall.INLCR
- syscall_IGNCR = syscall.IGNCR
- syscall_ICRNL = syscall.ICRNL
- syscall_IXON = syscall.IXON
- syscall_OPOST = syscall.OPOST
- syscall_ECHO = syscall.ECHO
- syscall_ECHONL = syscall.ECHONL
- syscall_ICANON = syscall.ICANON
- syscall_ISIG = syscall.ISIG
- syscall_IEXTEN = syscall.IEXTEN
- syscall_CSIZE = syscall.CSIZE
- syscall_PARENB = syscall.PARENB
- syscall_CS8 = syscall.CS8
- syscall_VMIN = syscall.VMIN
- syscall_VTIME = syscall.VTIME
-
- syscall_TCGETS = syscall.TCGETS
- syscall_TCSETS = syscall.TCSETS
-)
diff --git a/vendor/github.com/nsf/termbox-go/syscalls_netbsd.go b/vendor/github.com/nsf/termbox-go/syscalls_netbsd.go
deleted file mode 100644
index 49a3355..0000000
--- a/vendor/github.com/nsf/termbox-go/syscalls_netbsd.go
+++ /dev/null
@@ -1,39 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs syscalls.go
-
-package termbox
-
-type syscall_Termios struct {
- Iflag uint32
- Oflag uint32
- Cflag uint32
- Lflag uint32
- Cc [20]uint8
- Ispeed int32
- Ospeed int32
-}
-
-const (
- syscall_IGNBRK = 0x1
- syscall_BRKINT = 0x2
- syscall_PARMRK = 0x8
- syscall_ISTRIP = 0x20
- syscall_INLCR = 0x40
- syscall_IGNCR = 0x80
- syscall_ICRNL = 0x100
- syscall_IXON = 0x200
- syscall_OPOST = 0x1
- syscall_ECHO = 0x8
- syscall_ECHONL = 0x10
- syscall_ICANON = 0x100
- syscall_ISIG = 0x80
- syscall_IEXTEN = 0x400
- syscall_CSIZE = 0x300
- syscall_PARENB = 0x1000
- syscall_CS8 = 0x300
- syscall_VMIN = 0x10
- syscall_VTIME = 0x11
-
- syscall_TCGETS = 0x402c7413
- syscall_TCSETS = 0x802c7414
-)
diff --git a/vendor/github.com/nsf/termbox-go/syscalls_openbsd.go b/vendor/github.com/nsf/termbox-go/syscalls_openbsd.go
deleted file mode 100644
index 49a3355..0000000
--- a/vendor/github.com/nsf/termbox-go/syscalls_openbsd.go
+++ /dev/null
@@ -1,39 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs syscalls.go
-
-package termbox
-
-type syscall_Termios struct {
- Iflag uint32
- Oflag uint32
- Cflag uint32
- Lflag uint32
- Cc [20]uint8
- Ispeed int32
- Ospeed int32
-}
-
-const (
- syscall_IGNBRK = 0x1
- syscall_BRKINT = 0x2
- syscall_PARMRK = 0x8
- syscall_ISTRIP = 0x20
- syscall_INLCR = 0x40
- syscall_IGNCR = 0x80
- syscall_ICRNL = 0x100
- syscall_IXON = 0x200
- syscall_OPOST = 0x1
- syscall_ECHO = 0x8
- syscall_ECHONL = 0x10
- syscall_ICANON = 0x100
- syscall_ISIG = 0x80
- syscall_IEXTEN = 0x400
- syscall_CSIZE = 0x300
- syscall_PARENB = 0x1000
- syscall_CS8 = 0x300
- syscall_VMIN = 0x10
- syscall_VTIME = 0x11
-
- syscall_TCGETS = 0x402c7413
- syscall_TCSETS = 0x802c7414
-)
diff --git a/vendor/github.com/nsf/termbox-go/syscalls_windows.go b/vendor/github.com/nsf/termbox-go/syscalls_windows.go
deleted file mode 100644
index 472d002..0000000
--- a/vendor/github.com/nsf/termbox-go/syscalls_windows.go
+++ /dev/null
@@ -1,61 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs -- -DUNICODE syscalls.go
-
-package termbox
-
-const (
- foreground_blue = 0x1
- foreground_green = 0x2
- foreground_red = 0x4
- foreground_intensity = 0x8
- background_blue = 0x10
- background_green = 0x20
- background_red = 0x40
- background_intensity = 0x80
- std_input_handle = -0xa
- std_output_handle = -0xb
- key_event = 0x1
- mouse_event = 0x2
- window_buffer_size_event = 0x4
- enable_window_input = 0x8
- enable_mouse_input = 0x10
- enable_extended_flags = 0x80
-
- vk_f1 = 0x70
- vk_f2 = 0x71
- vk_f3 = 0x72
- vk_f4 = 0x73
- vk_f5 = 0x74
- vk_f6 = 0x75
- vk_f7 = 0x76
- vk_f8 = 0x77
- vk_f9 = 0x78
- vk_f10 = 0x79
- vk_f11 = 0x7a
- vk_f12 = 0x7b
- vk_insert = 0x2d
- vk_delete = 0x2e
- vk_home = 0x24
- vk_end = 0x23
- vk_pgup = 0x21
- vk_pgdn = 0x22
- vk_arrow_up = 0x26
- vk_arrow_down = 0x28
- vk_arrow_left = 0x25
- vk_arrow_right = 0x27
- vk_backspace = 0x8
- vk_tab = 0x9
- vk_enter = 0xd
- vk_esc = 0x1b
- vk_space = 0x20
-
- left_alt_pressed = 0x2
- left_ctrl_pressed = 0x8
- right_alt_pressed = 0x1
- right_ctrl_pressed = 0x4
- shift_pressed = 0x10
-
- generic_read = 0x80000000
- generic_write = 0x40000000
- console_textmode_buffer = 0x1
-)
diff --git a/vendor/github.com/nsf/termbox-go/termbox.go b/vendor/github.com/nsf/termbox-go/termbox.go
deleted file mode 100644
index fbe4c3d..0000000
--- a/vendor/github.com/nsf/termbox-go/termbox.go
+++ /dev/null
@@ -1,529 +0,0 @@
-// +build !windows
-
-package termbox
-
-import "unicode/utf8"
-import "bytes"
-import "syscall"
-import "unsafe"
-import "strings"
-import "strconv"
-import "os"
-import "io"
-
-// private API
-
-const (
- t_enter_ca = iota
- t_exit_ca
- t_show_cursor
- t_hide_cursor
- t_clear_screen
- t_sgr0
- t_underline
- t_bold
- t_blink
- t_reverse
- t_enter_keypad
- t_exit_keypad
- t_enter_mouse
- t_exit_mouse
- t_max_funcs
-)
-
-const (
- coord_invalid = -2
- attr_invalid = Attribute(0xFFFF)
-)
-
-type input_event struct {
- data []byte
- err error
-}
-
-type extract_event_res int
-
-const (
- event_not_extracted extract_event_res = iota
- event_extracted
- esc_wait
-)
-
-var (
- // term specific sequences
- keys []string
- funcs []string
-
- // termbox inner state
- orig_tios syscall_Termios
- back_buffer cellbuf
- front_buffer cellbuf
- termw int
- termh int
- input_mode = InputEsc
- output_mode = OutputNormal
- out *os.File
- in int
- lastfg = attr_invalid
- lastbg = attr_invalid
- lastx = coord_invalid
- lasty = coord_invalid
- cursor_x = cursor_hidden
- cursor_y = cursor_hidden
- foreground = ColorDefault
- background = ColorDefault
- inbuf = make([]byte, 0, 64)
- outbuf bytes.Buffer
- sigwinch = make(chan os.Signal, 1)
- sigio = make(chan os.Signal, 1)
- quit = make(chan int)
- input_comm = make(chan input_event)
- interrupt_comm = make(chan struct{})
- intbuf = make([]byte, 0, 16)
-
- // grayscale indexes
- grayscale = []Attribute{
- 0, 17, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244,
- 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 232,
- }
-)
-
-func write_cursor(x, y int) {
- outbuf.WriteString("\033[")
- outbuf.Write(strconv.AppendUint(intbuf, uint64(y+1), 10))
- outbuf.WriteString(";")
- outbuf.Write(strconv.AppendUint(intbuf, uint64(x+1), 10))
- outbuf.WriteString("H")
-}
-
-func write_sgr_fg(a Attribute) {
- switch output_mode {
- case Output256, Output216, OutputGrayscale:
- outbuf.WriteString("\033[38;5;")
- outbuf.Write(strconv.AppendUint(intbuf, uint64(a-1), 10))
- outbuf.WriteString("m")
- default:
- outbuf.WriteString("\033[3")
- outbuf.Write(strconv.AppendUint(intbuf, uint64(a-1), 10))
- outbuf.WriteString("m")
- }
-}
-
-func write_sgr_bg(a Attribute) {
- switch output_mode {
- case Output256, Output216, OutputGrayscale:
- outbuf.WriteString("\033[48;5;")
- outbuf.Write(strconv.AppendUint(intbuf, uint64(a-1), 10))
- outbuf.WriteString("m")
- default:
- outbuf.WriteString("\033[4")
- outbuf.Write(strconv.AppendUint(intbuf, uint64(a-1), 10))
- outbuf.WriteString("m")
- }
-}
-
-func write_sgr(fg, bg Attribute) {
- switch output_mode {
- case Output256, Output216, OutputGrayscale:
- outbuf.WriteString("\033[38;5;")
- outbuf.Write(strconv.AppendUint(intbuf, uint64(fg-1), 10))
- outbuf.WriteString("m")
- outbuf.WriteString("\033[48;5;")
- outbuf.Write(strconv.AppendUint(intbuf, uint64(bg-1), 10))
- outbuf.WriteString("m")
- default:
- outbuf.WriteString("\033[3")
- outbuf.Write(strconv.AppendUint(intbuf, uint64(fg-1), 10))
- outbuf.WriteString(";4")
- outbuf.Write(strconv.AppendUint(intbuf, uint64(bg-1), 10))
- outbuf.WriteString("m")
- }
-}
-
-type winsize struct {
- rows uint16
- cols uint16
- xpixels uint16
- ypixels uint16
-}
-
-func get_term_size(fd uintptr) (int, int) {
- var sz winsize
- _, _, _ = syscall.Syscall(syscall.SYS_IOCTL,
- fd, uintptr(syscall.TIOCGWINSZ), uintptr(unsafe.Pointer(&sz)))
- return int(sz.cols), int(sz.rows)
-}
-
-func send_attr(fg, bg Attribute) {
- if fg == lastfg && bg == lastbg {
- return
- }
-
- outbuf.WriteString(funcs[t_sgr0])
-
- var fgcol, bgcol Attribute
-
- switch output_mode {
- case Output256:
- fgcol = fg & 0x1FF
- bgcol = bg & 0x1FF
- case Output216:
- fgcol = fg & 0xFF
- bgcol = bg & 0xFF
- if fgcol > 216 {
- fgcol = ColorDefault
- }
- if bgcol > 216 {
- bgcol = ColorDefault
- }
- if fgcol != ColorDefault {
- fgcol += 0x10
- }
- if bgcol != ColorDefault {
- bgcol += 0x10
- }
- case OutputGrayscale:
- fgcol = fg & 0x1F
- bgcol = bg & 0x1F
- if fgcol > 26 {
- fgcol = ColorDefault
- }
- if bgcol > 26 {
- bgcol = ColorDefault
- }
- if fgcol != ColorDefault {
- fgcol = grayscale[fgcol]
- }
- if bgcol != ColorDefault {
- bgcol = grayscale[bgcol]
- }
- default:
- fgcol = fg & 0x0F
- bgcol = bg & 0x0F
- }
-
- if fgcol != ColorDefault {
- if bgcol != ColorDefault {
- write_sgr(fgcol, bgcol)
- } else {
- write_sgr_fg(fgcol)
- }
- } else if bgcol != ColorDefault {
- write_sgr_bg(bgcol)
- }
-
- if fg&AttrBold != 0 {
- outbuf.WriteString(funcs[t_bold])
- }
- if bg&AttrBold != 0 {
- outbuf.WriteString(funcs[t_blink])
- }
- if fg&AttrUnderline != 0 {
- outbuf.WriteString(funcs[t_underline])
- }
- if fg&AttrReverse|bg&AttrReverse != 0 {
- outbuf.WriteString(funcs[t_reverse])
- }
-
- lastfg, lastbg = fg, bg
-}
-
-func send_char(x, y int, ch rune) {
- var buf [8]byte
- n := utf8.EncodeRune(buf[:], ch)
- if x-1 != lastx || y != lasty {
- write_cursor(x, y)
- }
- lastx, lasty = x, y
- outbuf.Write(buf[:n])
-}
-
-func flush() error {
- _, err := io.Copy(out, &outbuf)
- outbuf.Reset()
- return err
-}
-
-func send_clear() error {
- send_attr(foreground, background)
- outbuf.WriteString(funcs[t_clear_screen])
- if !is_cursor_hidden(cursor_x, cursor_y) {
- write_cursor(cursor_x, cursor_y)
- }
-
- // we need to invalidate cursor position too and these two vars are
- // used only for simple cursor positioning optimization, cursor
- // actually may be in the correct place, but we simply discard
- // optimization once and it gives us simple solution for the case when
- // cursor moved
- lastx = coord_invalid
- lasty = coord_invalid
-
- return flush()
-}
-
-func update_size_maybe() error {
- w, h := get_term_size(out.Fd())
- if w != termw || h != termh {
- termw, termh = w, h
- back_buffer.resize(termw, termh)
- front_buffer.resize(termw, termh)
- front_buffer.clear()
- return send_clear()
- }
- return nil
-}
-
-func tcsetattr(fd uintptr, termios *syscall_Termios) error {
- r, _, e := syscall.Syscall(syscall.SYS_IOCTL,
- fd, uintptr(syscall_TCSETS), uintptr(unsafe.Pointer(termios)))
- if r != 0 {
- return os.NewSyscallError("SYS_IOCTL", e)
- }
- return nil
-}
-
-func tcgetattr(fd uintptr, termios *syscall_Termios) error {
- r, _, e := syscall.Syscall(syscall.SYS_IOCTL,
- fd, uintptr(syscall_TCGETS), uintptr(unsafe.Pointer(termios)))
- if r != 0 {
- return os.NewSyscallError("SYS_IOCTL", e)
- }
- return nil
-}
-
-func parse_mouse_event(event *Event, buf string) (int, bool) {
- if strings.HasPrefix(buf, "\033[M") && len(buf) >= 6 {
- // X10 mouse encoding, the simplest one
- // \033 [ M Cb Cx Cy
- b := buf[3] - 32
- switch b & 3 {
- case 0:
- if b&64 != 0 {
- event.Key = MouseWheelUp
- } else {
- event.Key = MouseLeft
- }
- case 1:
- if b&64 != 0 {
- event.Key = MouseWheelDown
- } else {
- event.Key = MouseMiddle
- }
- case 2:
- event.Key = MouseRight
- case 3:
- event.Key = MouseRelease
- default:
- return 6, false
- }
- event.Type = EventMouse // KeyEvent by default
- if b&32 != 0 {
- event.Mod |= ModMotion
- }
-
- // the coord is 1,1 for upper left
- event.MouseX = int(buf[4]) - 1 - 32
- event.MouseY = int(buf[5]) - 1 - 32
- return 6, true
- } else if strings.HasPrefix(buf, "\033[<") || strings.HasPrefix(buf, "\033[") {
- // xterm 1006 extended mode or urxvt 1015 extended mode
- // xterm: \033 [ < Cb ; Cx ; Cy (M or m)
- // urxvt: \033 [ Cb ; Cx ; Cy M
-
- // find the first M or m, that's where we stop
- mi := strings.IndexAny(buf, "Mm")
- if mi == -1 {
- return 0, false
- }
-
- // whether it's a capital M or not
- isM := buf[mi] == 'M'
-
- // whether it's urxvt or not
- isU := false
-
- // buf[2] is safe here, because having M or m found means we have at
- // least 3 bytes in a string
- if buf[2] == '<' {
- buf = buf[3:mi]
- } else {
- isU = true
- buf = buf[2:mi]
- }
-
- s1 := strings.Index(buf, ";")
- s2 := strings.LastIndex(buf, ";")
- // not found or only one ';'
- if s1 == -1 || s2 == -1 || s1 == s2 {
- return 0, false
- }
-
- n1, err := strconv.ParseInt(buf[0:s1], 10, 64)
- if err != nil {
- return 0, false
- }
- n2, err := strconv.ParseInt(buf[s1+1:s2], 10, 64)
- if err != nil {
- return 0, false
- }
- n3, err := strconv.ParseInt(buf[s2+1:], 10, 64)
- if err != nil {
- return 0, false
- }
-
- // on urxvt, first number is encoded exactly as in X10, but we need to
- // make it zero-based, on xterm it is zero-based already
- if isU {
- n1 -= 32
- }
- switch n1 & 3 {
- case 0:
- if n1&64 != 0 {
- event.Key = MouseWheelUp
- } else {
- event.Key = MouseLeft
- }
- case 1:
- if n1&64 != 0 {
- event.Key = MouseWheelDown
- } else {
- event.Key = MouseMiddle
- }
- case 2:
- event.Key = MouseRight
- case 3:
- event.Key = MouseRelease
- default:
- return mi + 1, false
- }
- if !isM {
- // on xterm mouse release is signaled by lowercase m
- event.Key = MouseRelease
- }
-
- event.Type = EventMouse // KeyEvent by default
- if n1&32 != 0 {
- event.Mod |= ModMotion
- }
-
- event.MouseX = int(n2) - 1
- event.MouseY = int(n3) - 1
- return mi + 1, true
- }
-
- return 0, false
-}
-
-func parse_escape_sequence(event *Event, buf []byte) (int, bool) {
- bufstr := string(buf)
- for i, key := range keys {
- if strings.HasPrefix(bufstr, key) {
- event.Ch = 0
- event.Key = Key(0xFFFF - i)
- return len(key), true
- }
- }
-
- // if none of the keys match, let's try mouse sequences
- return parse_mouse_event(event, bufstr)
-}
-
-func extract_raw_event(data []byte, event *Event) bool {
- if len(inbuf) == 0 {
- return false
- }
-
- n := len(data)
- if n == 0 {
- return false
- }
-
- n = copy(data, inbuf)
- copy(inbuf, inbuf[n:])
- inbuf = inbuf[:len(inbuf)-n]
-
- event.N = n
- event.Type = EventRaw
- return true
-}
-
-func extract_event(inbuf []byte, event *Event, allow_esc_wait bool) extract_event_res {
- if len(inbuf) == 0 {
- event.N = 0
- return event_not_extracted
- }
-
- if inbuf[0] == '\033' {
- // possible escape sequence
- if n, ok := parse_escape_sequence(event, inbuf); n != 0 {
- event.N = n
- if ok {
- return event_extracted
- } else {
- return event_not_extracted
- }
- }
-
- // possible partially read escape sequence; trigger a wait if appropriate
- if enable_wait_for_escape_sequence() && allow_esc_wait {
- event.N = 0
- return esc_wait
- }
-
- // it's not escape sequence, then it's Alt or Esc, check input_mode
- switch {
- case input_mode&InputEsc != 0:
- // if we're in escape mode, fill Esc event, pop buffer, return success
- event.Ch = 0
- event.Key = KeyEsc
- event.Mod = 0
- event.N = 1
- return event_extracted
- case input_mode&InputAlt != 0:
- // if we're in alt mode, set Alt modifier to event and redo parsing
- event.Mod = ModAlt
- status := extract_event(inbuf[1:], event, false)
- if status == event_extracted {
- event.N++
- } else {
- event.N = 0
- }
- return status
- default:
- panic("unreachable")
- }
- }
-
- // if we're here, this is not an escape sequence and not an alt sequence
- // so, it's a FUNCTIONAL KEY or a UNICODE character
-
- // first of all check if it's a functional key
- if Key(inbuf[0]) <= KeySpace || Key(inbuf[0]) == KeyBackspace2 {
- // fill event, pop buffer, return success
- event.Ch = 0
- event.Key = Key(inbuf[0])
- event.N = 1
- return event_extracted
- }
-
- // the only possible option is utf8 rune
- if r, n := utf8.DecodeRune(inbuf); r != utf8.RuneError {
- event.Ch = r
- event.Key = 0
- event.N = n
- return event_extracted
- }
-
- return event_not_extracted
-}
-
-func fcntl(fd int, cmd int, arg int) (val int, err error) {
- r, _, e := syscall.Syscall(syscall.SYS_FCNTL, uintptr(fd), uintptr(cmd),
- uintptr(arg))
- val = int(r)
- if e != 0 {
- err = e
- }
- return
-}
diff --git a/vendor/github.com/nsf/termbox-go/termbox_common.go b/vendor/github.com/nsf/termbox-go/termbox_common.go
deleted file mode 100644
index c3355cc..0000000
--- a/vendor/github.com/nsf/termbox-go/termbox_common.go
+++ /dev/null
@@ -1,59 +0,0 @@
-package termbox
-
-// private API, common OS agnostic part
-
-type cellbuf struct {
- width int
- height int
- cells []Cell
-}
-
-func (this *cellbuf) init(width, height int) {
- this.width = width
- this.height = height
- this.cells = make([]Cell, width*height)
-}
-
-func (this *cellbuf) resize(width, height int) {
- if this.width == width && this.height == height {
- return
- }
-
- oldw := this.width
- oldh := this.height
- oldcells := this.cells
-
- this.init(width, height)
- this.clear()
-
- minw, minh := oldw, oldh
-
- if width < minw {
- minw = width
- }
- if height < minh {
- minh = height
- }
-
- for i := 0; i < minh; i++ {
- srco, dsto := i*oldw, i*width
- src := oldcells[srco : srco+minw]
- dst := this.cells[dsto : dsto+minw]
- copy(dst, src)
- }
-}
-
-func (this *cellbuf) clear() {
- for i := range this.cells {
- c := &this.cells[i]
- c.Ch = ' '
- c.Fg = foreground
- c.Bg = background
- }
-}
-
-const cursor_hidden = -1
-
-func is_cursor_hidden(x, y int) bool {
- return x == cursor_hidden || y == cursor_hidden
-}
diff --git a/vendor/github.com/nsf/termbox-go/termbox_windows.go b/vendor/github.com/nsf/termbox-go/termbox_windows.go
deleted file mode 100644
index 7752a17..0000000
--- a/vendor/github.com/nsf/termbox-go/termbox_windows.go
+++ /dev/null
@@ -1,915 +0,0 @@
-package termbox
-
-import "math"
-import "syscall"
-import "unsafe"
-import "unicode/utf16"
-import "github.com/mattn/go-runewidth"
-
-type (
- wchar uint16
- short int16
- dword uint32
- word uint16
- char_info struct {
- char wchar
- attr word
- }
- coord struct {
- x short
- y short
- }
- small_rect struct {
- left short
- top short
- right short
- bottom short
- }
- console_screen_buffer_info struct {
- size coord
- cursor_position coord
- attributes word
- window small_rect
- maximum_window_size coord
- }
- console_cursor_info struct {
- size dword
- visible int32
- }
- input_record struct {
- event_type word
- _ [2]byte
- event [16]byte
- }
- key_event_record struct {
- key_down int32
- repeat_count word
- virtual_key_code word
- virtual_scan_code word
- unicode_char wchar
- control_key_state dword
- }
- window_buffer_size_record struct {
- size coord
- }
- mouse_event_record struct {
- mouse_pos coord
- button_state dword
- control_key_state dword
- event_flags dword
- }
- console_font_info struct {
- font uint32
- font_size coord
- }
-)
-
-const (
- mouse_lmb = 0x1
- mouse_rmb = 0x2
- mouse_mmb = 0x4 | 0x8 | 0x10
- SM_CXMIN = 28
- SM_CYMIN = 29
-)
-
-func (this coord) uintptr() uintptr {
- return uintptr(*(*int32)(unsafe.Pointer(&this)))
-}
-
-var kernel32 = syscall.NewLazyDLL("kernel32.dll")
-var moduser32 = syscall.NewLazyDLL("user32.dll")
-var is_cjk = runewidth.IsEastAsian()
-
-var (
- proc_set_console_active_screen_buffer = kernel32.NewProc("SetConsoleActiveScreenBuffer")
- proc_set_console_screen_buffer_size = kernel32.NewProc("SetConsoleScreenBufferSize")
- proc_create_console_screen_buffer = kernel32.NewProc("CreateConsoleScreenBuffer")
- proc_get_console_screen_buffer_info = kernel32.NewProc("GetConsoleScreenBufferInfo")
- proc_write_console_output = kernel32.NewProc("WriteConsoleOutputW")
- proc_write_console_output_character = kernel32.NewProc("WriteConsoleOutputCharacterW")
- proc_write_console_output_attribute = kernel32.NewProc("WriteConsoleOutputAttribute")
- proc_set_console_cursor_info = kernel32.NewProc("SetConsoleCursorInfo")
- proc_set_console_cursor_position = kernel32.NewProc("SetConsoleCursorPosition")
- proc_get_console_cursor_info = kernel32.NewProc("GetConsoleCursorInfo")
- proc_read_console_input = kernel32.NewProc("ReadConsoleInputW")
- proc_get_console_mode = kernel32.NewProc("GetConsoleMode")
- proc_set_console_mode = kernel32.NewProc("SetConsoleMode")
- proc_fill_console_output_character = kernel32.NewProc("FillConsoleOutputCharacterW")
- proc_fill_console_output_attribute = kernel32.NewProc("FillConsoleOutputAttribute")
- proc_create_event = kernel32.NewProc("CreateEventW")
- proc_wait_for_multiple_objects = kernel32.NewProc("WaitForMultipleObjects")
- proc_set_event = kernel32.NewProc("SetEvent")
- proc_get_current_console_font = kernel32.NewProc("GetCurrentConsoleFont")
- get_system_metrics = moduser32.NewProc("GetSystemMetrics")
-)
-
-func set_console_active_screen_buffer(h syscall.Handle) (err error) {
- r0, _, e1 := syscall.Syscall(proc_set_console_active_screen_buffer.Addr(),
- 1, uintptr(h), 0, 0)
- if int(r0) == 0 {
- if e1 != 0 {
- err = error(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func set_console_screen_buffer_size(h syscall.Handle, size coord) (err error) {
- r0, _, e1 := syscall.Syscall(proc_set_console_screen_buffer_size.Addr(),
- 2, uintptr(h), size.uintptr(), 0)
- if int(r0) == 0 {
- if e1 != 0 {
- err = error(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func create_console_screen_buffer() (h syscall.Handle, err error) {
- r0, _, e1 := syscall.Syscall6(proc_create_console_screen_buffer.Addr(),
- 5, uintptr(generic_read|generic_write), 0, 0, console_textmode_buffer, 0, 0)
- if int(r0) == 0 {
- if e1 != 0 {
- err = error(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return syscall.Handle(r0), err
-}
-
-func get_console_screen_buffer_info(h syscall.Handle, info *console_screen_buffer_info) (err error) {
- r0, _, e1 := syscall.Syscall(proc_get_console_screen_buffer_info.Addr(),
- 2, uintptr(h), uintptr(unsafe.Pointer(info)), 0)
- if int(r0) == 0 {
- if e1 != 0 {
- err = error(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func write_console_output(h syscall.Handle, chars []char_info, dst small_rect) (err error) {
- tmp_coord = coord{dst.right - dst.left + 1, dst.bottom - dst.top + 1}
- tmp_rect = dst
- r0, _, e1 := syscall.Syscall6(proc_write_console_output.Addr(),
- 5, uintptr(h), uintptr(unsafe.Pointer(&chars[0])), tmp_coord.uintptr(),
- tmp_coord0.uintptr(), uintptr(unsafe.Pointer(&tmp_rect)), 0)
- if int(r0) == 0 {
- if e1 != 0 {
- err = error(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func write_console_output_character(h syscall.Handle, chars []wchar, pos coord) (err error) {
- r0, _, e1 := syscall.Syscall6(proc_write_console_output_character.Addr(),
- 5, uintptr(h), uintptr(unsafe.Pointer(&chars[0])), uintptr(len(chars)),
- pos.uintptr(), uintptr(unsafe.Pointer(&tmp_arg)), 0)
- if int(r0) == 0 {
- if e1 != 0 {
- err = error(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func write_console_output_attribute(h syscall.Handle, attrs []word, pos coord) (err error) {
- r0, _, e1 := syscall.Syscall6(proc_write_console_output_attribute.Addr(),
- 5, uintptr(h), uintptr(unsafe.Pointer(&attrs[0])), uintptr(len(attrs)),
- pos.uintptr(), uintptr(unsafe.Pointer(&tmp_arg)), 0)
- if int(r0) == 0 {
- if e1 != 0 {
- err = error(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func set_console_cursor_info(h syscall.Handle, info *console_cursor_info) (err error) {
- r0, _, e1 := syscall.Syscall(proc_set_console_cursor_info.Addr(),
- 2, uintptr(h), uintptr(unsafe.Pointer(info)), 0)
- if int(r0) == 0 {
- if e1 != 0 {
- err = error(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func get_console_cursor_info(h syscall.Handle, info *console_cursor_info) (err error) {
- r0, _, e1 := syscall.Syscall(proc_get_console_cursor_info.Addr(),
- 2, uintptr(h), uintptr(unsafe.Pointer(info)), 0)
- if int(r0) == 0 {
- if e1 != 0 {
- err = error(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func set_console_cursor_position(h syscall.Handle, pos coord) (err error) {
- r0, _, e1 := syscall.Syscall(proc_set_console_cursor_position.Addr(),
- 2, uintptr(h), pos.uintptr(), 0)
- if int(r0) == 0 {
- if e1 != 0 {
- err = error(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func read_console_input(h syscall.Handle, record *input_record) (err error) {
- r0, _, e1 := syscall.Syscall6(proc_read_console_input.Addr(),
- 4, uintptr(h), uintptr(unsafe.Pointer(record)), 1, uintptr(unsafe.Pointer(&tmp_arg)), 0, 0)
- if int(r0) == 0 {
- if e1 != 0 {
- err = error(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func get_console_mode(h syscall.Handle, mode *dword) (err error) {
- r0, _, e1 := syscall.Syscall(proc_get_console_mode.Addr(),
- 2, uintptr(h), uintptr(unsafe.Pointer(mode)), 0)
- if int(r0) == 0 {
- if e1 != 0 {
- err = error(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func set_console_mode(h syscall.Handle, mode dword) (err error) {
- r0, _, e1 := syscall.Syscall(proc_set_console_mode.Addr(),
- 2, uintptr(h), uintptr(mode), 0)
- if int(r0) == 0 {
- if e1 != 0 {
- err = error(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func fill_console_output_character(h syscall.Handle, char wchar, n int) (err error) {
- r0, _, e1 := syscall.Syscall6(proc_fill_console_output_character.Addr(),
- 5, uintptr(h), uintptr(char), uintptr(n), tmp_coord.uintptr(),
- uintptr(unsafe.Pointer(&tmp_arg)), 0)
- if int(r0) == 0 {
- if e1 != 0 {
- err = error(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func fill_console_output_attribute(h syscall.Handle, attr word, n int) (err error) {
- r0, _, e1 := syscall.Syscall6(proc_fill_console_output_attribute.Addr(),
- 5, uintptr(h), uintptr(attr), uintptr(n), tmp_coord.uintptr(),
- uintptr(unsafe.Pointer(&tmp_arg)), 0)
- if int(r0) == 0 {
- if e1 != 0 {
- err = error(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func create_event() (out syscall.Handle, err error) {
- r0, _, e1 := syscall.Syscall6(proc_create_event.Addr(),
- 4, 0, 0, 0, 0, 0, 0)
- if int(r0) == 0 {
- if e1 != 0 {
- err = error(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return syscall.Handle(r0), err
-}
-
-func wait_for_multiple_objects(objects []syscall.Handle) (err error) {
- r0, _, e1 := syscall.Syscall6(proc_wait_for_multiple_objects.Addr(),
- 4, uintptr(len(objects)), uintptr(unsafe.Pointer(&objects[0])),
- 0, 0xFFFFFFFF, 0, 0)
- if uint32(r0) == 0xFFFFFFFF {
- if e1 != 0 {
- err = error(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func set_event(ev syscall.Handle) (err error) {
- r0, _, e1 := syscall.Syscall(proc_set_event.Addr(),
- 1, uintptr(ev), 0, 0)
- if int(r0) == 0 {
- if e1 != 0 {
- err = error(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func get_current_console_font(h syscall.Handle, info *console_font_info) (err error) {
- r0, _, e1 := syscall.Syscall(proc_get_current_console_font.Addr(),
- 3, uintptr(h), 0, uintptr(unsafe.Pointer(info)))
- if int(r0) == 0 {
- if e1 != 0 {
- err = error(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-type diff_msg struct {
- pos short
- lines short
- chars []char_info
-}
-
-type input_event struct {
- event Event
- err error
-}
-
-var (
- orig_cursor_info console_cursor_info
- orig_size coord
- orig_mode dword
- orig_screen syscall.Handle
- back_buffer cellbuf
- front_buffer cellbuf
- term_size coord
- input_mode = InputEsc
- cursor_x = cursor_hidden
- cursor_y = cursor_hidden
- foreground = ColorDefault
- background = ColorDefault
- in syscall.Handle
- out syscall.Handle
- interrupt syscall.Handle
- charbuf []char_info
- diffbuf []diff_msg
- beg_x = -1
- beg_y = -1
- beg_i = -1
- input_comm = make(chan Event)
- interrupt_comm = make(chan struct{})
- cancel_comm = make(chan bool, 1)
- cancel_done_comm = make(chan bool)
- alt_mode_esc = false
-
- // these ones just to prevent heap allocs at all costs
- tmp_info console_screen_buffer_info
- tmp_arg dword
- tmp_coord0 = coord{0, 0}
- tmp_coord = coord{0, 0}
- tmp_rect = small_rect{0, 0, 0, 0}
- tmp_finfo console_font_info
-)
-
-func get_cursor_position(out syscall.Handle) coord {
- err := get_console_screen_buffer_info(out, &tmp_info)
- if err != nil {
- panic(err)
- }
- return tmp_info.cursor_position
-}
-
-func get_term_size(out syscall.Handle) coord {
- err := get_console_screen_buffer_info(out, &tmp_info)
- if err != nil {
- panic(err)
- }
- return tmp_info.size
-}
-
-func get_win_min_size(out syscall.Handle) coord {
- x, _, err := get_system_metrics.Call(SM_CXMIN)
- y, _, err := get_system_metrics.Call(SM_CYMIN)
-
- if x == 0 || y == 0 {
- if err != nil {
- panic(err)
- }
- }
-
- err1 := get_current_console_font(out, &tmp_finfo)
- if err1 != nil {
- panic(err1)
- }
-
- return coord{
- x: short(math.Ceil(float64(x) / float64(tmp_finfo.font_size.x))),
- y: short(math.Ceil(float64(y) / float64(tmp_finfo.font_size.y))),
- }
-}
-
-func get_win_size(out syscall.Handle) coord {
- err := get_console_screen_buffer_info(out, &tmp_info)
- if err != nil {
- panic(err)
- }
-
- min_size := get_win_min_size(out)
-
- size := coord{
- x: tmp_info.window.right - tmp_info.window.left + 1,
- y: tmp_info.window.bottom - tmp_info.window.top + 1,
- }
-
- if size.x < min_size.x {
- size.x = min_size.x
- }
-
- if size.y < min_size.y {
- size.y = min_size.y
- }
-
- return size
-}
-
-func update_size_maybe() {
- size := get_win_size(out)
- if size.x != term_size.x || size.y != term_size.y {
- set_console_screen_buffer_size(out, size)
- term_size = size
- back_buffer.resize(int(size.x), int(size.y))
- front_buffer.resize(int(size.x), int(size.y))
- front_buffer.clear()
- clear()
-
- area := int(size.x) * int(size.y)
- if cap(charbuf) < area {
- charbuf = make([]char_info, 0, area)
- }
- }
-}
-
-var color_table_bg = []word{
- 0, // default (black)
- 0, // black
- background_red,
- background_green,
- background_red | background_green, // yellow
- background_blue,
- background_red | background_blue, // magenta
- background_green | background_blue, // cyan
- background_red | background_blue | background_green, // white
-}
-
-var color_table_fg = []word{
- foreground_red | foreground_blue | foreground_green, // default (white)
- 0,
- foreground_red,
- foreground_green,
- foreground_red | foreground_green, // yellow
- foreground_blue,
- foreground_red | foreground_blue, // magenta
- foreground_green | foreground_blue, // cyan
- foreground_red | foreground_blue | foreground_green, // white
-}
-
-const (
- replacement_char = '\uFFFD'
- max_rune = '\U0010FFFF'
- surr1 = 0xd800
- surr2 = 0xdc00
- surr3 = 0xe000
- surr_self = 0x10000
-)
-
-func append_diff_line(y int) int {
- n := 0
- for x := 0; x < front_buffer.width; {
- cell_offset := y*front_buffer.width + x
- back := &back_buffer.cells[cell_offset]
- front := &front_buffer.cells[cell_offset]
- attr, char := cell_to_char_info(*back)
- charbuf = append(charbuf, char_info{attr: attr, char: char[0]})
- *front = *back
- n++
- w := runewidth.RuneWidth(back.Ch)
- if w == 0 || w == 2 && runewidth.IsAmbiguousWidth(back.Ch) {
- w = 1
- }
- x += w
- // If not CJK, fill trailing space with whitespace
- if !is_cjk && w == 2 {
- charbuf = append(charbuf, char_info{attr: attr, char: ' '})
- }
- }
- return n
-}
-
-// compares 'back_buffer' with 'front_buffer' and prepares all changes in the form of
-// 'diff_msg's in the 'diff_buf'
-func prepare_diff_messages() {
- // clear buffers
- diffbuf = diffbuf[:0]
- charbuf = charbuf[:0]
-
- var diff diff_msg
- gbeg := 0
- for y := 0; y < front_buffer.height; y++ {
- same := true
- line_offset := y * front_buffer.width
- for x := 0; x < front_buffer.width; x++ {
- cell_offset := line_offset + x
- back := &back_buffer.cells[cell_offset]
- front := &front_buffer.cells[cell_offset]
- if *back != *front {
- same = false
- break
- }
- }
- if same && diff.lines > 0 {
- diffbuf = append(diffbuf, diff)
- diff = diff_msg{}
- }
- if !same {
- beg := len(charbuf)
- end := beg + append_diff_line(y)
- if diff.lines == 0 {
- diff.pos = short(y)
- gbeg = beg
- }
- diff.lines++
- diff.chars = charbuf[gbeg:end]
- }
- }
- if diff.lines > 0 {
- diffbuf = append(diffbuf, diff)
- diff = diff_msg{}
- }
-}
-
-func get_ct(table []word, idx int) word {
- idx = idx & 0x0F
- if idx >= len(table) {
- idx = len(table) - 1
- }
- return table[idx]
-}
-
-func cell_to_char_info(c Cell) (attr word, wc [2]wchar) {
- attr = get_ct(color_table_fg, int(c.Fg)) | get_ct(color_table_bg, int(c.Bg))
- if c.Fg&AttrReverse|c.Bg&AttrReverse != 0 {
- attr = (attr&0xF0)>>4 | (attr&0x0F)<<4
- }
- if c.Fg&AttrBold != 0 {
- attr |= foreground_intensity
- }
- if c.Bg&AttrBold != 0 {
- attr |= background_intensity
- }
-
- r0, r1 := utf16.EncodeRune(c.Ch)
- if r0 == 0xFFFD {
- wc[0] = wchar(c.Ch)
- wc[1] = ' '
- } else {
- wc[0] = wchar(r0)
- wc[1] = wchar(r1)
- }
- return
-}
-
-func move_cursor(x, y int) {
- err := set_console_cursor_position(out, coord{short(x), short(y)})
- if err != nil {
- panic(err)
- }
-}
-
-func show_cursor(visible bool) {
- var v int32
- if visible {
- v = 1
- }
-
- var info console_cursor_info
- info.size = 100
- info.visible = v
- err := set_console_cursor_info(out, &info)
- if err != nil {
- panic(err)
- }
-}
-
-func clear() {
- var err error
- attr, char := cell_to_char_info(Cell{
- ' ',
- foreground,
- background,
- })
-
- area := int(term_size.x) * int(term_size.y)
- err = fill_console_output_attribute(out, attr, area)
- if err != nil {
- panic(err)
- }
- err = fill_console_output_character(out, char[0], area)
- if err != nil {
- panic(err)
- }
- if !is_cursor_hidden(cursor_x, cursor_y) {
- move_cursor(cursor_x, cursor_y)
- }
-}
-
-func key_event_record_to_event(r *key_event_record) (Event, bool) {
- if r.key_down == 0 {
- return Event{}, false
- }
-
- e := Event{Type: EventKey}
- if input_mode&InputAlt != 0 {
- if alt_mode_esc {
- e.Mod = ModAlt
- alt_mode_esc = false
- }
- if r.control_key_state&(left_alt_pressed|right_alt_pressed) != 0 {
- e.Mod = ModAlt
- }
- }
-
- ctrlpressed := r.control_key_state&(left_ctrl_pressed|right_ctrl_pressed) != 0
-
- if r.virtual_key_code >= vk_f1 && r.virtual_key_code <= vk_f12 {
- switch r.virtual_key_code {
- case vk_f1:
- e.Key = KeyF1
- case vk_f2:
- e.Key = KeyF2
- case vk_f3:
- e.Key = KeyF3
- case vk_f4:
- e.Key = KeyF4
- case vk_f5:
- e.Key = KeyF5
- case vk_f6:
- e.Key = KeyF6
- case vk_f7:
- e.Key = KeyF7
- case vk_f8:
- e.Key = KeyF8
- case vk_f9:
- e.Key = KeyF9
- case vk_f10:
- e.Key = KeyF10
- case vk_f11:
- e.Key = KeyF11
- case vk_f12:
- e.Key = KeyF12
- default:
- panic("unreachable")
- }
-
- return e, true
- }
-
- if r.virtual_key_code <= vk_delete {
- switch r.virtual_key_code {
- case vk_insert:
- e.Key = KeyInsert
- case vk_delete:
- e.Key = KeyDelete
- case vk_home:
- e.Key = KeyHome
- case vk_end:
- e.Key = KeyEnd
- case vk_pgup:
- e.Key = KeyPgup
- case vk_pgdn:
- e.Key = KeyPgdn
- case vk_arrow_up:
- e.Key = KeyArrowUp
- case vk_arrow_down:
- e.Key = KeyArrowDown
- case vk_arrow_left:
- e.Key = KeyArrowLeft
- case vk_arrow_right:
- e.Key = KeyArrowRight
- case vk_backspace:
- if ctrlpressed {
- e.Key = KeyBackspace2
- } else {
- e.Key = KeyBackspace
- }
- case vk_tab:
- e.Key = KeyTab
- case vk_enter:
- e.Key = KeyEnter
- case vk_esc:
- switch {
- case input_mode&InputEsc != 0:
- e.Key = KeyEsc
- case input_mode&InputAlt != 0:
- alt_mode_esc = true
- return Event{}, false
- }
- case vk_space:
- if ctrlpressed {
- // manual return here, because KeyCtrlSpace is zero
- e.Key = KeyCtrlSpace
- return e, true
- } else {
- e.Key = KeySpace
- }
- }
-
- if e.Key != 0 {
- return e, true
- }
- }
-
- if ctrlpressed {
- if Key(r.unicode_char) >= KeyCtrlA && Key(r.unicode_char) <= KeyCtrlRsqBracket {
- e.Key = Key(r.unicode_char)
- if input_mode&InputAlt != 0 && e.Key == KeyEsc {
- alt_mode_esc = true
- return Event{}, false
- }
- return e, true
- }
- switch r.virtual_key_code {
- case 192, 50:
- // manual return here, because KeyCtrl2 is zero
- e.Key = KeyCtrl2
- return e, true
- case 51:
- if input_mode&InputAlt != 0 {
- alt_mode_esc = true
- return Event{}, false
- }
- e.Key = KeyCtrl3
- case 52:
- e.Key = KeyCtrl4
- case 53:
- e.Key = KeyCtrl5
- case 54:
- e.Key = KeyCtrl6
- case 189, 191, 55:
- e.Key = KeyCtrl7
- case 8, 56:
- e.Key = KeyCtrl8
- }
-
- if e.Key != 0 {
- return e, true
- }
- }
-
- if r.unicode_char != 0 {
- e.Ch = rune(r.unicode_char)
- return e, true
- }
-
- return Event{}, false
-}
-
-func input_event_producer() {
- var r input_record
- var err error
- var last_button Key
- var last_button_pressed Key
- var last_state = dword(0)
- var last_x, last_y = -1, -1
- handles := []syscall.Handle{in, interrupt}
- for {
- err = wait_for_multiple_objects(handles)
- if err != nil {
- input_comm <- Event{Type: EventError, Err: err}
- }
-
- select {
- case <-cancel_comm:
- cancel_done_comm <- true
- return
- default:
- }
-
- err = read_console_input(in, &r)
- if err != nil {
- input_comm <- Event{Type: EventError, Err: err}
- }
-
- switch r.event_type {
- case key_event:
- kr := (*key_event_record)(unsafe.Pointer(&r.event))
- ev, ok := key_event_record_to_event(kr)
- if ok {
- for i := 0; i < int(kr.repeat_count); i++ {
- input_comm <- ev
- }
- }
- case window_buffer_size_event:
- sr := *(*window_buffer_size_record)(unsafe.Pointer(&r.event))
- input_comm <- Event{
- Type: EventResize,
- Width: int(sr.size.x),
- Height: int(sr.size.y),
- }
- case mouse_event:
- mr := *(*mouse_event_record)(unsafe.Pointer(&r.event))
- ev := Event{Type: EventMouse}
- switch mr.event_flags {
- case 0, 2:
- // single or double click
- cur_state := mr.button_state
- switch {
- case last_state&mouse_lmb == 0 && cur_state&mouse_lmb != 0:
- last_button = MouseLeft
- last_button_pressed = last_button
- case last_state&mouse_rmb == 0 && cur_state&mouse_rmb != 0:
- last_button = MouseRight
- last_button_pressed = last_button
- case last_state&mouse_mmb == 0 && cur_state&mouse_mmb != 0:
- last_button = MouseMiddle
- last_button_pressed = last_button
- case last_state&mouse_lmb != 0 && cur_state&mouse_lmb == 0:
- last_button = MouseRelease
- case last_state&mouse_rmb != 0 && cur_state&mouse_rmb == 0:
- last_button = MouseRelease
- case last_state&mouse_mmb != 0 && cur_state&mouse_mmb == 0:
- last_button = MouseRelease
- default:
- last_state = cur_state
- continue
- }
- last_state = cur_state
- ev.Key = last_button
- last_x, last_y = int(mr.mouse_pos.x), int(mr.mouse_pos.y)
- ev.MouseX = last_x
- ev.MouseY = last_y
- case 1:
- // mouse motion
- x, y := int(mr.mouse_pos.x), int(mr.mouse_pos.y)
- if last_state != 0 && (last_x != x || last_y != y) {
- ev.Key = last_button_pressed
- ev.Mod = ModMotion
- ev.MouseX = x
- ev.MouseY = y
- last_x, last_y = x, y
- } else {
- ev.Type = EventNone
- }
- case 4:
- // mouse wheel
- n := int16(mr.button_state >> 16)
- if n > 0 {
- ev.Key = MouseWheelUp
- } else {
- ev.Key = MouseWheelDown
- }
- last_x, last_y = int(mr.mouse_pos.x), int(mr.mouse_pos.y)
- ev.MouseX = last_x
- ev.MouseY = last_y
- default:
- ev.Type = EventNone
- }
- if ev.Type != EventNone {
- input_comm <- ev
- }
- }
- }
-}
diff --git a/vendor/github.com/nsf/termbox-go/terminfo.go b/vendor/github.com/nsf/termbox-go/terminfo.go
deleted file mode 100644
index 5d38fce..0000000
--- a/vendor/github.com/nsf/termbox-go/terminfo.go
+++ /dev/null
@@ -1,226 +0,0 @@
-// +build !windows
-// This file contains a simple and incomplete implementation of the terminfo
-// database. Information was taken from the ncurses manpages term(5) and
-// terminfo(5). Currently, only the string capabilities for special keys and for
-// functions without parameters are actually used. Colors are still done with
-// ANSI escape sequences. Other special features that are not (yet?) supported
-// are reading from ~/.terminfo, the TERMINFO_DIRS variable, Berkeley database
-// format and extended capabilities.
-
-package termbox
-
-import (
- "bytes"
- "encoding/binary"
- "encoding/hex"
- "errors"
- "fmt"
- "io/ioutil"
- "os"
- "strings"
-)
-
-const (
- ti_magic = 0432
- ti_header_length = 12
- ti_mouse_enter = "\x1b[?1000h\x1b[?1002h\x1b[?1015h\x1b[?1006h"
- ti_mouse_leave = "\x1b[?1006l\x1b[?1015l\x1b[?1002l\x1b[?1000l"
-)
-
-func load_terminfo() ([]byte, error) {
- var data []byte
- var err error
-
- term := os.Getenv("TERM")
- if term == "" {
- return nil, fmt.Errorf("termbox: TERM not set")
- }
-
- // The following behaviour follows the one described in terminfo(5) as
- // distributed by ncurses.
-
- terminfo := os.Getenv("TERMINFO")
- if terminfo != "" {
- // if TERMINFO is set, no other directory should be searched
- return ti_try_path(terminfo)
- }
-
- // next, consider ~/.terminfo
- home := os.Getenv("HOME")
- if home != "" {
- data, err = ti_try_path(home + "/.terminfo")
- if err == nil {
- return data, nil
- }
- }
-
- // next, TERMINFO_DIRS
- dirs := os.Getenv("TERMINFO_DIRS")
- if dirs != "" {
- for _, dir := range strings.Split(dirs, ":") {
- if dir == "" {
- // "" -> "/usr/share/terminfo"
- dir = "/usr/share/terminfo"
- }
- data, err = ti_try_path(dir)
- if err == nil {
- return data, nil
- }
- }
- }
-
- // fall back to /usr/share/terminfo
- return ti_try_path("/usr/share/terminfo")
-}
-
-func ti_try_path(path string) (data []byte, err error) {
- // load_terminfo already made sure it is set
- term := os.Getenv("TERM")
-
- // first try, the typical *nix path
- terminfo := path + "/" + term[0:1] + "/" + term
- data, err = ioutil.ReadFile(terminfo)
- if err == nil {
- return
- }
-
- // fallback to darwin specific dirs structure
- terminfo = path + "/" + hex.EncodeToString([]byte(term[:1])) + "/" + term
- data, err = ioutil.ReadFile(terminfo)
- return
-}
-
-func setup_term_builtin() error {
- name := os.Getenv("TERM")
- if name == "" {
- return errors.New("termbox: TERM environment variable not set")
- }
-
- for _, t := range terms {
- if t.name == name {
- keys = t.keys
- funcs = t.funcs
- return nil
- }
- }
-
- compat_table := []struct {
- partial string
- keys []string
- funcs []string
- }{
- {"xterm", xterm_keys, xterm_funcs},
- {"rxvt", rxvt_unicode_keys, rxvt_unicode_funcs},
- {"linux", linux_keys, linux_funcs},
- {"Eterm", eterm_keys, eterm_funcs},
- {"screen", screen_keys, screen_funcs},
- // let's assume that 'cygwin' is xterm compatible
- {"cygwin", xterm_keys, xterm_funcs},
- {"st", xterm_keys, xterm_funcs},
- }
-
- // try compatibility variants
- for _, it := range compat_table {
- if strings.Contains(name, it.partial) {
- keys = it.keys
- funcs = it.funcs
- return nil
- }
- }
-
- return errors.New("termbox: unsupported terminal")
-}
-
-func setup_term() (err error) {
- var data []byte
- var header [6]int16
- var str_offset, table_offset int16
-
- data, err = load_terminfo()
- if err != nil {
- return setup_term_builtin()
- }
-
- rd := bytes.NewReader(data)
- // 0: magic number, 1: size of names section, 2: size of boolean section, 3:
- // size of numbers section (in integers), 4: size of the strings section (in
- // integers), 5: size of the string table
-
- err = binary.Read(rd, binary.LittleEndian, header[:])
- if err != nil {
- return
- }
-
- number_sec_len := int16(2)
- if header[0] == 542 { // doc says it should be octal 0542, but what I see it terminfo files is 542, learn to program please... thank you..
- number_sec_len = 4
- }
-
- if (header[1]+header[2])%2 != 0 {
- // old quirk to align everything on word boundaries
- header[2] += 1
- }
- str_offset = ti_header_length + header[1] + header[2] + number_sec_len*header[3]
- table_offset = str_offset + 2*header[4]
-
- keys = make([]string, 0xFFFF-key_min)
- for i, _ := range keys {
- keys[i], err = ti_read_string(rd, str_offset+2*ti_keys[i], table_offset)
- if err != nil {
- return
- }
- }
- funcs = make([]string, t_max_funcs)
- // the last two entries are reserved for mouse. because the table offset is
- // not there, the two entries have to fill in manually
- for i, _ := range funcs[:len(funcs)-2] {
- funcs[i], err = ti_read_string(rd, str_offset+2*ti_funcs[i], table_offset)
- if err != nil {
- return
- }
- }
- funcs[t_max_funcs-2] = ti_mouse_enter
- funcs[t_max_funcs-1] = ti_mouse_leave
- return nil
-}
-
-func ti_read_string(rd *bytes.Reader, str_off, table int16) (string, error) {
- var off int16
-
- _, err := rd.Seek(int64(str_off), 0)
- if err != nil {
- return "", err
- }
- err = binary.Read(rd, binary.LittleEndian, &off)
- if err != nil {
- return "", err
- }
- _, err = rd.Seek(int64(table+off), 0)
- if err != nil {
- return "", err
- }
- var bs []byte
- for {
- b, err := rd.ReadByte()
- if err != nil {
- return "", err
- }
- if b == byte(0x00) {
- break
- }
- bs = append(bs, b)
- }
- return string(bs), nil
-}
-
-// "Maps" the function constants from termbox.go to the number of the respective
-// string capability in the terminfo file. Taken from (ncurses) term.h.
-var ti_funcs = []int16{
- 28, 40, 16, 13, 5, 39, 36, 27, 26, 34, 89, 88,
-}
-
-// Same as above for the special keys.
-var ti_keys = []int16{
- 66, 68 /* apparently not a typo; 67 is F10 for whatever reason */, 69, 70,
- 71, 72, 73, 74, 75, 67, 216, 217, 77, 59, 76, 164, 82, 81, 87, 61, 79, 83,
-}
diff --git a/vendor/github.com/nsf/termbox-go/terminfo_builtin.go b/vendor/github.com/nsf/termbox-go/terminfo_builtin.go
deleted file mode 100644
index a948660..0000000
--- a/vendor/github.com/nsf/termbox-go/terminfo_builtin.go
+++ /dev/null
@@ -1,64 +0,0 @@
-// +build !windows
-
-package termbox
-
-// Eterm
-var eterm_keys = []string{
- "\x1b[11~", "\x1b[12~", "\x1b[13~", "\x1b[14~", "\x1b[15~", "\x1b[17~", "\x1b[18~", "\x1b[19~", "\x1b[20~", "\x1b[21~", "\x1b[23~", "\x1b[24~", "\x1b[2~", "\x1b[3~", "\x1b[7~", "\x1b[8~", "\x1b[5~", "\x1b[6~", "\x1b[A", "\x1b[B", "\x1b[D", "\x1b[C",
-}
-var eterm_funcs = []string{
- "\x1b7\x1b[?47h", "\x1b[2J\x1b[?47l\x1b8", "\x1b[?25h", "\x1b[?25l", "\x1b[H\x1b[2J", "\x1b[m\x0f", "\x1b[4m", "\x1b[1m", "\x1b[5m", "\x1b[7m", "", "", "", "",
-}
-
-// screen
-var screen_keys = []string{
- "\x1bOP", "\x1bOQ", "\x1bOR", "\x1bOS", "\x1b[15~", "\x1b[17~", "\x1b[18~", "\x1b[19~", "\x1b[20~", "\x1b[21~", "\x1b[23~", "\x1b[24~", "\x1b[2~", "\x1b[3~", "\x1b[1~", "\x1b[4~", "\x1b[5~", "\x1b[6~", "\x1bOA", "\x1bOB", "\x1bOD", "\x1bOC",
-}
-var screen_funcs = []string{
- "\x1b[?1049h", "\x1b[?1049l", "\x1b[34h\x1b[?25h", "\x1b[?25l", "\x1b[H\x1b[J", "\x1b[m\x0f", "\x1b[4m", "\x1b[1m", "\x1b[5m", "\x1b[7m", "\x1b[?1h\x1b=", "\x1b[?1l\x1b>", ti_mouse_enter, ti_mouse_leave,
-}
-
-// xterm
-var xterm_keys = []string{
- "\x1bOP", "\x1bOQ", "\x1bOR", "\x1bOS", "\x1b[15~", "\x1b[17~", "\x1b[18~", "\x1b[19~", "\x1b[20~", "\x1b[21~", "\x1b[23~", "\x1b[24~", "\x1b[2~", "\x1b[3~", "\x1bOH", "\x1bOF", "\x1b[5~", "\x1b[6~", "\x1bOA", "\x1bOB", "\x1bOD", "\x1bOC",
-}
-var xterm_funcs = []string{
- "\x1b[?1049h", "\x1b[?1049l", "\x1b[?12l\x1b[?25h", "\x1b[?25l", "\x1b[H\x1b[2J", "\x1b(B\x1b[m", "\x1b[4m", "\x1b[1m", "\x1b[5m", "\x1b[7m", "\x1b[?1h\x1b=", "\x1b[?1l\x1b>", ti_mouse_enter, ti_mouse_leave,
-}
-
-// rxvt-unicode
-var rxvt_unicode_keys = []string{
- "\x1b[11~", "\x1b[12~", "\x1b[13~", "\x1b[14~", "\x1b[15~", "\x1b[17~", "\x1b[18~", "\x1b[19~", "\x1b[20~", "\x1b[21~", "\x1b[23~", "\x1b[24~", "\x1b[2~", "\x1b[3~", "\x1b[7~", "\x1b[8~", "\x1b[5~", "\x1b[6~", "\x1b[A", "\x1b[B", "\x1b[D", "\x1b[C",
-}
-var rxvt_unicode_funcs = []string{
- "\x1b[?1049h", "\x1b[r\x1b[?1049l", "\x1b[?25h", "\x1b[?25l", "\x1b[H\x1b[2J", "\x1b[m\x1b(B", "\x1b[4m", "\x1b[1m", "\x1b[5m", "\x1b[7m", "\x1b=", "\x1b>", ti_mouse_enter, ti_mouse_leave,
-}
-
-// linux
-var linux_keys = []string{
- "\x1b[[A", "\x1b[[B", "\x1b[[C", "\x1b[[D", "\x1b[[E", "\x1b[17~", "\x1b[18~", "\x1b[19~", "\x1b[20~", "\x1b[21~", "\x1b[23~", "\x1b[24~", "\x1b[2~", "\x1b[3~", "\x1b[1~", "\x1b[4~", "\x1b[5~", "\x1b[6~", "\x1b[A", "\x1b[B", "\x1b[D", "\x1b[C",
-}
-var linux_funcs = []string{
- "", "", "\x1b[?25h\x1b[?0c", "\x1b[?25l\x1b[?1c", "\x1b[H\x1b[J", "\x1b[0;10m", "\x1b[4m", "\x1b[1m", "\x1b[5m", "\x1b[7m", "", "", "", "",
-}
-
-// rxvt-256color
-var rxvt_256color_keys = []string{
- "\x1b[11~", "\x1b[12~", "\x1b[13~", "\x1b[14~", "\x1b[15~", "\x1b[17~", "\x1b[18~", "\x1b[19~", "\x1b[20~", "\x1b[21~", "\x1b[23~", "\x1b[24~", "\x1b[2~", "\x1b[3~", "\x1b[7~", "\x1b[8~", "\x1b[5~", "\x1b[6~", "\x1b[A", "\x1b[B", "\x1b[D", "\x1b[C",
-}
-var rxvt_256color_funcs = []string{
- "\x1b7\x1b[?47h", "\x1b[2J\x1b[?47l\x1b8", "\x1b[?25h", "\x1b[?25l", "\x1b[H\x1b[2J", "\x1b[m\x0f", "\x1b[4m", "\x1b[1m", "\x1b[5m", "\x1b[7m", "\x1b=", "\x1b>", ti_mouse_enter, ti_mouse_leave,
-}
-
-var terms = []struct {
- name string
- keys []string
- funcs []string
-}{
- {"Eterm", eterm_keys, eterm_funcs},
- {"screen", screen_keys, screen_funcs},
- {"xterm", xterm_keys, xterm_funcs},
- {"rxvt-unicode", rxvt_unicode_keys, rxvt_unicode_funcs},
- {"linux", linux_keys, linux_funcs},
- {"rxvt-256color", rxvt_256color_keys, rxvt_256color_funcs},
-}
diff --git a/vendor/github.com/shirou/gopsutil/LICENSE b/vendor/github.com/shirou/gopsutil/LICENSE
deleted file mode 100644
index da71a5e..0000000
--- a/vendor/github.com/shirou/gopsutil/LICENSE
+++ /dev/null
@@ -1,61 +0,0 @@
-gopsutil is distributed under BSD license reproduced below.
-
-Copyright (c) 2014, WAKAYAMA Shirou
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification,
-are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
- * Neither the name of the gopsutil authors nor the names of its contributors
- may be used to endorse or promote products derived from this software without
- specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
--------
-internal/common/binary.go in the gopsutil is copied and modifid from golang/encoding/binary.go.
-
-
-
-Copyright (c) 2009 The Go Authors. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
- * Redistributions of source code must retain the above copyright
-notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above
-copyright notice, this list of conditions and the following disclaimer
-in the documentation and/or other materials provided with the
-distribution.
- * Neither the name of Google Inc. nor the names of its
-contributors may be used to endorse or promote products derived from
-this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
diff --git a/vendor/github.com/shirou/gopsutil/cpu/cpu.go b/vendor/github.com/shirou/gopsutil/cpu/cpu.go
deleted file mode 100644
index ceaf77f..0000000
--- a/vendor/github.com/shirou/gopsutil/cpu/cpu.go
+++ /dev/null
@@ -1,189 +0,0 @@
-package cpu
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "runtime"
- "strconv"
- "strings"
- "sync"
- "time"
-
- "github.com/shirou/gopsutil/internal/common"
-)
-
-// TimesStat contains the amounts of time the CPU has spent performing different
-// kinds of work. Time units are in USER_HZ or Jiffies (typically hundredths of
-// a second). It is based on linux /proc/stat file.
-type TimesStat struct {
- CPU string `json:"cpu"`
- User float64 `json:"user"`
- System float64 `json:"system"`
- Idle float64 `json:"idle"`
- Nice float64 `json:"nice"`
- Iowait float64 `json:"iowait"`
- Irq float64 `json:"irq"`
- Softirq float64 `json:"softirq"`
- Steal float64 `json:"steal"`
- Guest float64 `json:"guest"`
- GuestNice float64 `json:"guestNice"`
- Stolen float64 `json:"stolen"`
-}
-
-type InfoStat struct {
- CPU int32 `json:"cpu"`
- VendorID string `json:"vendorId"`
- Family string `json:"family"`
- Model string `json:"model"`
- Stepping int32 `json:"stepping"`
- PhysicalID string `json:"physicalId"`
- CoreID string `json:"coreId"`
- Cores int32 `json:"cores"`
- ModelName string `json:"modelName"`
- Mhz float64 `json:"mhz"`
- CacheSize int32 `json:"cacheSize"`
- Flags []string `json:"flags"`
- Microcode string `json:"microcode"`
-}
-
-type lastPercent struct {
- sync.Mutex
- lastCPUTimes []TimesStat
- lastPerCPUTimes []TimesStat
-}
-
-var lastCPUPercent lastPercent
-var invoke common.Invoker = common.Invoke{}
-
-func init() {
- lastCPUPercent.Lock()
- lastCPUPercent.lastCPUTimes, _ = Times(false)
- lastCPUPercent.lastPerCPUTimes, _ = Times(true)
- lastCPUPercent.Unlock()
-}
-
-func Counts(logical bool) (int, error) {
- return CountsWithContext(context.Background(), logical)
-}
-
-func CountsWithContext(ctx context.Context, logical bool) (int, error) {
- return runtime.NumCPU(), nil
-}
-
-func (c TimesStat) String() string {
- v := []string{
- `"cpu":"` + c.CPU + `"`,
- `"user":` + strconv.FormatFloat(c.User, 'f', 1, 64),
- `"system":` + strconv.FormatFloat(c.System, 'f', 1, 64),
- `"idle":` + strconv.FormatFloat(c.Idle, 'f', 1, 64),
- `"nice":` + strconv.FormatFloat(c.Nice, 'f', 1, 64),
- `"iowait":` + strconv.FormatFloat(c.Iowait, 'f', 1, 64),
- `"irq":` + strconv.FormatFloat(c.Irq, 'f', 1, 64),
- `"softirq":` + strconv.FormatFloat(c.Softirq, 'f', 1, 64),
- `"steal":` + strconv.FormatFloat(c.Steal, 'f', 1, 64),
- `"guest":` + strconv.FormatFloat(c.Guest, 'f', 1, 64),
- `"guestNice":` + strconv.FormatFloat(c.GuestNice, 'f', 1, 64),
- `"stolen":` + strconv.FormatFloat(c.Stolen, 'f', 1, 64),
- }
-
- return `{` + strings.Join(v, ",") + `}`
-}
-
-// Total returns the total number of seconds in a CPUTimesStat
-func (c TimesStat) Total() float64 {
- total := c.User + c.System + c.Nice + c.Iowait + c.Irq + c.Softirq + c.Steal +
- c.Guest + c.GuestNice + c.Idle + c.Stolen
- return total
-}
-
-func (c InfoStat) String() string {
- s, _ := json.Marshal(c)
- return string(s)
-}
-
-func getAllBusy(t TimesStat) (float64, float64) {
- busy := t.User + t.System + t.Nice + t.Iowait + t.Irq +
- t.Softirq + t.Steal + t.Guest + t.GuestNice + t.Stolen
- return busy + t.Idle, busy
-}
-
-func calculateBusy(t1, t2 TimesStat) float64 {
- t1All, t1Busy := getAllBusy(t1)
- t2All, t2Busy := getAllBusy(t2)
-
- if t2Busy <= t1Busy {
- return 0
- }
- if t2All <= t1All {
- return 1
- }
- return (t2Busy - t1Busy) / (t2All - t1All) * 100
-}
-
-func calculateAllBusy(t1, t2 []TimesStat) ([]float64, error) {
- // Make sure the CPU measurements have the same length.
- if len(t1) != len(t2) {
- return nil, fmt.Errorf(
- "received two CPU counts: %d != %d",
- len(t1), len(t2),
- )
- }
-
- ret := make([]float64, len(t1))
- for i, t := range t2 {
- ret[i] = calculateBusy(t1[i], t)
- }
- return ret, nil
-}
-
-// Percent calculates the percentage of cpu used either per CPU or combined.
-// If an interval of 0 is given it will compare the current cpu times against the last call.
-// Returns one value per cpu, or a single value if percpu is set to false.
-func Percent(interval time.Duration, percpu bool) ([]float64, error) {
- return PercentWithContext(context.Background(), interval, percpu)
-}
-
-func PercentWithContext(ctx context.Context, interval time.Duration, percpu bool) ([]float64, error) {
- if interval <= 0 {
- return percentUsedFromLastCall(percpu)
- }
-
- // Get CPU usage at the start of the interval.
- cpuTimes1, err := Times(percpu)
- if err != nil {
- return nil, err
- }
-
- time.Sleep(interval)
-
- // And at the end of the interval.
- cpuTimes2, err := Times(percpu)
- if err != nil {
- return nil, err
- }
-
- return calculateAllBusy(cpuTimes1, cpuTimes2)
-}
-
-func percentUsedFromLastCall(percpu bool) ([]float64, error) {
- cpuTimes, err := Times(percpu)
- if err != nil {
- return nil, err
- }
- lastCPUPercent.Lock()
- defer lastCPUPercent.Unlock()
- var lastTimes []TimesStat
- if percpu {
- lastTimes = lastCPUPercent.lastPerCPUTimes
- lastCPUPercent.lastPerCPUTimes = cpuTimes
- } else {
- lastTimes = lastCPUPercent.lastCPUTimes
- lastCPUPercent.lastCPUTimes = cpuTimes
- }
-
- if lastTimes == nil {
- return nil, fmt.Errorf("error getting times for cpu percent. lastTimes was nil")
- }
- return calculateAllBusy(lastTimes, cpuTimes)
-}
diff --git a/vendor/github.com/shirou/gopsutil/cpu/cpu_darwin.go b/vendor/github.com/shirou/gopsutil/cpu/cpu_darwin.go
deleted file mode 100644
index 74d2737..0000000
--- a/vendor/github.com/shirou/gopsutil/cpu/cpu_darwin.go
+++ /dev/null
@@ -1,115 +0,0 @@
-// +build darwin
-
-package cpu
-
-import (
- "context"
- "os/exec"
- "strconv"
- "strings"
-)
-
-// sys/resource.h
-const (
- CPUser = 0
- CPNice = 1
- CPSys = 2
- CPIntr = 3
- CPIdle = 4
- CPUStates = 5
-)
-
-// default value. from time.h
-var ClocksPerSec = float64(128)
-
-func Times(percpu bool) ([]TimesStat, error) {
- return TimesWithContext(context.Background(), percpu)
-}
-
-func TimesWithContext(ctx context.Context, percpu bool) ([]TimesStat, error) {
- if percpu {
- return perCPUTimes()
- }
-
- return allCPUTimes()
-}
-
-// Returns only one CPUInfoStat on FreeBSD
-func Info() ([]InfoStat, error) {
- return InfoWithContext(context.Background())
-}
-
-func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
- var ret []InfoStat
- sysctl, err := exec.LookPath("/usr/sbin/sysctl")
- if err != nil {
- return ret, err
- }
- out, err := invoke.CommandWithContext(ctx, sysctl, "machdep.cpu")
- if err != nil {
- return ret, err
- }
-
- c := InfoStat{}
- for _, line := range strings.Split(string(out), "\n") {
- values := strings.Fields(line)
- if len(values) < 1 {
- continue
- }
-
- t, err := strconv.ParseInt(values[1], 10, 64)
- // err is not checked here because some value is string.
- if strings.HasPrefix(line, "machdep.cpu.brand_string") {
- c.ModelName = strings.Join(values[1:], " ")
- } else if strings.HasPrefix(line, "machdep.cpu.family") {
- c.Family = values[1]
- } else if strings.HasPrefix(line, "machdep.cpu.model") {
- c.Model = values[1]
- } else if strings.HasPrefix(line, "machdep.cpu.stepping") {
- if err != nil {
- return ret, err
- }
- c.Stepping = int32(t)
- } else if strings.HasPrefix(line, "machdep.cpu.features") {
- for _, v := range values[1:] {
- c.Flags = append(c.Flags, strings.ToLower(v))
- }
- } else if strings.HasPrefix(line, "machdep.cpu.leaf7_features") {
- for _, v := range values[1:] {
- c.Flags = append(c.Flags, strings.ToLower(v))
- }
- } else if strings.HasPrefix(line, "machdep.cpu.extfeatures") {
- for _, v := range values[1:] {
- c.Flags = append(c.Flags, strings.ToLower(v))
- }
- } else if strings.HasPrefix(line, "machdep.cpu.core_count") {
- if err != nil {
- return ret, err
- }
- c.Cores = int32(t)
- } else if strings.HasPrefix(line, "machdep.cpu.cache.size") {
- if err != nil {
- return ret, err
- }
- c.CacheSize = int32(t)
- } else if strings.HasPrefix(line, "machdep.cpu.vendor") {
- c.VendorID = values[1]
- }
- }
-
- // Use the rated frequency of the CPU. This is a static value and does not
- // account for low power or Turbo Boost modes.
- out, err = invoke.CommandWithContext(ctx, sysctl, "hw.cpufrequency")
- if err != nil {
- return ret, err
- }
-
- values := strings.Fields(string(out))
- hz, err := strconv.ParseFloat(values[1], 64)
- if err != nil {
- return ret, err
- }
- c.Mhz = hz / 1000000.0
-
- return append(ret, c), nil
-}
diff --git a/vendor/github.com/shirou/gopsutil/cpu/cpu_darwin_cgo.go b/vendor/github.com/shirou/gopsutil/cpu/cpu_darwin_cgo.go
deleted file mode 100644
index 180e0af..0000000
--- a/vendor/github.com/shirou/gopsutil/cpu/cpu_darwin_cgo.go
+++ /dev/null
@@ -1,111 +0,0 @@
-// +build darwin
-// +build cgo
-
-package cpu
-
-/*
-#include
-#include
-#include
-#include
-#include
-#include
-#if TARGET_OS_MAC
-#include
-#endif
-#include
-#include
-*/
-import "C"
-
-import (
- "bytes"
- "encoding/binary"
- "fmt"
- "unsafe"
-)
-
-// these CPU times for darwin is borrowed from influxdb/telegraf.
-
-func perCPUTimes() ([]TimesStat, error) {
- var (
- count C.mach_msg_type_number_t
- cpuload *C.processor_cpu_load_info_data_t
- ncpu C.natural_t
- )
-
- status := C.host_processor_info(C.host_t(C.mach_host_self()),
- C.PROCESSOR_CPU_LOAD_INFO,
- &ncpu,
- (*C.processor_info_array_t)(unsafe.Pointer(&cpuload)),
- &count)
-
- if status != C.KERN_SUCCESS {
- return nil, fmt.Errorf("host_processor_info error=%d", status)
- }
-
- // jump through some cgo casting hoops and ensure we properly free
- // the memory that cpuload points to
- target := C.vm_map_t(C.mach_task_self_)
- address := C.vm_address_t(uintptr(unsafe.Pointer(cpuload)))
- defer C.vm_deallocate(target, address, C.vm_size_t(ncpu))
-
- // the body of struct processor_cpu_load_info
- // aka processor_cpu_load_info_data_t
- var cpu_ticks [C.CPU_STATE_MAX]uint32
-
- // copy the cpuload array to a []byte buffer
- // where we can binary.Read the data
- size := int(ncpu) * binary.Size(cpu_ticks)
- buf := (*[1 << 30]byte)(unsafe.Pointer(cpuload))[:size:size]
-
- bbuf := bytes.NewBuffer(buf)
-
- var ret []TimesStat
-
- for i := 0; i < int(ncpu); i++ {
- err := binary.Read(bbuf, binary.LittleEndian, &cpu_ticks)
- if err != nil {
- return nil, err
- }
-
- c := TimesStat{
- CPU: fmt.Sprintf("cpu%d", i),
- User: float64(cpu_ticks[C.CPU_STATE_USER]) / ClocksPerSec,
- System: float64(cpu_ticks[C.CPU_STATE_SYSTEM]) / ClocksPerSec,
- Nice: float64(cpu_ticks[C.CPU_STATE_NICE]) / ClocksPerSec,
- Idle: float64(cpu_ticks[C.CPU_STATE_IDLE]) / ClocksPerSec,
- }
-
- ret = append(ret, c)
- }
-
- return ret, nil
-}
-
-func allCPUTimes() ([]TimesStat, error) {
- var count C.mach_msg_type_number_t
- var cpuload C.host_cpu_load_info_data_t
-
- count = C.HOST_CPU_LOAD_INFO_COUNT
-
- status := C.host_statistics(C.host_t(C.mach_host_self()),
- C.HOST_CPU_LOAD_INFO,
- C.host_info_t(unsafe.Pointer(&cpuload)),
- &count)
-
- if status != C.KERN_SUCCESS {
- return nil, fmt.Errorf("host_statistics error=%d", status)
- }
-
- c := TimesStat{
- CPU: "cpu-total",
- User: float64(cpuload.cpu_ticks[C.CPU_STATE_USER]) / ClocksPerSec,
- System: float64(cpuload.cpu_ticks[C.CPU_STATE_SYSTEM]) / ClocksPerSec,
- Nice: float64(cpuload.cpu_ticks[C.CPU_STATE_NICE]) / ClocksPerSec,
- Idle: float64(cpuload.cpu_ticks[C.CPU_STATE_IDLE]) / ClocksPerSec,
- }
-
- return []TimesStat{c}, nil
-
-}
diff --git a/vendor/github.com/shirou/gopsutil/cpu/cpu_darwin_nocgo.go b/vendor/github.com/shirou/gopsutil/cpu/cpu_darwin_nocgo.go
deleted file mode 100644
index 242b4a8..0000000
--- a/vendor/github.com/shirou/gopsutil/cpu/cpu_darwin_nocgo.go
+++ /dev/null
@@ -1,14 +0,0 @@
-// +build darwin
-// +build !cgo
-
-package cpu
-
-import "github.com/shirou/gopsutil/internal/common"
-
-func perCPUTimes() ([]TimesStat, error) {
- return []TimesStat{}, common.ErrNotImplementedError
-}
-
-func allCPUTimes() ([]TimesStat, error) {
- return []TimesStat{}, common.ErrNotImplementedError
-}
diff --git a/vendor/github.com/shirou/gopsutil/cpu/cpu_fallback.go b/vendor/github.com/shirou/gopsutil/cpu/cpu_fallback.go
deleted file mode 100644
index e9e7ada..0000000
--- a/vendor/github.com/shirou/gopsutil/cpu/cpu_fallback.go
+++ /dev/null
@@ -1,25 +0,0 @@
-// +build !darwin,!linux,!freebsd,!openbsd,!solaris,!windows
-
-package cpu
-
-import (
- "context"
-
- "github.com/shirou/gopsutil/internal/common"
-)
-
-func Times(percpu bool) ([]TimesStat, error) {
- return TimesWithContext(context.Background(), percpu)
-}
-
-func TimesWithContext(ctx context.Context, percpu bool) ([]TimesStat, error) {
- return []TimesStat{}, common.ErrNotImplementedError
-}
-
-func Info() ([]InfoStat, error) {
- return InfoWithContext(context.Background())
-}
-
-func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
- return []InfoStat{}, common.ErrNotImplementedError
-}
diff --git a/vendor/github.com/shirou/gopsutil/cpu/cpu_freebsd.go b/vendor/github.com/shirou/gopsutil/cpu/cpu_freebsd.go
deleted file mode 100644
index b6c7186..0000000
--- a/vendor/github.com/shirou/gopsutil/cpu/cpu_freebsd.go
+++ /dev/null
@@ -1,168 +0,0 @@
-package cpu
-
-import (
- "context"
- "fmt"
- "os/exec"
- "reflect"
- "regexp"
- "strconv"
- "strings"
- "unsafe"
-
- "github.com/shirou/gopsutil/internal/common"
- "golang.org/x/sys/unix"
-)
-
-var ClocksPerSec = float64(128)
-var cpuMatch = regexp.MustCompile(`^CPU:`)
-var originMatch = regexp.MustCompile(`Origin\s*=\s*"(.+)"\s+Id\s*=\s*(.+)\s+Family\s*=\s*(.+)\s+Model\s*=\s*(.+)\s+Stepping\s*=\s*(.+)`)
-var featuresMatch = regexp.MustCompile(`Features=.+<(.+)>`)
-var featuresMatch2 = regexp.MustCompile(`Features2=[a-f\dx]+<(.+)>`)
-var cpuEnd = regexp.MustCompile(`^Trying to mount root`)
-var cpuCores = regexp.MustCompile(`FreeBSD/SMP: (\d*) package\(s\) x (\d*) core\(s\)`)
-var cpuTimesSize int
-var emptyTimes cpuTimes
-
-func init() {
- getconf, err := exec.LookPath("/usr/bin/getconf")
- if err != nil {
- return
- }
- out, err := invoke.Command(getconf, "CLK_TCK")
- // ignore errors
- if err == nil {
- i, err := strconv.ParseFloat(strings.TrimSpace(string(out)), 64)
- if err == nil {
- ClocksPerSec = float64(i)
- }
- }
-}
-
-func timeStat(name string, t *cpuTimes) *TimesStat {
- return &TimesStat{
- User: float64(t.User) / ClocksPerSec,
- Nice: float64(t.Nice) / ClocksPerSec,
- System: float64(t.Sys) / ClocksPerSec,
- Idle: float64(t.Idle) / ClocksPerSec,
- Irq: float64(t.Intr) / ClocksPerSec,
- CPU: name,
- }
-}
-
-func Times(percpu bool) ([]TimesStat, error) {
- return TimesWithContext(context.Background(), percpu)
-}
-
-func TimesWithContext(ctx context.Context, percpu bool) ([]TimesStat, error) {
- if percpu {
- buf, err := unix.SysctlRaw("kern.cp_times")
- if err != nil {
- return nil, err
- }
-
- // We can't do this in init due to the conflict with cpu.init()
- if cpuTimesSize == 0 {
- cpuTimesSize = int(reflect.TypeOf(cpuTimes{}).Size())
- }
-
- ncpus := len(buf) / cpuTimesSize
- ret := make([]TimesStat, 0, ncpus)
- for i := 0; i < ncpus; i++ {
- times := (*cpuTimes)(unsafe.Pointer(&buf[i*cpuTimesSize]))
- if *times == emptyTimes {
- // CPU not present
- continue
- }
- ret = append(ret, *timeStat(fmt.Sprintf("cpu%d", len(ret)), times))
- }
- return ret, nil
- }
-
- buf, err := unix.SysctlRaw("kern.cp_time")
- if err != nil {
- return nil, err
- }
-
- times := (*cpuTimes)(unsafe.Pointer(&buf[0]))
- return []TimesStat{*timeStat("cpu-total", times)}, nil
-}
-
-// Returns only one InfoStat on FreeBSD. The information regarding core
-// count, however is accurate and it is assumed that all InfoStat attributes
-// are the same across CPUs.
-func Info() ([]InfoStat, error) {
- return InfoWithContext(context.Background())
-}
-
-func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
- const dmesgBoot = "/var/run/dmesg.boot"
-
- c, num, err := parseDmesgBoot(dmesgBoot)
- if err != nil {
- return nil, err
- }
-
- var u32 uint32
- if u32, err = unix.SysctlUint32("hw.clockrate"); err != nil {
- return nil, err
- }
- c.Mhz = float64(u32)
-
- if u32, err = unix.SysctlUint32("hw.ncpu"); err != nil {
- return nil, err
- }
- c.Cores = int32(u32)
-
- if c.ModelName, err = unix.Sysctl("hw.model"); err != nil {
- return nil, err
- }
-
- ret := make([]InfoStat, num)
- for i := 0; i < num; i++ {
- ret[i] = c
- }
-
- return ret, nil
-}
-
-func parseDmesgBoot(fileName string) (InfoStat, int, error) {
- c := InfoStat{}
- lines, _ := common.ReadLines(fileName)
- cpuNum := 1 // default cpu num is 1
- for _, line := range lines {
- if matches := cpuEnd.FindStringSubmatch(line); matches != nil {
- break
- } else if matches := originMatch.FindStringSubmatch(line); matches != nil {
- c.VendorID = matches[1]
- c.Family = matches[3]
- c.Model = matches[4]
- t, err := strconv.ParseInt(matches[5], 10, 32)
- if err != nil {
- return c, 0, fmt.Errorf("unable to parse FreeBSD CPU stepping information from %q: %v", line, err)
- }
- c.Stepping = int32(t)
- } else if matches := featuresMatch.FindStringSubmatch(line); matches != nil {
- for _, v := range strings.Split(matches[1], ",") {
- c.Flags = append(c.Flags, strings.ToLower(v))
- }
- } else if matches := featuresMatch2.FindStringSubmatch(line); matches != nil {
- for _, v := range strings.Split(matches[1], ",") {
- c.Flags = append(c.Flags, strings.ToLower(v))
- }
- } else if matches := cpuCores.FindStringSubmatch(line); matches != nil {
- t, err := strconv.ParseInt(matches[1], 10, 32)
- if err != nil {
- return c, 0, fmt.Errorf("unable to parse FreeBSD CPU Nums from %q: %v", line, err)
- }
- cpuNum = int(t)
- t2, err := strconv.ParseInt(matches[2], 10, 32)
- if err != nil {
- return c, 0, fmt.Errorf("unable to parse FreeBSD CPU cores from %q: %v", line, err)
- }
- c.Cores = int32(t2)
- }
- }
-
- return c, cpuNum, nil
-}
diff --git a/vendor/github.com/shirou/gopsutil/cpu/cpu_freebsd_386.go b/vendor/github.com/shirou/gopsutil/cpu/cpu_freebsd_386.go
deleted file mode 100644
index 8b7f4c3..0000000
--- a/vendor/github.com/shirou/gopsutil/cpu/cpu_freebsd_386.go
+++ /dev/null
@@ -1,9 +0,0 @@
-package cpu
-
-type cpuTimes struct {
- User uint32
- Nice uint32
- Sys uint32
- Intr uint32
- Idle uint32
-}
diff --git a/vendor/github.com/shirou/gopsutil/cpu/cpu_freebsd_amd64.go b/vendor/github.com/shirou/gopsutil/cpu/cpu_freebsd_amd64.go
deleted file mode 100644
index 57e1452..0000000
--- a/vendor/github.com/shirou/gopsutil/cpu/cpu_freebsd_amd64.go
+++ /dev/null
@@ -1,9 +0,0 @@
-package cpu
-
-type cpuTimes struct {
- User uint64
- Nice uint64
- Sys uint64
- Intr uint64
- Idle uint64
-}
diff --git a/vendor/github.com/shirou/gopsutil/cpu/cpu_linux.go b/vendor/github.com/shirou/gopsutil/cpu/cpu_linux.go
deleted file mode 100644
index 23b0952..0000000
--- a/vendor/github.com/shirou/gopsutil/cpu/cpu_linux.go
+++ /dev/null
@@ -1,285 +0,0 @@
-// +build linux
-
-package cpu
-
-import (
- "context"
- "errors"
- "fmt"
- "os/exec"
- "strconv"
- "strings"
-
- "github.com/shirou/gopsutil/internal/common"
-)
-
-var cpu_tick = float64(100)
-
-func init() {
- getconf, err := exec.LookPath("/usr/bin/getconf")
- if err != nil {
- return
- }
- out, err := invoke.CommandWithContext(context.Background(), getconf, "CLK_TCK")
- // ignore errors
- if err == nil {
- i, err := strconv.ParseFloat(strings.TrimSpace(string(out)), 64)
- if err == nil {
- cpu_tick = float64(i)
- }
- }
-}
-
-func Times(percpu bool) ([]TimesStat, error) {
- return TimesWithContext(context.Background(), percpu)
-}
-
-func TimesWithContext(ctx context.Context, percpu bool) ([]TimesStat, error) {
- filename := common.HostProc("stat")
- var lines = []string{}
- if percpu {
- statlines, err := common.ReadLines(filename)
- if err != nil || len(statlines) < 2 {
- return []TimesStat{}, nil
- }
- for _, line := range statlines[1:] {
- if !strings.HasPrefix(line, "cpu") {
- break
- }
- lines = append(lines, line)
- }
- } else {
- lines, _ = common.ReadLinesOffsetN(filename, 0, 1)
- }
-
- ret := make([]TimesStat, 0, len(lines))
-
- for _, line := range lines {
- ct, err := parseStatLine(line)
- if err != nil {
- continue
- }
- ret = append(ret, *ct)
-
- }
- return ret, nil
-}
-
-func sysCPUPath(cpu int32, relPath string) string {
- return common.HostSys(fmt.Sprintf("devices/system/cpu/cpu%d", cpu), relPath)
-}
-
-func finishCPUInfo(c *InfoStat) error {
- var lines []string
- var err error
- var value float64
-
- if len(c.CoreID) == 0 {
- lines, err = common.ReadLines(sysCPUPath(c.CPU, "topology/core_id"))
- if err == nil {
- c.CoreID = lines[0]
- }
- }
-
- // override the value of c.Mhz with cpufreq/cpuinfo_max_freq regardless
- // of the value from /proc/cpuinfo because we want to report the maximum
- // clock-speed of the CPU for c.Mhz, matching the behaviour of Windows
- lines, err = common.ReadLines(sysCPUPath(c.CPU, "cpufreq/cpuinfo_max_freq"))
- // if we encounter errors below such as there are no cpuinfo_max_freq file,
- // we just ignore. so let Mhz is 0.
- if err != nil {
- return nil
- }
- value, err = strconv.ParseFloat(lines[0], 64)
- if err != nil {
- return nil
- }
- c.Mhz = value / 1000.0 // value is in kHz
- if c.Mhz > 9999 {
- c.Mhz = c.Mhz / 1000.0 // value in Hz
- }
- return nil
-}
-
-// CPUInfo on linux will return 1 item per physical thread.
-//
-// CPUs have three levels of counting: sockets, cores, threads.
-// Cores with HyperThreading count as having 2 threads per core.
-// Sockets often come with many physical CPU cores.
-// For example a single socket board with two cores each with HT will
-// return 4 CPUInfoStat structs on Linux and the "Cores" field set to 1.
-func Info() ([]InfoStat, error) {
- return InfoWithContext(context.Background())
-}
-
-func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
- filename := common.HostProc("cpuinfo")
- lines, _ := common.ReadLines(filename)
-
- var ret []InfoStat
- var processorName string
-
- c := InfoStat{CPU: -1, Cores: 1}
- for _, line := range lines {
- fields := strings.Split(line, ":")
- if len(fields) < 2 {
- continue
- }
- key := strings.TrimSpace(fields[0])
- value := strings.TrimSpace(fields[1])
-
- switch key {
- case "Processor":
- processorName = value
- case "processor":
- if c.CPU >= 0 {
- err := finishCPUInfo(&c)
- if err != nil {
- return ret, err
- }
- ret = append(ret, c)
- }
- c = InfoStat{Cores: 1, ModelName: processorName}
- t, err := strconv.ParseInt(value, 10, 64)
- if err != nil {
- return ret, err
- }
- c.CPU = int32(t)
- case "vendorId", "vendor_id":
- c.VendorID = value
- case "cpu family":
- c.Family = value
- case "model":
- c.Model = value
- case "model name", "cpu":
- c.ModelName = value
- if strings.Contains(value, "POWER8") ||
- strings.Contains(value, "POWER7") {
- c.Model = strings.Split(value, " ")[0]
- c.Family = "POWER"
- c.VendorID = "IBM"
- }
- case "stepping", "revision":
- val := value
-
- if key == "revision" {
- val = strings.Split(value, ".")[0]
- }
-
- t, err := strconv.ParseInt(val, 10, 64)
- if err != nil {
- return ret, err
- }
- c.Stepping = int32(t)
- case "cpu MHz", "clock":
- // treat this as the fallback value, thus we ignore error
- if t, err := strconv.ParseFloat(strings.Replace(value, "MHz", "", 1), 64); err == nil {
- c.Mhz = t
- }
- case "cache size":
- t, err := strconv.ParseInt(strings.Replace(value, " KB", "", 1), 10, 64)
- if err != nil {
- return ret, err
- }
- c.CacheSize = int32(t)
- case "physical id":
- c.PhysicalID = value
- case "core id":
- c.CoreID = value
- case "flags", "Features":
- c.Flags = strings.FieldsFunc(value, func(r rune) bool {
- return r == ',' || r == ' '
- })
- case "microcode":
- c.Microcode = value
- }
- }
- if c.CPU >= 0 {
- err := finishCPUInfo(&c)
- if err != nil {
- return ret, err
- }
- ret = append(ret, c)
- }
- return ret, nil
-}
-
-func parseStatLine(line string) (*TimesStat, error) {
- fields := strings.Fields(line)
-
- if len(fields) == 0 {
- return nil, errors.New("stat does not contain cpu info")
- }
-
- if strings.HasPrefix(fields[0], "cpu") == false {
- // return CPUTimesStat{}, e
- return nil, errors.New("not contain cpu")
- }
-
- cpu := fields[0]
- if cpu == "cpu" {
- cpu = "cpu-total"
- }
- user, err := strconv.ParseFloat(fields[1], 64)
- if err != nil {
- return nil, err
- }
- nice, err := strconv.ParseFloat(fields[2], 64)
- if err != nil {
- return nil, err
- }
- system, err := strconv.ParseFloat(fields[3], 64)
- if err != nil {
- return nil, err
- }
- idle, err := strconv.ParseFloat(fields[4], 64)
- if err != nil {
- return nil, err
- }
- iowait, err := strconv.ParseFloat(fields[5], 64)
- if err != nil {
- return nil, err
- }
- irq, err := strconv.ParseFloat(fields[6], 64)
- if err != nil {
- return nil, err
- }
- softirq, err := strconv.ParseFloat(fields[7], 64)
- if err != nil {
- return nil, err
- }
-
- ct := &TimesStat{
- CPU: cpu,
- User: float64(user) / cpu_tick,
- Nice: float64(nice) / cpu_tick,
- System: float64(system) / cpu_tick,
- Idle: float64(idle) / cpu_tick,
- Iowait: float64(iowait) / cpu_tick,
- Irq: float64(irq) / cpu_tick,
- Softirq: float64(softirq) / cpu_tick,
- }
- if len(fields) > 8 { // Linux >= 2.6.11
- steal, err := strconv.ParseFloat(fields[8], 64)
- if err != nil {
- return nil, err
- }
- ct.Steal = float64(steal) / cpu_tick
- }
- if len(fields) > 9 { // Linux >= 2.6.24
- guest, err := strconv.ParseFloat(fields[9], 64)
- if err != nil {
- return nil, err
- }
- ct.Guest = float64(guest) / cpu_tick
- }
- if len(fields) > 10 { // Linux >= 3.2.0
- guestNice, err := strconv.ParseFloat(fields[10], 64)
- if err != nil {
- return nil, err
- }
- ct.GuestNice = float64(guestNice) / cpu_tick
- }
-
- return ct, nil
-}
diff --git a/vendor/github.com/shirou/gopsutil/cpu/cpu_openbsd.go b/vendor/github.com/shirou/gopsutil/cpu/cpu_openbsd.go
deleted file mode 100644
index 82b920f..0000000
--- a/vendor/github.com/shirou/gopsutil/cpu/cpu_openbsd.go
+++ /dev/null
@@ -1,119 +0,0 @@
-// +build openbsd
-
-package cpu
-
-import (
- "bytes"
- "context"
- "encoding/binary"
- "fmt"
- "os/exec"
- "strconv"
- "strings"
-
- "github.com/shirou/gopsutil/internal/common"
- "golang.org/x/sys/unix"
-)
-
-// sys/sched.h
-const (
- CPUser = 0
- CPNice = 1
- CPSys = 2
- CPIntr = 3
- CPIdle = 4
- CPUStates = 5
-)
-
-// sys/sysctl.h
-const (
- CTLKern = 1 // "high kernel": proc, limits
- KernCptime = 40 // KERN_CPTIME
- KernCptime2 = 71 // KERN_CPTIME2
-)
-
-var ClocksPerSec = float64(128)
-
-func init() {
- getconf, err := exec.LookPath("/usr/bin/getconf")
- if err != nil {
- return
- }
- out, err := invoke.Command(getconf, "CLK_TCK")
- // ignore errors
- if err == nil {
- i, err := strconv.ParseFloat(strings.TrimSpace(string(out)), 64)
- if err == nil {
- ClocksPerSec = float64(i)
- }
- }
-}
-
-func Times(percpu bool) ([]TimesStat, error) {
- return TimesWithContext(context.Background(), percpu)
-}
-
-func TimesWithContext(ctx context.Context, percpu bool) ([]TimesStat, error) {
- var ret []TimesStat
-
- var ncpu int
- if percpu {
- ncpu, _ = Counts(true)
- } else {
- ncpu = 1
- }
-
- for i := 0; i < ncpu; i++ {
- var cpuTimes [CPUStates]int64
- var mib []int32
- if percpu {
- mib = []int32{CTLKern, KernCptime}
- } else {
- mib = []int32{CTLKern, KernCptime2, int32(i)}
- }
- buf, _, err := common.CallSyscall(mib)
- if err != nil {
- return ret, err
- }
-
- br := bytes.NewReader(buf)
- err = binary.Read(br, binary.LittleEndian, &cpuTimes)
- if err != nil {
- return ret, err
- }
- c := TimesStat{
- User: float64(cpuTimes[CPUser]) / ClocksPerSec,
- Nice: float64(cpuTimes[CPNice]) / ClocksPerSec,
- System: float64(cpuTimes[CPSys]) / ClocksPerSec,
- Idle: float64(cpuTimes[CPIdle]) / ClocksPerSec,
- Irq: float64(cpuTimes[CPIntr]) / ClocksPerSec,
- }
- if !percpu {
- c.CPU = "cpu-total"
- } else {
- c.CPU = fmt.Sprintf("cpu%d", i)
- }
- ret = append(ret, c)
- }
-
- return ret, nil
-}
-
-// Returns only one (minimal) CPUInfoStat on OpenBSD
-func Info() ([]InfoStat, error) {
- return InfoWithContext(context.Background())
-}
-
-func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
- var ret []InfoStat
-
- c := InfoStat{}
-
- v, err := unix.Sysctl("hw.model")
- if err != nil {
- return nil, err
- }
- c.ModelName = v
-
- return append(ret, c), nil
-}
diff --git a/vendor/github.com/shirou/gopsutil/cpu/cpu_solaris.go b/vendor/github.com/shirou/gopsutil/cpu/cpu_solaris.go
deleted file mode 100644
index 117fd90..0000000
--- a/vendor/github.com/shirou/gopsutil/cpu/cpu_solaris.go
+++ /dev/null
@@ -1,198 +0,0 @@
-package cpu
-
-import (
- "context"
- "errors"
- "fmt"
- "os/exec"
- "regexp"
- "sort"
- "strconv"
- "strings"
-
- "github.com/shirou/gopsutil/internal/common"
-)
-
-var ClocksPerSec = float64(128)
-
-func init() {
- getconf, err := exec.LookPath("/usr/bin/getconf")
- if err != nil {
- return
- }
- out, err := invoke.Command(getconf, "CLK_TCK")
- // ignore errors
- if err == nil {
- i, err := strconv.ParseFloat(strings.TrimSpace(string(out)), 64)
- if err == nil {
- ClocksPerSec = float64(i)
- }
- }
-}
-
-func Times(percpu bool) ([]TimesStat, error) {
- return TimesWithContext(context.Background(), percpu)
-}
-
-func TimesWithContext(ctx context.Context, percpu bool) ([]TimesStat, error) {
- return []TimesStat{}, common.ErrNotImplementedError
-}
-
-func Info() ([]InfoStat, error) {
- return InfoWithContext(context.Background())
-}
-
-func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
- psrInfo, err := exec.LookPath("/usr/sbin/psrinfo")
- if err != nil {
- return nil, fmt.Errorf("cannot find psrinfo: %s", err)
- }
- psrInfoOut, err := invoke.CommandWithContext(ctx, psrInfo, "-p", "-v")
- if err != nil {
- return nil, fmt.Errorf("cannot execute psrinfo: %s", err)
- }
-
- isaInfo, err := exec.LookPath("/usr/bin/isainfo")
- if err != nil {
- return nil, fmt.Errorf("cannot find isainfo: %s", err)
- }
- isaInfoOut, err := invoke.CommandWithContext(ctx, isaInfo, "-b", "-v")
- if err != nil {
- return nil, fmt.Errorf("cannot execute isainfo: %s", err)
- }
-
- procs, err := parseProcessorInfo(string(psrInfoOut))
- if err != nil {
- return nil, fmt.Errorf("error parsing psrinfo output: %s", err)
- }
-
- flags, err := parseISAInfo(string(isaInfoOut))
- if err != nil {
- return nil, fmt.Errorf("error parsing isainfo output: %s", err)
- }
-
- result := make([]InfoStat, 0, len(flags))
- for _, proc := range procs {
- procWithFlags := proc
- procWithFlags.Flags = flags
- result = append(result, procWithFlags)
- }
-
- return result, nil
-}
-
-var flagsMatch = regexp.MustCompile(`[\w\.]+`)
-
-func parseISAInfo(cmdOutput string) ([]string, error) {
- words := flagsMatch.FindAllString(cmdOutput, -1)
-
- // Sanity check the output
- if len(words) < 4 || words[1] != "bit" || words[3] != "applications" {
- return nil, errors.New("attempted to parse invalid isainfo output")
- }
-
- flags := make([]string, len(words)-4)
- for i, val := range words[4:] {
- flags[i] = val
- }
- sort.Strings(flags)
-
- return flags, nil
-}
-
-var psrInfoMatch = regexp.MustCompile(`The physical processor has (?:([\d]+) virtual processor \(([\d]+)\)|([\d]+) cores and ([\d]+) virtual processors[^\n]+)\n(?:\s+ The core has.+\n)*\s+.+ \((\w+) ([\S]+) family (.+) model (.+) step (.+) clock (.+) MHz\)\n[\s]*(.*)`)
-
-const (
- psrNumCoresOffset = 1
- psrNumCoresHTOffset = 3
- psrNumHTOffset = 4
- psrVendorIDOffset = 5
- psrFamilyOffset = 7
- psrModelOffset = 8
- psrStepOffset = 9
- psrClockOffset = 10
- psrModelNameOffset = 11
-)
-
-func parseProcessorInfo(cmdOutput string) ([]InfoStat, error) {
- matches := psrInfoMatch.FindAllStringSubmatch(cmdOutput, -1)
-
- var infoStatCount int32
- result := make([]InfoStat, 0, len(matches))
- for physicalIndex, physicalCPU := range matches {
- var step int32
- var clock float64
-
- if physicalCPU[psrStepOffset] != "" {
- stepParsed, err := strconv.ParseInt(physicalCPU[psrStepOffset], 10, 32)
- if err != nil {
- return nil, fmt.Errorf("cannot parse value %q for step as 32-bit integer: %s", physicalCPU[9], err)
- }
- step = int32(stepParsed)
- }
-
- if physicalCPU[psrClockOffset] != "" {
- clockParsed, err := strconv.ParseInt(physicalCPU[psrClockOffset], 10, 64)
- if err != nil {
- return nil, fmt.Errorf("cannot parse value %q for clock as 32-bit integer: %s", physicalCPU[10], err)
- }
- clock = float64(clockParsed)
- }
-
- var err error
- var numCores int64
- var numHT int64
- switch {
- case physicalCPU[psrNumCoresOffset] != "":
- numCores, err = strconv.ParseInt(physicalCPU[psrNumCoresOffset], 10, 32)
- if err != nil {
- return nil, fmt.Errorf("cannot parse value %q for core count as 32-bit integer: %s", physicalCPU[1], err)
- }
-
- for i := 0; i < int(numCores); i++ {
- result = append(result, InfoStat{
- CPU: infoStatCount,
- PhysicalID: strconv.Itoa(physicalIndex),
- CoreID: strconv.Itoa(i),
- Cores: 1,
- VendorID: physicalCPU[psrVendorIDOffset],
- ModelName: physicalCPU[psrModelNameOffset],
- Family: physicalCPU[psrFamilyOffset],
- Model: physicalCPU[psrModelOffset],
- Stepping: step,
- Mhz: clock,
- })
- infoStatCount++
- }
- case physicalCPU[psrNumCoresHTOffset] != "":
- numCores, err = strconv.ParseInt(physicalCPU[psrNumCoresHTOffset], 10, 32)
- if err != nil {
- return nil, fmt.Errorf("cannot parse value %q for core count as 32-bit integer: %s", physicalCPU[3], err)
- }
-
- numHT, err = strconv.ParseInt(physicalCPU[psrNumHTOffset], 10, 32)
- if err != nil {
- return nil, fmt.Errorf("cannot parse value %q for hyperthread count as 32-bit integer: %s", physicalCPU[4], err)
- }
-
- for i := 0; i < int(numCores); i++ {
- result = append(result, InfoStat{
- CPU: infoStatCount,
- PhysicalID: strconv.Itoa(physicalIndex),
- CoreID: strconv.Itoa(i),
- Cores: int32(numHT) / int32(numCores),
- VendorID: physicalCPU[psrVendorIDOffset],
- ModelName: physicalCPU[psrModelNameOffset],
- Family: physicalCPU[psrFamilyOffset],
- Model: physicalCPU[psrModelOffset],
- Stepping: step,
- Mhz: clock,
- })
- infoStatCount++
- }
- default:
- return nil, errors.New("values for cores with and without hyperthreading are both set")
- }
- }
- return result, nil
-}
diff --git a/vendor/github.com/shirou/gopsutil/cpu/cpu_windows.go b/vendor/github.com/shirou/gopsutil/cpu/cpu_windows.go
deleted file mode 100644
index 8aa691c..0000000
--- a/vendor/github.com/shirou/gopsutil/cpu/cpu_windows.go
+++ /dev/null
@@ -1,172 +0,0 @@
-// +build windows
-
-package cpu
-
-import (
- "context"
- "fmt"
- "unsafe"
-
- "github.com/StackExchange/wmi"
- "github.com/shirou/gopsutil/internal/common"
- "golang.org/x/sys/windows"
-)
-
-type Win32_Processor struct {
- LoadPercentage *uint16
- Family uint16
- Manufacturer string
- Name string
- NumberOfLogicalProcessors uint32
- ProcessorID *string
- Stepping *string
- MaxClockSpeed uint32
-}
-
-// Win32_PerfFormattedData_Counters_ProcessorInformation stores instance value of the perf counters
-type Win32_PerfFormattedData_Counters_ProcessorInformation struct {
- Name string
- PercentDPCTime uint64
- PercentIdleTime uint64
- PercentUserTime uint64
- PercentProcessorTime uint64
- PercentInterruptTime uint64
- PercentPriorityTime uint64
- PercentPrivilegedTime uint64
- InterruptsPerSec uint32
- ProcessorFrequency uint32
- DPCRate uint32
-}
-
-// Win32_PerfFormattedData_PerfOS_System struct to have count of processes and processor queue length
-type Win32_PerfFormattedData_PerfOS_System struct {
- Processes uint32
- ProcessorQueueLength uint32
-}
-
-// Times returns times stat per cpu and combined for all CPUs
-func Times(percpu bool) ([]TimesStat, error) {
- return TimesWithContext(context.Background(), percpu)
-}
-
-func TimesWithContext(ctx context.Context, percpu bool) ([]TimesStat, error) {
- if percpu {
- return perCPUTimes()
- }
-
- var ret []TimesStat
- var lpIdleTime common.FILETIME
- var lpKernelTime common.FILETIME
- var lpUserTime common.FILETIME
- r, _, _ := common.ProcGetSystemTimes.Call(
- uintptr(unsafe.Pointer(&lpIdleTime)),
- uintptr(unsafe.Pointer(&lpKernelTime)),
- uintptr(unsafe.Pointer(&lpUserTime)))
- if r == 0 {
- return ret, windows.GetLastError()
- }
-
- LOT := float64(0.0000001)
- HIT := (LOT * 4294967296.0)
- idle := ((HIT * float64(lpIdleTime.DwHighDateTime)) + (LOT * float64(lpIdleTime.DwLowDateTime)))
- user := ((HIT * float64(lpUserTime.DwHighDateTime)) + (LOT * float64(lpUserTime.DwLowDateTime)))
- kernel := ((HIT * float64(lpKernelTime.DwHighDateTime)) + (LOT * float64(lpKernelTime.DwLowDateTime)))
- system := (kernel - idle)
-
- ret = append(ret, TimesStat{
- CPU: "cpu-total",
- Idle: float64(idle),
- User: float64(user),
- System: float64(system),
- })
- return ret, nil
-}
-
-func Info() ([]InfoStat, error) {
- return InfoWithContext(context.Background())
-}
-
-func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
- var ret []InfoStat
- var dst []Win32_Processor
- q := wmi.CreateQuery(&dst, "")
- if err := common.WMIQueryWithContext(ctx, q, &dst); err != nil {
- return ret, err
- }
-
- var procID string
- for i, l := range dst {
- procID = ""
- if l.ProcessorID != nil {
- procID = *l.ProcessorID
- }
-
- cpu := InfoStat{
- CPU: int32(i),
- Family: fmt.Sprintf("%d", l.Family),
- VendorID: l.Manufacturer,
- ModelName: l.Name,
- Cores: int32(l.NumberOfLogicalProcessors),
- PhysicalID: procID,
- Mhz: float64(l.MaxClockSpeed),
- Flags: []string{},
- }
- ret = append(ret, cpu)
- }
-
- return ret, nil
-}
-
-// PerfInfo returns the performance counter's instance value for ProcessorInformation.
-// Name property is the key by which overall, per cpu and per core metric is known.
-func PerfInfo() ([]Win32_PerfFormattedData_Counters_ProcessorInformation, error) {
- return PerfInfoWithContext(context.Background())
-}
-
-func PerfInfoWithContext(ctx context.Context) ([]Win32_PerfFormattedData_Counters_ProcessorInformation, error) {
- var ret []Win32_PerfFormattedData_Counters_ProcessorInformation
-
- q := wmi.CreateQuery(&ret, "")
- err := common.WMIQueryWithContext(ctx, q, &ret)
- if err != nil {
- return []Win32_PerfFormattedData_Counters_ProcessorInformation{}, err
- }
-
- return ret, err
-}
-
-// ProcInfo returns processes count and processor queue length in the system.
-// There is a single queue for processor even on multiprocessors systems.
-func ProcInfo() ([]Win32_PerfFormattedData_PerfOS_System, error) {
- return ProcInfoWithContext(context.Background())
-}
-
-func ProcInfoWithContext(ctx context.Context) ([]Win32_PerfFormattedData_PerfOS_System, error) {
- var ret []Win32_PerfFormattedData_PerfOS_System
- q := wmi.CreateQuery(&ret, "")
- err := common.WMIQueryWithContext(ctx, q, &ret)
- if err != nil {
- return []Win32_PerfFormattedData_PerfOS_System{}, err
- }
- return ret, err
-}
-
-// perCPUTimes returns times stat per cpu, per core and overall for all CPUs
-func perCPUTimes() ([]TimesStat, error) {
- var ret []TimesStat
- stats, err := PerfInfo()
- if err != nil {
- return nil, err
- }
- for _, v := range stats {
- c := TimesStat{
- CPU: v.Name,
- User: float64(v.PercentUserTime),
- System: float64(v.PercentPrivilegedTime),
- Idle: float64(v.PercentIdleTime),
- Irq: float64(v.PercentInterruptTime),
- }
- ret = append(ret, c)
- }
- return ret, nil
-}
diff --git a/vendor/github.com/shirou/gopsutil/disk/disk.go b/vendor/github.com/shirou/gopsutil/disk/disk.go
deleted file mode 100644
index 38d8a8f..0000000
--- a/vendor/github.com/shirou/gopsutil/disk/disk.go
+++ /dev/null
@@ -1,61 +0,0 @@
-package disk
-
-import (
- "encoding/json"
-
- "github.com/shirou/gopsutil/internal/common"
-)
-
-var invoke common.Invoker = common.Invoke{}
-
-type UsageStat struct {
- Path string `json:"path"`
- Fstype string `json:"fstype"`
- Total uint64 `json:"total"`
- Free uint64 `json:"free"`
- Used uint64 `json:"used"`
- UsedPercent float64 `json:"usedPercent"`
- InodesTotal uint64 `json:"inodesTotal"`
- InodesUsed uint64 `json:"inodesUsed"`
- InodesFree uint64 `json:"inodesFree"`
- InodesUsedPercent float64 `json:"inodesUsedPercent"`
-}
-
-type PartitionStat struct {
- Device string `json:"device"`
- Mountpoint string `json:"mountpoint"`
- Fstype string `json:"fstype"`
- Opts string `json:"opts"`
-}
-
-type IOCountersStat struct {
- ReadCount uint64 `json:"readCount"`
- MergedReadCount uint64 `json:"mergedReadCount"`
- WriteCount uint64 `json:"writeCount"`
- MergedWriteCount uint64 `json:"mergedWriteCount"`
- ReadBytes uint64 `json:"readBytes"`
- WriteBytes uint64 `json:"writeBytes"`
- ReadTime uint64 `json:"readTime"`
- WriteTime uint64 `json:"writeTime"`
- IopsInProgress uint64 `json:"iopsInProgress"`
- IoTime uint64 `json:"ioTime"`
- WeightedIO uint64 `json:"weightedIO"`
- Name string `json:"name"`
- SerialNumber string `json:"serialNumber"`
- Label string `json:"label"`
-}
-
-func (d UsageStat) String() string {
- s, _ := json.Marshal(d)
- return string(s)
-}
-
-func (d PartitionStat) String() string {
- s, _ := json.Marshal(d)
- return string(s)
-}
-
-func (d IOCountersStat) String() string {
- s, _ := json.Marshal(d)
- return string(s)
-}
diff --git a/vendor/github.com/shirou/gopsutil/disk/disk_darwin.go b/vendor/github.com/shirou/gopsutil/disk/disk_darwin.go
deleted file mode 100644
index 2b1d000..0000000
--- a/vendor/github.com/shirou/gopsutil/disk/disk_darwin.go
+++ /dev/null
@@ -1,118 +0,0 @@
-// +build darwin
-
-package disk
-
-import (
- "context"
- "path"
- "unsafe"
-
- "github.com/shirou/gopsutil/internal/common"
- "golang.org/x/sys/unix"
-)
-
-func Partitions(all bool) ([]PartitionStat, error) {
- return PartitionsWithContext(context.Background(), all)
-}
-
-func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, error) {
- var ret []PartitionStat
-
- count, err := Getfsstat(nil, MntWait)
- if err != nil {
- return ret, err
- }
- fs := make([]Statfs, count)
- if _, err = Getfsstat(fs, MntWait); err != nil {
- return ret, err
- }
- for _, stat := range fs {
- opts := "rw"
- if stat.Flags&MntReadOnly != 0 {
- opts = "ro"
- }
- if stat.Flags&MntSynchronous != 0 {
- opts += ",sync"
- }
- if stat.Flags&MntNoExec != 0 {
- opts += ",noexec"
- }
- if stat.Flags&MntNoSuid != 0 {
- opts += ",nosuid"
- }
- if stat.Flags&MntUnion != 0 {
- opts += ",union"
- }
- if stat.Flags&MntAsync != 0 {
- opts += ",async"
- }
- if stat.Flags&MntSuidDir != 0 {
- opts += ",suiddir"
- }
- if stat.Flags&MntSoftDep != 0 {
- opts += ",softdep"
- }
- if stat.Flags&MntNoSymFollow != 0 {
- opts += ",nosymfollow"
- }
- if stat.Flags&MntGEOMJournal != 0 {
- opts += ",gjounalc"
- }
- if stat.Flags&MntMultilabel != 0 {
- opts += ",multilabel"
- }
- if stat.Flags&MntACLs != 0 {
- opts += ",acls"
- }
- if stat.Flags&MntNoATime != 0 {
- opts += ",noattime"
- }
- if stat.Flags&MntClusterRead != 0 {
- opts += ",nocluster"
- }
- if stat.Flags&MntClusterWrite != 0 {
- opts += ",noclusterw"
- }
- if stat.Flags&MntNFS4ACLs != 0 {
- opts += ",nfs4acls"
- }
- d := PartitionStat{
- Device: common.IntToString(stat.Mntfromname[:]),
- Mountpoint: common.IntToString(stat.Mntonname[:]),
- Fstype: common.IntToString(stat.Fstypename[:]),
- Opts: opts,
- }
- if all == false {
- if !path.IsAbs(d.Device) || !common.PathExists(d.Device) {
- continue
- }
- }
-
- ret = append(ret, d)
- }
-
- return ret, nil
-}
-
-func Getfsstat(buf []Statfs, flags int) (n int, err error) {
- return GetfsstatWithContext(context.Background(), buf, flags)
-}
-
-func GetfsstatWithContext(ctx context.Context, buf []Statfs, flags int) (n int, err error) {
- var _p0 unsafe.Pointer
- var bufsize uintptr
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- bufsize = unsafe.Sizeof(Statfs{}) * uintptr(len(buf))
- }
- r0, _, e1 := unix.Syscall(SYS_GETFSSTAT64, uintptr(_p0), bufsize, uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func getFsType(stat unix.Statfs_t) string {
- return common.IntToString(stat.Fstypename[:])
-}
diff --git a/vendor/github.com/shirou/gopsutil/disk/disk_darwin.h b/vendor/github.com/shirou/gopsutil/disk/disk_darwin.h
deleted file mode 100644
index d0fe514..0000000
--- a/vendor/github.com/shirou/gopsutil/disk/disk_darwin.h
+++ /dev/null
@@ -1,164 +0,0 @@
-#include
-#include
-#include
-#include
-#include
-
-// The iterator of all things disk. Allocated by StartIOCounterFetch, released
-// by EndIOCounterFetch.
-static io_iterator_t diskIter;
-
-// Begins fetching IO counters.
-//
-// Returns 1 if the fetch started successfully, false otherwise.
-//
-// If the fetch was started successfully, you must call EndIOCounterFetch once
-// done to release resources.
-int StartIOCounterFetch()
-{
- if (IOServiceGetMatchingServices(kIOMasterPortDefault,
- IOServiceMatching(kIOMediaClass),
- &diskIter) != kIOReturnSuccess) {
- return 0;
- }
-
- return 1;
-}
-
-// Releases resources from fetching IO counters.
-void EndIOCounterFetch()
-{
- IOObjectRelease(diskIter);
-}
-
-// The current disk entry of interest. Allocated by FetchNextDisk(), released by
-// ReadDiskInfo().
-static io_registry_entry_t diskEntry;
-
-// The parent of diskEntry. Same lifetimes.
-static io_registry_entry_t parentEntry;
-
-// Fetches the next disk. Note that a disk entry is allocated, and will be held
-// until it is processed and freed by ReadDiskInfo.
-int FetchNextDisk()
-{
- while ((diskEntry = IOIteratorNext(diskIter)) != 0) {
- // We are iterating IOMedia. We need to get the parent too (IOBSD).
- if (IORegistryEntryGetParentEntry(diskEntry, kIOServicePlane, &parentEntry) != kIOReturnSuccess) {
- // something is wrong...
- IOObjectRelease(diskEntry);
- continue;
- }
-
- if (!IOObjectConformsTo(parentEntry, "IOBlockStorageDriver")) {
- // no use to us, try the next disk
- IOObjectRelease(diskEntry);
- IOObjectRelease(parentEntry);
- continue;
- }
-
- // Got a disk OK.
- return 1;
- }
-
- // No more disks.
- return 0;
-}
-
-// Reads the current disk (from iteration) info into DiskInfo struct.
-// Once done, all resources from the current iteration of reading are freed,
-// ready for FetchNextDisk() to be called again.
-int ReadDiskInfo(DiskInfo *info)
-{
- // Parent props. Allocated by us.
- CFDictionaryRef parentProps = NULL;
-
- // Disk props. Allocated by us.
- CFDictionaryRef diskProps = NULL;
-
- // Disk stats, fetched by us, but not allocated by us.
- CFDictionaryRef stats = NULL;
-
- if (IORegistryEntryCreateCFProperties(diskEntry, (CFMutableDictionaryRef *)&parentProps,
- kCFAllocatorDefault, kNilOptions) != kIOReturnSuccess)
- {
- // can't get parent props, give up
- CFRelease(parentProps);
- IOObjectRelease(diskEntry);
- IOObjectRelease(parentEntry);
- return -1;
- }
-
- if (IORegistryEntryCreateCFProperties(parentEntry, (CFMutableDictionaryRef *)&diskProps,
- kCFAllocatorDefault, kNilOptions) != kIOReturnSuccess)
- {
- // can't get disk props, give up
- CFRelease(parentProps);
- CFRelease(diskProps);
- IOObjectRelease(diskEntry);
- IOObjectRelease(parentEntry);
- return -1;
- }
-
- // Start fetching
- CFStringRef cfDiskName = (CFStringRef)CFDictionaryGetValue(parentProps, CFSTR(kIOBSDNameKey));
- CFStringGetCString(cfDiskName, info->DiskName, MAX_DISK_NAME, CFStringGetSystemEncoding());
- stats = (CFDictionaryRef)CFDictionaryGetValue( diskProps, CFSTR(kIOBlockStorageDriverStatisticsKey));
-
- if (stats == NULL) {
- // stat fetch failed...
- CFRelease(parentProps);
- CFRelease(diskProps);
- IOObjectRelease(parentEntry);
- IOObjectRelease(diskEntry);
- return -1;
- }
-
- CFNumberRef cfnum;
-
- if ((cfnum = (CFNumberRef)CFDictionaryGetValue(stats, CFSTR(kIOBlockStorageDriverStatisticsReadsKey)))) {
- CFNumberGetValue(cfnum, kCFNumberSInt64Type, &info->Reads);
- } else {
- info->Reads = 0;
- }
-
- if ((cfnum = (CFNumberRef)CFDictionaryGetValue(stats, CFSTR(kIOBlockStorageDriverStatisticsWritesKey)))) {
- CFNumberGetValue(cfnum, kCFNumberSInt64Type, &info->Writes);
- } else {
- info->Writes = 0;
- }
-
- if ((cfnum = (CFNumberRef)CFDictionaryGetValue(stats, CFSTR(kIOBlockStorageDriverStatisticsBytesReadKey)))) {
- CFNumberGetValue(cfnum, kCFNumberSInt64Type, &info->ReadBytes);
- } else {
- info->ReadBytes = 0;
- }
-
- if ((cfnum = (CFNumberRef)CFDictionaryGetValue(stats, CFSTR(kIOBlockStorageDriverStatisticsBytesWrittenKey)))) {
- CFNumberGetValue(cfnum, kCFNumberSInt64Type, &info->WriteBytes);
- } else {
- info->WriteBytes = 0;
- }
-
- if ((cfnum = (CFNumberRef)CFDictionaryGetValue(stats, CFSTR(kIOBlockStorageDriverStatisticsTotalReadTimeKey)))) {
- CFNumberGetValue(cfnum, kCFNumberSInt64Type, &info->ReadTime);
- } else {
- info->ReadTime = 0;
- }
- if ((cfnum = (CFNumberRef)CFDictionaryGetValue(stats, CFSTR(kIOBlockStorageDriverStatisticsTotalWriteTimeKey)))) {
- CFNumberGetValue(cfnum, kCFNumberSInt64Type, &info->WriteTime);
- } else {
- info->WriteTime = 0;
- }
-
- // note: read/write time are in ns, but we want ms.
- info->ReadTime = info->ReadTime / 1000 / 1000;
- info->WriteTime = info->WriteTime / 1000 / 1000;
-
- CFRelease(parentProps);
- CFRelease(diskProps);
- IOObjectRelease(parentEntry);
- IOObjectRelease(diskEntry);
- return 0;
-}
-
diff --git a/vendor/github.com/shirou/gopsutil/disk/disk_darwin_386.go b/vendor/github.com/shirou/gopsutil/disk/disk_darwin_386.go
deleted file mode 100644
index bd83a4a..0000000
--- a/vendor/github.com/shirou/gopsutil/disk/disk_darwin_386.go
+++ /dev/null
@@ -1,59 +0,0 @@
-// +build darwin
-// +build 386
-
-package disk
-
-const (
- MntWait = 1
- MfsNameLen = 15 /* length of fs type name, not inc. nul */
- MNameLen = 90 /* length of buffer for returned name */
-
- MFSTYPENAMELEN = 16 /* length of fs type name including null */
- MAXPATHLEN = 1024
- MNAMELEN = MAXPATHLEN
-
- SYS_GETFSSTAT64 = 347
-)
-
-type Fsid struct{ val [2]int32 } /* file system id type */
-type uid_t int32
-
-// sys/mount.h
-const (
- MntReadOnly = 0x00000001 /* read only filesystem */
- MntSynchronous = 0x00000002 /* filesystem written synchronously */
- MntNoExec = 0x00000004 /* can't exec from filesystem */
- MntNoSuid = 0x00000008 /* don't honor setuid bits on fs */
- MntUnion = 0x00000020 /* union with underlying filesystem */
- MntAsync = 0x00000040 /* filesystem written asynchronously */
- MntSuidDir = 0x00100000 /* special handling of SUID on dirs */
- MntSoftDep = 0x00200000 /* soft updates being done */
- MntNoSymFollow = 0x00400000 /* do not follow symlinks */
- MntGEOMJournal = 0x02000000 /* GEOM journal support enabled */
- MntMultilabel = 0x04000000 /* MAC support for individual objects */
- MntACLs = 0x08000000 /* ACL support enabled */
- MntNoATime = 0x10000000 /* disable update of file access time */
- MntClusterRead = 0x40000000 /* disable cluster read */
- MntClusterWrite = 0x80000000 /* disable cluster write */
- MntNFS4ACLs = 0x00000010
-)
-
-// https://github.com/golang/go/blob/master/src/syscall/ztypes_darwin_386.go#L82
-type Statfs struct {
- Bsize uint32
- Iosize int32
- Blocks uint64
- Bfree uint64
- Bavail uint64
- Files uint64
- Ffree uint64
- Fsid Fsid
- Owner uint32
- Type uint32
- Flags uint32
- Fssubtype uint32
- Fstypename [16]int8
- Mntonname [1024]int8
- Mntfromname [1024]int8
- Reserved [8]uint32
-}
diff --git a/vendor/github.com/shirou/gopsutil/disk/disk_darwin_amd64.go b/vendor/github.com/shirou/gopsutil/disk/disk_darwin_amd64.go
deleted file mode 100644
index ec40a75..0000000
--- a/vendor/github.com/shirou/gopsutil/disk/disk_darwin_amd64.go
+++ /dev/null
@@ -1,58 +0,0 @@
-// +build darwin
-// +build amd64
-
-package disk
-
-const (
- MntWait = 1
- MfsNameLen = 15 /* length of fs type name, not inc. nul */
- MNameLen = 90 /* length of buffer for returned name */
-
- MFSTYPENAMELEN = 16 /* length of fs type name including null */
- MAXPATHLEN = 1024
- MNAMELEN = MAXPATHLEN
-
- SYS_GETFSSTAT64 = 347
-)
-
-type Fsid struct{ val [2]int32 } /* file system id type */
-type uid_t int32
-
-// sys/mount.h
-const (
- MntReadOnly = 0x00000001 /* read only filesystem */
- MntSynchronous = 0x00000002 /* filesystem written synchronously */
- MntNoExec = 0x00000004 /* can't exec from filesystem */
- MntNoSuid = 0x00000008 /* don't honor setuid bits on fs */
- MntUnion = 0x00000020 /* union with underlying filesystem */
- MntAsync = 0x00000040 /* filesystem written asynchronously */
- MntSuidDir = 0x00100000 /* special handling of SUID on dirs */
- MntSoftDep = 0x00200000 /* soft updates being done */
- MntNoSymFollow = 0x00400000 /* do not follow symlinks */
- MntGEOMJournal = 0x02000000 /* GEOM journal support enabled */
- MntMultilabel = 0x04000000 /* MAC support for individual objects */
- MntACLs = 0x08000000 /* ACL support enabled */
- MntNoATime = 0x10000000 /* disable update of file access time */
- MntClusterRead = 0x40000000 /* disable cluster read */
- MntClusterWrite = 0x80000000 /* disable cluster write */
- MntNFS4ACLs = 0x00000010
-)
-
-type Statfs struct {
- Bsize uint32
- Iosize int32
- Blocks uint64
- Bfree uint64
- Bavail uint64
- Files uint64
- Ffree uint64
- Fsid Fsid
- Owner uint32
- Type uint32
- Flags uint32
- Fssubtype uint32
- Fstypename [16]int8
- Mntonname [1024]int8
- Mntfromname [1024]int8
- Reserved [8]uint32
-}
diff --git a/vendor/github.com/shirou/gopsutil/disk/disk_darwin_arm64.go b/vendor/github.com/shirou/gopsutil/disk/disk_darwin_arm64.go
deleted file mode 100644
index 0e3f670..0000000
--- a/vendor/github.com/shirou/gopsutil/disk/disk_darwin_arm64.go
+++ /dev/null
@@ -1,58 +0,0 @@
-// +build darwin
-// +build arm64
-
-package disk
-
-const (
- MntWait = 1
- MfsNameLen = 15 /* length of fs type name, not inc. nul */
- MNameLen = 90 /* length of buffer for returned name */
-
- MFSTYPENAMELEN = 16 /* length of fs type name including null */
- MAXPATHLEN = 1024
- MNAMELEN = MAXPATHLEN
-
- SYS_GETFSSTAT64 = 347
-)
-
-type Fsid struct{ val [2]int32 } /* file system id type */
-type uid_t int32
-
-// sys/mount.h
-const (
- MntReadOnly = 0x00000001 /* read only filesystem */
- MntSynchronous = 0x00000002 /* filesystem written synchronously */
- MntNoExec = 0x00000004 /* can't exec from filesystem */
- MntNoSuid = 0x00000008 /* don't honor setuid bits on fs */
- MntUnion = 0x00000020 /* union with underlying filesystem */
- MntAsync = 0x00000040 /* filesystem written asynchronously */
- MntSuidDir = 0x00100000 /* special handling of SUID on dirs */
- MntSoftDep = 0x00200000 /* soft updates being done */
- MntNoSymFollow = 0x00400000 /* do not follow symlinks */
- MntGEOMJournal = 0x02000000 /* GEOM journal support enabled */
- MntMultilabel = 0x04000000 /* MAC support for individual objects */
- MntACLs = 0x08000000 /* ACL support enabled */
- MntNoATime = 0x10000000 /* disable update of file access time */
- MntClusterRead = 0x40000000 /* disable cluster read */
- MntClusterWrite = 0x80000000 /* disable cluster write */
- MntNFS4ACLs = 0x00000010
-)
-
-type Statfs struct {
- Bsize uint32
- Iosize int32
- Blocks uint64
- Bfree uint64
- Bavail uint64
- Files uint64
- Ffree uint64
- Fsid Fsid
- Owner uint32
- Type uint32
- Flags uint32
- Fssubtype uint32
- Fstypename [16]int8
- Mntonname [1024]int8
- Mntfromname [1024]int8
- Reserved [8]uint32
-}
diff --git a/vendor/github.com/shirou/gopsutil/disk/disk_darwin_cgo.go b/vendor/github.com/shirou/gopsutil/disk/disk_darwin_cgo.go
deleted file mode 100644
index 480e237..0000000
--- a/vendor/github.com/shirou/gopsutil/disk/disk_darwin_cgo.go
+++ /dev/null
@@ -1,95 +0,0 @@
-// +build darwin
-// +build cgo
-
-package disk
-
-/*
-#cgo LDFLAGS: -lobjc -framework Foundation -framework IOKit
-#include
-
-// ### enough?
-const int MAX_DISK_NAME = 100;
-
-typedef struct
-{
- char DiskName[MAX_DISK_NAME];
- int64_t Reads;
- int64_t Writes;
- int64_t ReadBytes;
- int64_t WriteBytes;
- int64_t ReadTime;
- int64_t WriteTime;
-} DiskInfo;
-
-#include "disk_darwin.h"
-*/
-import "C"
-
-import (
- "context"
- "errors"
- "strings"
- "unsafe"
-
- "github.com/shirou/gopsutil/internal/common"
-)
-
-func IOCounters(names ...string) (map[string]IOCountersStat, error) {
- return IOCountersWithContext(context.Background(), names...)
-}
-
-func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOCountersStat, error) {
- if C.StartIOCounterFetch() == 0 {
- return nil, errors.New("Unable to fetch disk list")
- }
-
- // Clean up when we are done.
- defer C.EndIOCounterFetch()
- ret := make(map[string]IOCountersStat, 0)
-
- for {
- res := C.FetchNextDisk()
- if res == -1 {
- return nil, errors.New("Unable to fetch disk information")
- } else if res == 0 {
- break // done
- }
-
- di := C.DiskInfo{}
- if C.ReadDiskInfo((*C.DiskInfo)(unsafe.Pointer(&di))) == -1 {
- return nil, errors.New("Unable to fetch disk properties")
- }
-
- // Used to only get the necessary part of the C string.
- isRuneNull := func(r rune) bool {
- return r == '\u0000'
- }
-
- // Map from the darwin-specific C struct to the Go type
- //
- // ### missing: IopsInProgress, WeightedIO, MergedReadCount,
- // MergedWriteCount, SerialNumber
- // IOKit can give us at least the serial number I think...
- d := IOCountersStat{
- // Note: The Go type wants unsigned values, but CFNumberGetValue
- // doesn't appear to be able to give us unsigned values. So, we
- // cast, and hope for the best.
- ReadBytes: uint64(di.ReadBytes),
- WriteBytes: uint64(di.WriteBytes),
- ReadCount: uint64(di.Reads),
- WriteCount: uint64(di.Writes),
- ReadTime: uint64(di.ReadTime),
- WriteTime: uint64(di.WriteTime),
- IoTime: uint64(di.ReadTime + di.WriteTime),
- Name: strings.TrimFunc(C.GoStringN(&di.DiskName[0], C.MAX_DISK_NAME), isRuneNull),
- }
-
- if len(names) > 0 && !common.StringsHas(names, d.Name) {
- continue
- }
-
- ret[d.Name] = d
- }
-
- return ret, nil
-}
diff --git a/vendor/github.com/shirou/gopsutil/disk/disk_darwin_nocgo.go b/vendor/github.com/shirou/gopsutil/disk/disk_darwin_nocgo.go
deleted file mode 100644
index fe76d83..0000000
--- a/vendor/github.com/shirou/gopsutil/disk/disk_darwin_nocgo.go
+++ /dev/null
@@ -1,18 +0,0 @@
-// +build darwin
-// +build !cgo
-
-package disk
-
-import (
- "context"
-
- "github.com/shirou/gopsutil/internal/common"
-)
-
-func IOCounters(names ...string) (map[string]IOCountersStat, error) {
- return IOCountersWithContext(context.Background(), names...)
-}
-
-func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOCountersStat, error) {
- return nil, common.ErrNotImplementedError
-}
diff --git a/vendor/github.com/shirou/gopsutil/disk/disk_fallback.go b/vendor/github.com/shirou/gopsutil/disk/disk_fallback.go
deleted file mode 100644
index 22eb507..0000000
--- a/vendor/github.com/shirou/gopsutil/disk/disk_fallback.go
+++ /dev/null
@@ -1,33 +0,0 @@
-// +build !darwin,!linux,!freebsd,!openbsd,!windows,!solaris
-
-package disk
-
-import (
- "context"
-
- "github.com/shirou/gopsutil/internal/common"
-)
-
-func IOCounters(names ...string) (map[string]IOCountersStat, error) {
- return IOCountersWithContext(context.Background(), names...)
-}
-
-func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOCountersStat, error) {
- return nil, common.ErrNotImplementedError
-}
-
-func Partitions(all bool) ([]PartitionStat, error) {
- return PartitionsWithContext(context.Background(), all)
-}
-
-func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, error) {
- return []PartitionStat{}, common.ErrNotImplementedError
-}
-
-func Usage(path string) (*UsageStat, error) {
- return UsageWithContext(context.Background(), path)
-}
-
-func UsageWithContext(ctx context.Context, path string) (*UsageStat, error) {
- return nil, common.ErrNotImplementedError
-}
diff --git a/vendor/github.com/shirou/gopsutil/disk/disk_freebsd.go b/vendor/github.com/shirou/gopsutil/disk/disk_freebsd.go
deleted file mode 100644
index 2e0966a..0000000
--- a/vendor/github.com/shirou/gopsutil/disk/disk_freebsd.go
+++ /dev/null
@@ -1,196 +0,0 @@
-// +build freebsd
-
-package disk
-
-import (
- "bytes"
- "context"
- "encoding/binary"
- "path"
- "strconv"
- "unsafe"
-
- "golang.org/x/sys/unix"
-
- "github.com/shirou/gopsutil/internal/common"
-)
-
-func Partitions(all bool) ([]PartitionStat, error) {
- return PartitionsWithContext(context.Background(), all)
-}
-
-func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, error) {
- var ret []PartitionStat
-
- // get length
- count, err := unix.Getfsstat(nil, MNT_WAIT)
- if err != nil {
- return ret, err
- }
-
- fs := make([]Statfs, count)
- if _, err = Getfsstat(fs, MNT_WAIT); err != nil {
- return ret, err
- }
-
- for _, stat := range fs {
- opts := "rw"
- if stat.Flags&MNT_RDONLY != 0 {
- opts = "ro"
- }
- if stat.Flags&MNT_SYNCHRONOUS != 0 {
- opts += ",sync"
- }
- if stat.Flags&MNT_NOEXEC != 0 {
- opts += ",noexec"
- }
- if stat.Flags&MNT_NOSUID != 0 {
- opts += ",nosuid"
- }
- if stat.Flags&MNT_UNION != 0 {
- opts += ",union"
- }
- if stat.Flags&MNT_ASYNC != 0 {
- opts += ",async"
- }
- if stat.Flags&MNT_SUIDDIR != 0 {
- opts += ",suiddir"
- }
- if stat.Flags&MNT_SOFTDEP != 0 {
- opts += ",softdep"
- }
- if stat.Flags&MNT_NOSYMFOLLOW != 0 {
- opts += ",nosymfollow"
- }
- if stat.Flags&MNT_GJOURNAL != 0 {
- opts += ",gjounalc"
- }
- if stat.Flags&MNT_MULTILABEL != 0 {
- opts += ",multilabel"
- }
- if stat.Flags&MNT_ACLS != 0 {
- opts += ",acls"
- }
- if stat.Flags&MNT_NOATIME != 0 {
- opts += ",noattime"
- }
- if stat.Flags&MNT_NOCLUSTERR != 0 {
- opts += ",nocluster"
- }
- if stat.Flags&MNT_NOCLUSTERW != 0 {
- opts += ",noclusterw"
- }
- if stat.Flags&MNT_NFS4ACLS != 0 {
- opts += ",nfs4acls"
- }
-
- d := PartitionStat{
- Device: common.IntToString(stat.Mntfromname[:]),
- Mountpoint: common.IntToString(stat.Mntonname[:]),
- Fstype: common.IntToString(stat.Fstypename[:]),
- Opts: opts,
- }
- if all == false {
- if !path.IsAbs(d.Device) || !common.PathExists(d.Device) {
- continue
- }
- }
-
- ret = append(ret, d)
- }
-
- return ret, nil
-}
-
-func IOCounters(names ...string) (map[string]IOCountersStat, error) {
- return IOCountersWithContext(context.Background(), names...)
-}
-
-func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOCountersStat, error) {
- // statinfo->devinfo->devstat
- // /usr/include/devinfo.h
- ret := make(map[string]IOCountersStat)
-
- r, err := unix.Sysctl("kern.devstat.all")
- if err != nil {
- return nil, err
- }
- buf := []byte(r)
- length := len(buf)
-
- count := int(uint64(length) / uint64(sizeOfDevstat))
-
- buf = buf[8:] // devstat.all has version in the head.
- // parse buf to Devstat
- for i := 0; i < count; i++ {
- b := buf[i*sizeOfDevstat : i*sizeOfDevstat+sizeOfDevstat]
- d, err := parseDevstat(b)
- if err != nil {
- continue
- }
- un := strconv.Itoa(int(d.Unit_number))
- name := common.IntToString(d.Device_name[:]) + un
-
- if len(names) > 0 && !common.StringsHas(names, name) {
- continue
- }
-
- ds := IOCountersStat{
- ReadCount: d.Operations[DEVSTAT_READ],
- WriteCount: d.Operations[DEVSTAT_WRITE],
- ReadBytes: d.Bytes[DEVSTAT_READ],
- WriteBytes: d.Bytes[DEVSTAT_WRITE],
- ReadTime: uint64(d.Duration[DEVSTAT_READ].Compute() * 1000),
- WriteTime: uint64(d.Duration[DEVSTAT_WRITE].Compute() * 1000),
- IoTime: uint64(d.Busy_time.Compute() * 1000),
- Name: name,
- }
- ret[name] = ds
- }
-
- return ret, nil
-}
-
-func (b Bintime) Compute() float64 {
- BINTIME_SCALE := 5.42101086242752217003726400434970855712890625e-20
- return float64(b.Sec) + float64(b.Frac)*BINTIME_SCALE
-}
-
-// BT2LD(time) ((long double)(time).sec + (time).frac * BINTIME_SCALE)
-
-// Getfsstat is borrowed from pkg/syscall/syscall_freebsd.go
-// change Statfs_t to Statfs in order to get more information
-func Getfsstat(buf []Statfs, flags int) (n int, err error) {
- return GetfsstatWithContext(context.Background(), buf, flags)
-}
-
-func GetfsstatWithContext(ctx context.Context, buf []Statfs, flags int) (n int, err error) {
- var _p0 unsafe.Pointer
- var bufsize uintptr
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- bufsize = unsafe.Sizeof(Statfs{}) * uintptr(len(buf))
- }
- r0, _, e1 := unix.Syscall(unix.SYS_GETFSSTAT, uintptr(_p0), bufsize, uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func parseDevstat(buf []byte) (Devstat, error) {
- var ds Devstat
- br := bytes.NewReader(buf)
- // err := binary.Read(br, binary.LittleEndian, &ds)
- err := common.Read(br, binary.LittleEndian, &ds)
- if err != nil {
- return ds, err
- }
-
- return ds, nil
-}
-
-func getFsType(stat unix.Statfs_t) string {
- return common.IntToString(stat.Fstypename[:])
-}
diff --git a/vendor/github.com/shirou/gopsutil/disk/disk_freebsd_386.go b/vendor/github.com/shirou/gopsutil/disk/disk_freebsd_386.go
deleted file mode 100644
index 0b3f536..0000000
--- a/vendor/github.com/shirou/gopsutil/disk/disk_freebsd_386.go
+++ /dev/null
@@ -1,112 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_freebsd.go
-
-package disk
-
-const (
- sizeofPtr = 0x4
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x4
- sizeofLongLong = 0x8
- sizeofLongDouble = 0x8
-
- DEVSTAT_NO_DATA = 0x00
- DEVSTAT_READ = 0x01
- DEVSTAT_WRITE = 0x02
- DEVSTAT_FREE = 0x03
-
- MNT_RDONLY = 0x00000001
- MNT_SYNCHRONOUS = 0x00000002
- MNT_NOEXEC = 0x00000004
- MNT_NOSUID = 0x00000008
- MNT_UNION = 0x00000020
- MNT_ASYNC = 0x00000040
- MNT_SUIDDIR = 0x00100000
- MNT_SOFTDEP = 0x00200000
- MNT_NOSYMFOLLOW = 0x00400000
- MNT_GJOURNAL = 0x02000000
- MNT_MULTILABEL = 0x04000000
- MNT_ACLS = 0x08000000
- MNT_NOATIME = 0x10000000
- MNT_NOCLUSTERR = 0x40000000
- MNT_NOCLUSTERW = 0x80000000
- MNT_NFS4ACLS = 0x00000010
-
- MNT_WAIT = 1
- MNT_NOWAIT = 2
- MNT_LAZY = 3
- MNT_SUSPEND = 4
-)
-
-const (
- sizeOfDevstat = 0xf0
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int32
- _C_long_long int64
- _C_long_double int64
-)
-
-type Statfs struct {
- Version uint32
- Type uint32
- Flags uint64
- Bsize uint64
- Iosize uint64
- Blocks uint64
- Bfree uint64
- Bavail int64
- Files uint64
- Ffree int64
- Syncwrites uint64
- Asyncwrites uint64
- Syncreads uint64
- Asyncreads uint64
- Spare [10]uint64
- Namemax uint32
- Owner uint32
- Fsid Fsid
- Charspare [80]int8
- Fstypename [16]int8
- Mntfromname [88]int8
- Mntonname [88]int8
-}
-type Fsid struct {
- Val [2]int32
-}
-
-type Devstat struct {
- Sequence0 uint32
- Allocated int32
- Start_count uint32
- End_count uint32
- Busy_from Bintime
- Dev_links _Ctype_struct___0
- Device_number uint32
- Device_name [16]int8
- Unit_number int32
- Bytes [4]uint64
- Operations [4]uint64
- Duration [4]Bintime
- Busy_time Bintime
- Creation_time Bintime
- Block_size uint32
- Tag_types [3]uint64
- Flags uint32
- Device_type uint32
- Priority uint32
- Id *byte
- Sequence1 uint32
-}
-type Bintime struct {
- Sec int32
- Frac uint64
-}
-
-type _Ctype_struct___0 struct {
- Empty uint32
-}
diff --git a/vendor/github.com/shirou/gopsutil/disk/disk_freebsd_amd64.go b/vendor/github.com/shirou/gopsutil/disk/disk_freebsd_amd64.go
deleted file mode 100644
index 89b617c..0000000
--- a/vendor/github.com/shirou/gopsutil/disk/disk_freebsd_amd64.go
+++ /dev/null
@@ -1,115 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_freebsd.go
-
-package disk
-
-const (
- sizeofPtr = 0x8
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x8
- sizeofLongLong = 0x8
- sizeofLongDouble = 0x8
-
- DEVSTAT_NO_DATA = 0x00
- DEVSTAT_READ = 0x01
- DEVSTAT_WRITE = 0x02
- DEVSTAT_FREE = 0x03
-
- MNT_RDONLY = 0x00000001
- MNT_SYNCHRONOUS = 0x00000002
- MNT_NOEXEC = 0x00000004
- MNT_NOSUID = 0x00000008
- MNT_UNION = 0x00000020
- MNT_ASYNC = 0x00000040
- MNT_SUIDDIR = 0x00100000
- MNT_SOFTDEP = 0x00200000
- MNT_NOSYMFOLLOW = 0x00400000
- MNT_GJOURNAL = 0x02000000
- MNT_MULTILABEL = 0x04000000
- MNT_ACLS = 0x08000000
- MNT_NOATIME = 0x10000000
- MNT_NOCLUSTERR = 0x40000000
- MNT_NOCLUSTERW = 0x80000000
- MNT_NFS4ACLS = 0x00000010
-
- MNT_WAIT = 1
- MNT_NOWAIT = 2
- MNT_LAZY = 3
- MNT_SUSPEND = 4
-)
-
-const (
- sizeOfDevstat = 0x120
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int64
- _C_long_long int64
- _C_long_double int64
-)
-
-type Statfs struct {
- Version uint32
- Type uint32
- Flags uint64
- Bsize uint64
- Iosize uint64
- Blocks uint64
- Bfree uint64
- Bavail int64
- Files uint64
- Ffree int64
- Syncwrites uint64
- Asyncwrites uint64
- Syncreads uint64
- Asyncreads uint64
- Spare [10]uint64
- Namemax uint32
- Owner uint32
- Fsid Fsid
- Charspare [80]int8
- Fstypename [16]int8
- Mntfromname [88]int8
- Mntonname [88]int8
-}
-type Fsid struct {
- Val [2]int32
-}
-
-type Devstat struct {
- Sequence0 uint32
- Allocated int32
- Start_count uint32
- End_count uint32
- Busy_from Bintime
- Dev_links _Ctype_struct___0
- Device_number uint32
- Device_name [16]int8
- Unit_number int32
- Bytes [4]uint64
- Operations [4]uint64
- Duration [4]Bintime
- Busy_time Bintime
- Creation_time Bintime
- Block_size uint32
- Pad_cgo_0 [4]byte
- Tag_types [3]uint64
- Flags uint32
- Device_type uint32
- Priority uint32
- Pad_cgo_1 [4]byte
- ID *byte
- Sequence1 uint32
- Pad_cgo_2 [4]byte
-}
-type Bintime struct {
- Sec int64
- Frac uint64
-}
-
-type _Ctype_struct___0 struct {
- Empty uint64
-}
diff --git a/vendor/github.com/shirou/gopsutil/disk/disk_linux.go b/vendor/github.com/shirou/gopsutil/disk/disk_linux.go
deleted file mode 100644
index 1b10a38..0000000
--- a/vendor/github.com/shirou/gopsutil/disk/disk_linux.go
+++ /dev/null
@@ -1,447 +0,0 @@
-// +build linux
-
-package disk
-
-import (
- "bufio"
- "bytes"
- "context"
- "fmt"
- "io/ioutil"
- "path/filepath"
- "strconv"
- "strings"
-
- "golang.org/x/sys/unix"
-
- "github.com/shirou/gopsutil/internal/common"
-)
-
-const (
- SectorSize = 512
-)
-const (
- // man statfs
- ADFS_SUPER_MAGIC = 0xadf5
- AFFS_SUPER_MAGIC = 0xADFF
- BDEVFS_MAGIC = 0x62646576
- BEFS_SUPER_MAGIC = 0x42465331
- BFS_MAGIC = 0x1BADFACE
- BINFMTFS_MAGIC = 0x42494e4d
- BTRFS_SUPER_MAGIC = 0x9123683E
- CGROUP_SUPER_MAGIC = 0x27e0eb
- CIFS_MAGIC_NUMBER = 0xFF534D42
- CODA_SUPER_MAGIC = 0x73757245
- COH_SUPER_MAGIC = 0x012FF7B7
- CRAMFS_MAGIC = 0x28cd3d45
- DEBUGFS_MAGIC = 0x64626720
- DEVFS_SUPER_MAGIC = 0x1373
- DEVPTS_SUPER_MAGIC = 0x1cd1
- EFIVARFS_MAGIC = 0xde5e81e4
- EFS_SUPER_MAGIC = 0x00414A53
- EXT_SUPER_MAGIC = 0x137D
- EXT2_OLD_SUPER_MAGIC = 0xEF51
- EXT2_SUPER_MAGIC = 0xEF53
- EXT3_SUPER_MAGIC = 0xEF53
- EXT4_SUPER_MAGIC = 0xEF53
- FUSE_SUPER_MAGIC = 0x65735546
- FUTEXFS_SUPER_MAGIC = 0xBAD1DEA
- HFS_SUPER_MAGIC = 0x4244
- HOSTFS_SUPER_MAGIC = 0x00c0ffee
- HPFS_SUPER_MAGIC = 0xF995E849
- HUGETLBFS_MAGIC = 0x958458f6
- ISOFS_SUPER_MAGIC = 0x9660
- JFFS2_SUPER_MAGIC = 0x72b6
- JFS_SUPER_MAGIC = 0x3153464a
- MINIX_SUPER_MAGIC = 0x137F /* orig. minix */
- MINIX_SUPER_MAGIC2 = 0x138F /* 30 char minix */
- MINIX2_SUPER_MAGIC = 0x2468 /* minix V2 */
- MINIX2_SUPER_MAGIC2 = 0x2478 /* minix V2, 30 char names */
- MINIX3_SUPER_MAGIC = 0x4d5a /* minix V3 fs, 60 char names */
- MQUEUE_MAGIC = 0x19800202
- MSDOS_SUPER_MAGIC = 0x4d44
- NCP_SUPER_MAGIC = 0x564c
- NFS_SUPER_MAGIC = 0x6969
- NILFS_SUPER_MAGIC = 0x3434
- NTFS_SB_MAGIC = 0x5346544e
- OCFS2_SUPER_MAGIC = 0x7461636f
- OPENPROM_SUPER_MAGIC = 0x9fa1
- PIPEFS_MAGIC = 0x50495045
- PROC_SUPER_MAGIC = 0x9fa0
- PSTOREFS_MAGIC = 0x6165676C
- QNX4_SUPER_MAGIC = 0x002f
- QNX6_SUPER_MAGIC = 0x68191122
- RAMFS_MAGIC = 0x858458f6
- REISERFS_SUPER_MAGIC = 0x52654973
- ROMFS_MAGIC = 0x7275
- SELINUX_MAGIC = 0xf97cff8c
- SMACK_MAGIC = 0x43415d53
- SMB_SUPER_MAGIC = 0x517B
- SOCKFS_MAGIC = 0x534F434B
- SQUASHFS_MAGIC = 0x73717368
- SYSFS_MAGIC = 0x62656572
- SYSV2_SUPER_MAGIC = 0x012FF7B6
- SYSV4_SUPER_MAGIC = 0x012FF7B5
- TMPFS_MAGIC = 0x01021994
- UDF_SUPER_MAGIC = 0x15013346
- UFS_MAGIC = 0x00011954
- USBDEVICE_SUPER_MAGIC = 0x9fa2
- V9FS_MAGIC = 0x01021997
- VXFS_SUPER_MAGIC = 0xa501FCF5
- XENFS_SUPER_MAGIC = 0xabba1974
- XENIX_SUPER_MAGIC = 0x012FF7B4
- XFS_SUPER_MAGIC = 0x58465342
- _XIAFS_SUPER_MAGIC = 0x012FD16D
-
- AFS_SUPER_MAGIC = 0x5346414F
- AUFS_SUPER_MAGIC = 0x61756673
- ANON_INODE_FS_SUPER_MAGIC = 0x09041934
- CEPH_SUPER_MAGIC = 0x00C36400
- ECRYPTFS_SUPER_MAGIC = 0xF15F
- FAT_SUPER_MAGIC = 0x4006
- FHGFS_SUPER_MAGIC = 0x19830326
- FUSEBLK_SUPER_MAGIC = 0x65735546
- FUSECTL_SUPER_MAGIC = 0x65735543
- GFS_SUPER_MAGIC = 0x1161970
- GPFS_SUPER_MAGIC = 0x47504653
- MTD_INODE_FS_SUPER_MAGIC = 0x11307854
- INOTIFYFS_SUPER_MAGIC = 0x2BAD1DEA
- ISOFS_R_WIN_SUPER_MAGIC = 0x4004
- ISOFS_WIN_SUPER_MAGIC = 0x4000
- JFFS_SUPER_MAGIC = 0x07C0
- KAFS_SUPER_MAGIC = 0x6B414653
- LUSTRE_SUPER_MAGIC = 0x0BD00BD0
- NFSD_SUPER_MAGIC = 0x6E667364
- PANFS_SUPER_MAGIC = 0xAAD7AAEA
- RPC_PIPEFS_SUPER_MAGIC = 0x67596969
- SECURITYFS_SUPER_MAGIC = 0x73636673
- UFS_BYTESWAPPED_SUPER_MAGIC = 0x54190100
- VMHGFS_SUPER_MAGIC = 0xBACBACBC
- VZFS_SUPER_MAGIC = 0x565A4653
- ZFS_SUPER_MAGIC = 0x2FC12FC1
-)
-
-// coreutils/src/stat.c
-var fsTypeMap = map[int64]string{
- ADFS_SUPER_MAGIC: "adfs", /* 0xADF5 local */
- AFFS_SUPER_MAGIC: "affs", /* 0xADFF local */
- AFS_SUPER_MAGIC: "afs", /* 0x5346414F remote */
- ANON_INODE_FS_SUPER_MAGIC: "anon-inode FS", /* 0x09041934 local */
- AUFS_SUPER_MAGIC: "aufs", /* 0x61756673 remote */
- // AUTOFS_SUPER_MAGIC: "autofs", /* 0x0187 local */
- BEFS_SUPER_MAGIC: "befs", /* 0x42465331 local */
- BDEVFS_MAGIC: "bdevfs", /* 0x62646576 local */
- BFS_MAGIC: "bfs", /* 0x1BADFACE local */
- BINFMTFS_MAGIC: "binfmt_misc", /* 0x42494E4D local */
- BTRFS_SUPER_MAGIC: "btrfs", /* 0x9123683E local */
- CEPH_SUPER_MAGIC: "ceph", /* 0x00C36400 remote */
- CGROUP_SUPER_MAGIC: "cgroupfs", /* 0x0027E0EB local */
- CIFS_MAGIC_NUMBER: "cifs", /* 0xFF534D42 remote */
- CODA_SUPER_MAGIC: "coda", /* 0x73757245 remote */
- COH_SUPER_MAGIC: "coh", /* 0x012FF7B7 local */
- CRAMFS_MAGIC: "cramfs", /* 0x28CD3D45 local */
- DEBUGFS_MAGIC: "debugfs", /* 0x64626720 local */
- DEVFS_SUPER_MAGIC: "devfs", /* 0x1373 local */
- DEVPTS_SUPER_MAGIC: "devpts", /* 0x1CD1 local */
- ECRYPTFS_SUPER_MAGIC: "ecryptfs", /* 0xF15F local */
- EFS_SUPER_MAGIC: "efs", /* 0x00414A53 local */
- EXT_SUPER_MAGIC: "ext", /* 0x137D local */
- EXT2_SUPER_MAGIC: "ext2/ext3", /* 0xEF53 local */
- EXT2_OLD_SUPER_MAGIC: "ext2", /* 0xEF51 local */
- FAT_SUPER_MAGIC: "fat", /* 0x4006 local */
- FHGFS_SUPER_MAGIC: "fhgfs", /* 0x19830326 remote */
- FUSEBLK_SUPER_MAGIC: "fuseblk", /* 0x65735546 remote */
- FUSECTL_SUPER_MAGIC: "fusectl", /* 0x65735543 remote */
- FUTEXFS_SUPER_MAGIC: "futexfs", /* 0x0BAD1DEA local */
- GFS_SUPER_MAGIC: "gfs/gfs2", /* 0x1161970 remote */
- GPFS_SUPER_MAGIC: "gpfs", /* 0x47504653 remote */
- HFS_SUPER_MAGIC: "hfs", /* 0x4244 local */
- HPFS_SUPER_MAGIC: "hpfs", /* 0xF995E849 local */
- HUGETLBFS_MAGIC: "hugetlbfs", /* 0x958458F6 local */
- MTD_INODE_FS_SUPER_MAGIC: "inodefs", /* 0x11307854 local */
- INOTIFYFS_SUPER_MAGIC: "inotifyfs", /* 0x2BAD1DEA local */
- ISOFS_SUPER_MAGIC: "isofs", /* 0x9660 local */
- ISOFS_R_WIN_SUPER_MAGIC: "isofs", /* 0x4004 local */
- ISOFS_WIN_SUPER_MAGIC: "isofs", /* 0x4000 local */
- JFFS_SUPER_MAGIC: "jffs", /* 0x07C0 local */
- JFFS2_SUPER_MAGIC: "jffs2", /* 0x72B6 local */
- JFS_SUPER_MAGIC: "jfs", /* 0x3153464A local */
- KAFS_SUPER_MAGIC: "k-afs", /* 0x6B414653 remote */
- LUSTRE_SUPER_MAGIC: "lustre", /* 0x0BD00BD0 remote */
- MINIX_SUPER_MAGIC: "minix", /* 0x137F local */
- MINIX_SUPER_MAGIC2: "minix (30 char.)", /* 0x138F local */
- MINIX2_SUPER_MAGIC: "minix v2", /* 0x2468 local */
- MINIX2_SUPER_MAGIC2: "minix v2 (30 char.)", /* 0x2478 local */
- MINIX3_SUPER_MAGIC: "minix3", /* 0x4D5A local */
- MQUEUE_MAGIC: "mqueue", /* 0x19800202 local */
- MSDOS_SUPER_MAGIC: "msdos", /* 0x4D44 local */
- NCP_SUPER_MAGIC: "novell", /* 0x564C remote */
- NFS_SUPER_MAGIC: "nfs", /* 0x6969 remote */
- NFSD_SUPER_MAGIC: "nfsd", /* 0x6E667364 remote */
- NILFS_SUPER_MAGIC: "nilfs", /* 0x3434 local */
- NTFS_SB_MAGIC: "ntfs", /* 0x5346544E local */
- OPENPROM_SUPER_MAGIC: "openprom", /* 0x9FA1 local */
- OCFS2_SUPER_MAGIC: "ocfs2", /* 0x7461636f remote */
- PANFS_SUPER_MAGIC: "panfs", /* 0xAAD7AAEA remote */
- PIPEFS_MAGIC: "pipefs", /* 0x50495045 remote */
- PROC_SUPER_MAGIC: "proc", /* 0x9FA0 local */
- PSTOREFS_MAGIC: "pstorefs", /* 0x6165676C local */
- QNX4_SUPER_MAGIC: "qnx4", /* 0x002F local */
- QNX6_SUPER_MAGIC: "qnx6", /* 0x68191122 local */
- RAMFS_MAGIC: "ramfs", /* 0x858458F6 local */
- REISERFS_SUPER_MAGIC: "reiserfs", /* 0x52654973 local */
- ROMFS_MAGIC: "romfs", /* 0x7275 local */
- RPC_PIPEFS_SUPER_MAGIC: "rpc_pipefs", /* 0x67596969 local */
- SECURITYFS_SUPER_MAGIC: "securityfs", /* 0x73636673 local */
- SELINUX_MAGIC: "selinux", /* 0xF97CFF8C local */
- SMB_SUPER_MAGIC: "smb", /* 0x517B remote */
- SOCKFS_MAGIC: "sockfs", /* 0x534F434B local */
- SQUASHFS_MAGIC: "squashfs", /* 0x73717368 local */
- SYSFS_MAGIC: "sysfs", /* 0x62656572 local */
- SYSV2_SUPER_MAGIC: "sysv2", /* 0x012FF7B6 local */
- SYSV4_SUPER_MAGIC: "sysv4", /* 0x012FF7B5 local */
- TMPFS_MAGIC: "tmpfs", /* 0x01021994 local */
- UDF_SUPER_MAGIC: "udf", /* 0x15013346 local */
- UFS_MAGIC: "ufs", /* 0x00011954 local */
- UFS_BYTESWAPPED_SUPER_MAGIC: "ufs", /* 0x54190100 local */
- USBDEVICE_SUPER_MAGIC: "usbdevfs", /* 0x9FA2 local */
- V9FS_MAGIC: "v9fs", /* 0x01021997 local */
- VMHGFS_SUPER_MAGIC: "vmhgfs", /* 0xBACBACBC remote */
- VXFS_SUPER_MAGIC: "vxfs", /* 0xA501FCF5 local */
- VZFS_SUPER_MAGIC: "vzfs", /* 0x565A4653 local */
- XENFS_SUPER_MAGIC: "xenfs", /* 0xABBA1974 local */
- XENIX_SUPER_MAGIC: "xenix", /* 0x012FF7B4 local */
- XFS_SUPER_MAGIC: "xfs", /* 0x58465342 local */
- _XIAFS_SUPER_MAGIC: "xia", /* 0x012FD16D local */
- ZFS_SUPER_MAGIC: "zfs", /* 0x2FC12FC1 local */
-}
-
-// Partitions returns disk partitions. If all is false, returns
-// physical devices only (e.g. hard disks, cd-rom drives, USB keys)
-// and ignore all others (e.g. memory partitions such as /dev/shm)
-func Partitions(all bool) ([]PartitionStat, error) {
- return PartitionsWithContext(context.Background(), all)
-}
-
-func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, error) {
- filename := common.HostProc("self/mounts")
- lines, err := common.ReadLines(filename)
- if err != nil {
- return nil, err
- }
-
- fs, err := getFileSystems()
- if err != nil {
- return nil, err
- }
-
- ret := make([]PartitionStat, 0, len(lines))
-
- for _, line := range lines {
- fields := strings.Fields(line)
- d := PartitionStat{
- Device: fields[0],
- Mountpoint: fields[1],
- Fstype: fields[2],
- Opts: fields[3],
- }
- if all == false {
- if d.Device == "none" || !common.StringsHas(fs, d.Fstype) {
- continue
- }
- }
- ret = append(ret, d)
- }
-
- return ret, nil
-}
-
-// getFileSystems returns supported filesystems from /proc/filesystems
-func getFileSystems() ([]string, error) {
- filename := common.HostProc("filesystems")
- lines, err := common.ReadLines(filename)
- if err != nil {
- return nil, err
- }
- var ret []string
- for _, line := range lines {
- if !strings.HasPrefix(line, "nodev") {
- ret = append(ret, strings.TrimSpace(line))
- continue
- }
- t := strings.Split(line, "\t")
- if len(t) != 2 || t[1] != "zfs" {
- continue
- }
- ret = append(ret, strings.TrimSpace(t[1]))
- }
-
- return ret, nil
-}
-
-func IOCounters(names ...string) (map[string]IOCountersStat, error) {
- return IOCountersWithContext(context.Background(), names...)
-}
-
-func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOCountersStat, error) {
- filename := common.HostProc("diskstats")
- lines, err := common.ReadLines(filename)
- if err != nil {
- return nil, err
- }
- ret := make(map[string]IOCountersStat, 0)
- empty := IOCountersStat{}
-
- // use only basename such as "/dev/sda1" to "sda1"
- for i, name := range names {
- names[i] = filepath.Base(name)
- }
-
- for _, line := range lines {
- fields := strings.Fields(line)
- if len(fields) < 14 {
- // malformed line in /proc/diskstats, avoid panic by ignoring.
- continue
- }
- name := fields[2]
-
- if len(names) > 0 && !common.StringsHas(names, name) {
- continue
- }
-
- reads, err := strconv.ParseUint((fields[3]), 10, 64)
- if err != nil {
- return ret, err
- }
- mergedReads, err := strconv.ParseUint((fields[4]), 10, 64)
- if err != nil {
- return ret, err
- }
- rbytes, err := strconv.ParseUint((fields[5]), 10, 64)
- if err != nil {
- return ret, err
- }
- rtime, err := strconv.ParseUint((fields[6]), 10, 64)
- if err != nil {
- return ret, err
- }
- writes, err := strconv.ParseUint((fields[7]), 10, 64)
- if err != nil {
- return ret, err
- }
- mergedWrites, err := strconv.ParseUint((fields[8]), 10, 64)
- if err != nil {
- return ret, err
- }
- wbytes, err := strconv.ParseUint((fields[9]), 10, 64)
- if err != nil {
- return ret, err
- }
- wtime, err := strconv.ParseUint((fields[10]), 10, 64)
- if err != nil {
- return ret, err
- }
- iopsInProgress, err := strconv.ParseUint((fields[11]), 10, 64)
- if err != nil {
- return ret, err
- }
- iotime, err := strconv.ParseUint((fields[12]), 10, 64)
- if err != nil {
- return ret, err
- }
- weightedIO, err := strconv.ParseUint((fields[13]), 10, 64)
- if err != nil {
- return ret, err
- }
- d := IOCountersStat{
- ReadBytes: rbytes * SectorSize,
- WriteBytes: wbytes * SectorSize,
- ReadCount: reads,
- WriteCount: writes,
- MergedReadCount: mergedReads,
- MergedWriteCount: mergedWrites,
- ReadTime: rtime,
- WriteTime: wtime,
- IopsInProgress: iopsInProgress,
- IoTime: iotime,
- WeightedIO: weightedIO,
- }
- if d == empty {
- continue
- }
- d.Name = name
-
- d.SerialNumber = GetDiskSerialNumber(name)
- d.Label = GetLabel(name)
-
- ret[name] = d
- }
- return ret, nil
-}
-
-// GetDiskSerialNumber returns Serial Number of given device or empty string
-// on error. Name of device is expected, eg. /dev/sda
-func GetDiskSerialNumber(name string) string {
- return GetDiskSerialNumberWithContext(context.Background(), name)
-}
-
-func GetDiskSerialNumberWithContext(ctx context.Context, name string) string {
- var stat unix.Stat_t
- err := unix.Stat(name, &stat)
- if err != nil {
- return ""
- }
- major := unix.Major(uint64(stat.Rdev))
- minor := unix.Minor(uint64(stat.Rdev))
-
- // Try to get the serial from udev data
- udevDataPath := common.HostRun(fmt.Sprintf("udev/data/b%d:%d", major, minor))
- if udevdata, err := ioutil.ReadFile(udevDataPath); err == nil {
- scanner := bufio.NewScanner(bytes.NewReader(udevdata))
- for scanner.Scan() {
- values := strings.Split(scanner.Text(), "=")
- if len(values) == 2 && values[0] == "E:ID_SERIAL" {
- return values[1]
- }
- }
- }
-
- // Try to get the serial from sysfs, look at the disk device (minor 0) directly
- // because if it is a partition it is not going to contain any device information
- devicePath := common.HostSys(fmt.Sprintf("dev/block/%d:0/device", major))
- model, _ := ioutil.ReadFile(filepath.Join(devicePath, "model"))
- serial, _ := ioutil.ReadFile(filepath.Join(devicePath, "serial"))
- if len(model) > 0 && len(serial) > 0 {
- return fmt.Sprintf("%s_%s", string(model), string(serial))
- }
- return ""
-}
-
-// GetLabel returns label of given device or empty string on error.
-// Name of device is expected, eg. /dev/sda
-// Supports label based on devicemapper name
-// See https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-block-dm
-func GetLabel(name string) string {
- // Try label based on devicemapper name
- dmname_filename := common.HostSys(fmt.Sprintf("block/%s/dm/name", name))
-
- if !common.PathExists(dmname_filename) {
- return ""
- }
-
- dmname, err := ioutil.ReadFile(dmname_filename)
- if err != nil {
- return ""
- } else {
- return string(dmname)
- }
-}
-
-func getFsType(stat unix.Statfs_t) string {
- t := int64(stat.Type)
- ret, ok := fsTypeMap[t]
- if !ok {
- return ""
- }
- return ret
-}
diff --git a/vendor/github.com/shirou/gopsutil/disk/disk_openbsd.go b/vendor/github.com/shirou/gopsutil/disk/disk_openbsd.go
deleted file mode 100644
index 6fdf386..0000000
--- a/vendor/github.com/shirou/gopsutil/disk/disk_openbsd.go
+++ /dev/null
@@ -1,181 +0,0 @@
-// +build openbsd
-
-package disk
-
-import (
- "bytes"
- "context"
- "encoding/binary"
- "path"
- "unsafe"
-
- "github.com/shirou/gopsutil/internal/common"
- "golang.org/x/sys/unix"
-)
-
-func Partitions(all bool) ([]PartitionStat, error) {
- return PartitionsWithContext(context.Background(), all)
-}
-
-func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, error) {
- var ret []PartitionStat
-
- // get length
- count, err := unix.Getfsstat(nil, MNT_WAIT)
- if err != nil {
- return ret, err
- }
-
- fs := make([]Statfs, count)
- if _, err = Getfsstat(fs, MNT_WAIT); err != nil {
- return ret, err
- }
-
- for _, stat := range fs {
- opts := "rw"
- if stat.F_flags&MNT_RDONLY != 0 {
- opts = "ro"
- }
- if stat.F_flags&MNT_SYNCHRONOUS != 0 {
- opts += ",sync"
- }
- if stat.F_flags&MNT_NOEXEC != 0 {
- opts += ",noexec"
- }
- if stat.F_flags&MNT_NOSUID != 0 {
- opts += ",nosuid"
- }
- if stat.F_flags&MNT_NODEV != 0 {
- opts += ",nodev"
- }
- if stat.F_flags&MNT_ASYNC != 0 {
- opts += ",async"
- }
-
- d := PartitionStat{
- Device: common.IntToString(stat.F_mntfromname[:]),
- Mountpoint: common.IntToString(stat.F_mntonname[:]),
- Fstype: common.IntToString(stat.F_fstypename[:]),
- Opts: opts,
- }
- if all == false {
- if !path.IsAbs(d.Device) || !common.PathExists(d.Device) {
- continue
- }
- }
-
- ret = append(ret, d)
- }
-
- return ret, nil
-}
-
-func IOCounters(names ...string) (map[string]IOCountersStat, error) {
- return IOCountersWithContext(context.Background(), names...)
-}
-
-func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOCountersStat, error) {
- ret := make(map[string]IOCountersStat)
-
- r, err := unix.SysctlRaw("hw.diskstats")
- if err != nil {
- return nil, err
- }
- buf := []byte(r)
- length := len(buf)
-
- count := int(uint64(length) / uint64(sizeOfDiskstats))
-
- // parse buf to Diskstats
- for i := 0; i < count; i++ {
- b := buf[i*sizeOfDiskstats : i*sizeOfDiskstats+sizeOfDiskstats]
- d, err := parseDiskstats(b)
- if err != nil {
- continue
- }
- name := common.IntToString(d.Name[:])
-
- if len(names) > 0 && !common.StringsHas(names, name) {
- continue
- }
-
- ds := IOCountersStat{
- ReadCount: d.Rxfer,
- WriteCount: d.Wxfer,
- ReadBytes: d.Rbytes,
- WriteBytes: d.Wbytes,
- Name: name,
- }
- ret[name] = ds
- }
-
- return ret, nil
-}
-
-// BT2LD(time) ((long double)(time).sec + (time).frac * BINTIME_SCALE)
-
-// Getfsstat is borrowed from pkg/syscall/syscall_freebsd.go
-// change Statfs_t to Statfs in order to get more information
-func Getfsstat(buf []Statfs, flags int) (n int, err error) {
- return GetfsstatWithContext(context.Background(), buf, flags)
-}
-
-func GetfsstatWithContext(ctx context.Context, buf []Statfs, flags int) (n int, err error) {
- var _p0 unsafe.Pointer
- var bufsize uintptr
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- bufsize = unsafe.Sizeof(Statfs{}) * uintptr(len(buf))
- }
- r0, _, e1 := unix.Syscall(unix.SYS_GETFSSTAT, uintptr(_p0), bufsize, uintptr(flags))
- n = int(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func parseDiskstats(buf []byte) (Diskstats, error) {
- var ds Diskstats
- br := bytes.NewReader(buf)
- // err := binary.Read(br, binary.LittleEndian, &ds)
- err := common.Read(br, binary.LittleEndian, &ds)
- if err != nil {
- return ds, err
- }
-
- return ds, nil
-}
-
-func Usage(path string) (*UsageStat, error) {
- return UsageWithContext(context.Background(), path)
-}
-
-func UsageWithContext(ctx context.Context, path string) (*UsageStat, error) {
- stat := unix.Statfs_t{}
- err := unix.Statfs(path, &stat)
- if err != nil {
- return nil, err
- }
- bsize := stat.F_bsize
-
- ret := &UsageStat{
- Path: path,
- Fstype: getFsType(stat),
- Total: (uint64(stat.F_blocks) * uint64(bsize)),
- Free: (uint64(stat.F_bavail) * uint64(bsize)),
- InodesTotal: (uint64(stat.F_files)),
- InodesFree: (uint64(stat.F_ffree)),
- }
-
- ret.InodesUsed = (ret.InodesTotal - ret.InodesFree)
- ret.InodesUsedPercent = (float64(ret.InodesUsed) / float64(ret.InodesTotal)) * 100.0
- ret.Used = (uint64(stat.F_blocks) - uint64(stat.F_bfree)) * uint64(bsize)
- ret.UsedPercent = (float64(ret.Used) / float64(ret.Total)) * 100.0
-
- return ret, nil
-}
-
-func getFsType(stat unix.Statfs_t) string {
- return common.IntToString(stat.F_fstypename[:])
-}
diff --git a/vendor/github.com/shirou/gopsutil/disk/disk_openbsd_amd64.go b/vendor/github.com/shirou/gopsutil/disk/disk_openbsd_amd64.go
deleted file mode 100644
index 07a845f..0000000
--- a/vendor/github.com/shirou/gopsutil/disk/disk_openbsd_amd64.go
+++ /dev/null
@@ -1,91 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_openbsd.go
-
-package disk
-
-const (
- sizeofPtr = 0x8
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x8
- sizeofLongLong = 0x8
- sizeofLongDouble = 0x8
-
- DEVSTAT_NO_DATA = 0x00
- DEVSTAT_READ = 0x01
- DEVSTAT_WRITE = 0x02
- DEVSTAT_FREE = 0x03
-
- MNT_RDONLY = 0x00000001
- MNT_SYNCHRONOUS = 0x00000002
- MNT_NOEXEC = 0x00000004
- MNT_NOSUID = 0x00000008
- MNT_NODEV = 0x00000010
- MNT_ASYNC = 0x00000040
-
- MNT_WAIT = 1
- MNT_NOWAIT = 2
- MNT_LAZY = 3
-)
-
-const (
- sizeOfDiskstats = 0x70
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int64
- _C_long_long int64
- _C_long_double int64
-)
-
-type Statfs struct {
- F_flags uint32
- F_bsize uint32
- F_iosize uint32
- Pad_cgo_0 [4]byte
- F_blocks uint64
- F_bfree uint64
- F_bavail int64
- F_files uint64
- F_ffree uint64
- F_favail int64
- F_syncwrites uint64
- F_syncreads uint64
- F_asyncwrites uint64
- F_asyncreads uint64
- F_fsid Fsid
- F_namemax uint32
- F_owner uint32
- F_ctime uint64
- F_fstypename [16]int8
- F_mntonname [90]int8
- F_mntfromname [90]int8
- F_mntfromspec [90]int8
- Pad_cgo_1 [2]byte
- Mount_info [160]byte
-}
-type Diskstats struct {
- Name [16]int8
- Busy int32
- Pad_cgo_0 [4]byte
- Rxfer uint64
- Wxfer uint64
- Seek uint64
- Rbytes uint64
- Wbytes uint64
- Attachtime Timeval
- Timestamp Timeval
- Time Timeval
-}
-type Fsid struct {
- Val [2]int32
-}
-type Timeval struct {
- Sec int64
- Usec int64
-}
-
-type Diskstat struct{}
-type Bintime struct{}
diff --git a/vendor/github.com/shirou/gopsutil/disk/disk_solaris.go b/vendor/github.com/shirou/gopsutil/disk/disk_solaris.go
deleted file mode 100644
index c660835..0000000
--- a/vendor/github.com/shirou/gopsutil/disk/disk_solaris.go
+++ /dev/null
@@ -1,127 +0,0 @@
-// +build solaris
-
-package disk
-
-import (
- "bufio"
- "context"
- "fmt"
- "math"
- "os"
- "strings"
-
- "github.com/shirou/gopsutil/internal/common"
- "golang.org/x/sys/unix"
-)
-
-const (
- // _DEFAULT_NUM_MOUNTS is set to `cat /etc/mnttab | wc -l` rounded up to the
- // nearest power of two.
- _DEFAULT_NUM_MOUNTS = 32
-
- // _MNTTAB default place to read mount information
- _MNTTAB = "/etc/mnttab"
-)
-
-var (
- // A blacklist of read-only virtual filesystems. Writable filesystems are of
- // operational concern and must not be included in this list.
- fsTypeBlacklist = map[string]struct{}{
- "ctfs": struct{}{},
- "dev": struct{}{},
- "fd": struct{}{},
- "lofs": struct{}{},
- "lxproc": struct{}{},
- "mntfs": struct{}{},
- "objfs": struct{}{},
- "proc": struct{}{},
- }
-)
-
-func Partitions(all bool) ([]PartitionStat, error) {
- return PartitionsWithContext(context.Background(), all)
-}
-
-func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, error) {
- ret := make([]PartitionStat, 0, _DEFAULT_NUM_MOUNTS)
-
- // Scan mnttab(4)
- f, err := os.Open(_MNTTAB)
- if err != nil {
- }
- defer func() {
- if err == nil {
- err = f.Close()
- } else {
- f.Close()
- }
- }()
-
- scanner := bufio.NewScanner(f)
- for scanner.Scan() {
- fields := strings.Split(scanner.Text(), "\t")
-
- if _, found := fsTypeBlacklist[fields[2]]; found {
- continue
- }
-
- ret = append(ret, PartitionStat{
- // NOTE(seanc@): Device isn't exactly accurate: from mnttab(4): "The name
- // of the resource that has been mounted." Ideally this value would come
- // from Statvfs_t.Fsid but I'm leaving it to the caller to traverse
- // unix.Statvfs().
- Device: fields[0],
- Mountpoint: fields[1],
- Fstype: fields[2],
- Opts: fields[3],
- })
- }
- if err := scanner.Err(); err != nil {
- return nil, fmt.Errorf("unable to scan %q: %v", _MNTTAB, err)
- }
-
- return ret, err
-}
-
-func IOCounters(names ...string) (map[string]IOCountersStat, error) {
- return IOCountersWithContext(context.Background(), names...)
-}
-
-func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOCountersStat, error) {
- return nil, common.ErrNotImplementedError
-}
-
-func Usage(path string) (*UsageStat, error) {
- return UsageWithContext(context.Background(), path)
-}
-
-func UsageWithContext(ctx context.Context, path string) (*UsageStat, error) {
- statvfs := unix.Statvfs_t{}
- if err := unix.Statvfs(path, &statvfs); err != nil {
- return nil, fmt.Errorf("unable to call statvfs(2) on %q: %v", path, err)
- }
-
- usageStat := &UsageStat{
- Path: path,
- Fstype: common.IntToString(statvfs.Basetype[:]),
- Total: statvfs.Blocks * statvfs.Frsize,
- Free: statvfs.Bfree * statvfs.Frsize,
- Used: (statvfs.Blocks - statvfs.Bfree) * statvfs.Frsize,
-
- // NOTE: ZFS (and FreeBZSD's UFS2) use dynamic inode/dnode allocation.
- // Explicitly return a near-zero value for InodesUsedPercent so that nothing
- // attempts to garbage collect based on a lack of available inodes/dnodes.
- // Similarly, don't use the zero value to prevent divide-by-zero situations
- // and inject a faux near-zero value. Filesystems evolve. Has your
- // filesystem evolved? Probably not if you care about the number of
- // available inodes.
- InodesTotal: 1024.0 * 1024.0,
- InodesUsed: 1024.0,
- InodesFree: math.MaxUint64,
- InodesUsedPercent: (1024.0 / (1024.0 * 1024.0)) * 100.0,
- }
-
- usageStat.UsedPercent = (float64(usageStat.Used) / float64(usageStat.Total)) * 100.0
-
- return usageStat, nil
-}
diff --git a/vendor/github.com/shirou/gopsutil/disk/disk_unix.go b/vendor/github.com/shirou/gopsutil/disk/disk_unix.go
deleted file mode 100644
index 9b499b5..0000000
--- a/vendor/github.com/shirou/gopsutil/disk/disk_unix.go
+++ /dev/null
@@ -1,68 +0,0 @@
-// +build freebsd linux darwin
-
-package disk
-
-import (
- "context"
- "strconv"
-
- "golang.org/x/sys/unix"
-)
-
-// Usage returns a file system usage. path is a filessytem path such
-// as "/", not device file path like "/dev/vda1". If you want to use
-// a return value of disk.Partitions, use "Mountpoint" not "Device".
-func Usage(path string) (*UsageStat, error) {
- return UsageWithContext(context.Background(), path)
-}
-
-func UsageWithContext(ctx context.Context, path string) (*UsageStat, error) {
- stat := unix.Statfs_t{}
- err := unix.Statfs(path, &stat)
- if err != nil {
- return nil, err
- }
- bsize := stat.Bsize
-
- ret := &UsageStat{
- Path: unescapeFstab(path),
- Fstype: getFsType(stat),
- Total: (uint64(stat.Blocks) * uint64(bsize)),
- Free: (uint64(stat.Bavail) * uint64(bsize)),
- InodesTotal: (uint64(stat.Files)),
- InodesFree: (uint64(stat.Ffree)),
- }
-
- // if could not get InodesTotal, return empty
- if ret.InodesTotal < ret.InodesFree {
- return ret, nil
- }
-
- ret.InodesUsed = (ret.InodesTotal - ret.InodesFree)
- ret.Used = (uint64(stat.Blocks) - uint64(stat.Bfree)) * uint64(bsize)
-
- if ret.InodesTotal == 0 {
- ret.InodesUsedPercent = 0
- } else {
- ret.InodesUsedPercent = (float64(ret.InodesUsed) / float64(ret.InodesTotal)) * 100.0
- }
-
- if (ret.Used + ret.Free) == 0 {
- ret.UsedPercent = 0
- } else {
- // We don't use ret.Total to calculate percent.
- // see https://github.com/shirou/gopsutil/issues/562
- ret.UsedPercent = (float64(ret.Used) / float64(ret.Used+ret.Free)) * 100.0
- }
-
- return ret, nil
-}
-
-// Unescape escaped octal chars (like space 040, ampersand 046 and backslash 134) to their real value in fstab fields issue#555
-func unescapeFstab(path string) string {
- escaped, err := strconv.Unquote(`"` + path + `"`)
- if err != nil {
- return path
- }
- return escaped
-}
diff --git a/vendor/github.com/shirou/gopsutil/disk/disk_windows.go b/vendor/github.com/shirou/gopsutil/disk/disk_windows.go
deleted file mode 100644
index 326bc1f..0000000
--- a/vendor/github.com/shirou/gopsutil/disk/disk_windows.go
+++ /dev/null
@@ -1,171 +0,0 @@
-// +build windows
-
-package disk
-
-import (
- "bytes"
- "context"
- "unsafe"
-
- "github.com/shirou/gopsutil/internal/common"
- "golang.org/x/sys/windows"
-)
-
-var (
- procGetDiskFreeSpaceExW = common.Modkernel32.NewProc("GetDiskFreeSpaceExW")
- procGetLogicalDriveStringsW = common.Modkernel32.NewProc("GetLogicalDriveStringsW")
- procGetDriveType = common.Modkernel32.NewProc("GetDriveTypeW")
- provGetVolumeInformation = common.Modkernel32.NewProc("GetVolumeInformationW")
-)
-
-var (
- FileFileCompression = int64(16) // 0x00000010
- FileReadOnlyVolume = int64(524288) // 0x00080000
-)
-
-type Win32_PerfFormattedData struct {
- Name string
- AvgDiskBytesPerRead uint64
- AvgDiskBytesPerWrite uint64
- AvgDiskReadQueueLength uint64
- AvgDiskWriteQueueLength uint64
- AvgDisksecPerRead uint64
- AvgDisksecPerWrite uint64
-}
-
-const WaitMSec = 500
-
-func Usage(path string) (*UsageStat, error) {
- return UsageWithContext(context.Background(), path)
-}
-
-func UsageWithContext(ctx context.Context, path string) (*UsageStat, error) {
- ret := &UsageStat{}
-
- lpFreeBytesAvailable := int64(0)
- lpTotalNumberOfBytes := int64(0)
- lpTotalNumberOfFreeBytes := int64(0)
- diskret, _, err := procGetDiskFreeSpaceExW.Call(
- uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(path))),
- uintptr(unsafe.Pointer(&lpFreeBytesAvailable)),
- uintptr(unsafe.Pointer(&lpTotalNumberOfBytes)),
- uintptr(unsafe.Pointer(&lpTotalNumberOfFreeBytes)))
- if diskret == 0 {
- return nil, err
- }
- ret = &UsageStat{
- Path: path,
- Total: uint64(lpTotalNumberOfBytes),
- Free: uint64(lpTotalNumberOfFreeBytes),
- Used: uint64(lpTotalNumberOfBytes) - uint64(lpTotalNumberOfFreeBytes),
- UsedPercent: (float64(lpTotalNumberOfBytes) - float64(lpTotalNumberOfFreeBytes)) / float64(lpTotalNumberOfBytes) * 100,
- // InodesTotal: 0,
- // InodesFree: 0,
- // InodesUsed: 0,
- // InodesUsedPercent: 0,
- }
- return ret, nil
-}
-
-func Partitions(all bool) ([]PartitionStat, error) {
- return PartitionsWithContext(context.Background(), all)
-}
-
-func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, error) {
- var ret []PartitionStat
- lpBuffer := make([]byte, 254)
- diskret, _, err := procGetLogicalDriveStringsW.Call(
- uintptr(len(lpBuffer)),
- uintptr(unsafe.Pointer(&lpBuffer[0])))
- if diskret == 0 {
- return ret, err
- }
- for _, v := range lpBuffer {
- if v >= 65 && v <= 90 {
- path := string(v) + ":"
- if path == "A:" || path == "B:" { // skip floppy drives
- continue
- }
- typepath, _ := windows.UTF16PtrFromString(path)
- typeret, _, _ := procGetDriveType.Call(uintptr(unsafe.Pointer(typepath)))
- if typeret == 0 {
- return ret, windows.GetLastError()
- }
- // 2: DRIVE_REMOVABLE 3: DRIVE_FIXED 4: DRIVE_REMOTE 5: DRIVE_CDROM
-
- if typeret == 2 || typeret == 3 || typeret == 4 || typeret == 5 {
- lpVolumeNameBuffer := make([]byte, 256)
- lpVolumeSerialNumber := int64(0)
- lpMaximumComponentLength := int64(0)
- lpFileSystemFlags := int64(0)
- lpFileSystemNameBuffer := make([]byte, 256)
- volpath, _ := windows.UTF16PtrFromString(string(v) + ":/")
- driveret, _, err := provGetVolumeInformation.Call(
- uintptr(unsafe.Pointer(volpath)),
- uintptr(unsafe.Pointer(&lpVolumeNameBuffer[0])),
- uintptr(len(lpVolumeNameBuffer)),
- uintptr(unsafe.Pointer(&lpVolumeSerialNumber)),
- uintptr(unsafe.Pointer(&lpMaximumComponentLength)),
- uintptr(unsafe.Pointer(&lpFileSystemFlags)),
- uintptr(unsafe.Pointer(&lpFileSystemNameBuffer[0])),
- uintptr(len(lpFileSystemNameBuffer)))
- if driveret == 0 {
- if typeret == 5 || typeret == 2 {
- continue //device is not ready will happen if there is no disk in the drive
- }
- return ret, err
- }
- opts := "rw"
- if lpFileSystemFlags&FileReadOnlyVolume != 0 {
- opts = "ro"
- }
- if lpFileSystemFlags&FileFileCompression != 0 {
- opts += ".compress"
- }
-
- d := PartitionStat{
- Mountpoint: path,
- Device: path,
- Fstype: string(bytes.Replace(lpFileSystemNameBuffer, []byte("\x00"), []byte(""), -1)),
- Opts: opts,
- }
- ret = append(ret, d)
- }
- }
- }
- return ret, nil
-}
-
-func IOCounters(names ...string) (map[string]IOCountersStat, error) {
- return IOCountersWithContext(context.Background(), names...)
-}
-
-func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOCountersStat, error) {
- ret := make(map[string]IOCountersStat, 0)
- var dst []Win32_PerfFormattedData
-
- err := common.WMIQueryWithContext(ctx, "SELECT * FROM Win32_PerfFormattedData_PerfDisk_LogicalDisk", &dst)
- if err != nil {
- return ret, err
- }
- for _, d := range dst {
- if len(d.Name) > 3 { // not get _Total or Harddrive
- continue
- }
-
- if len(names) > 0 && !common.StringsHas(names, d.Name) {
- continue
- }
-
- ret[d.Name] = IOCountersStat{
- Name: d.Name,
- ReadCount: uint64(d.AvgDiskReadQueueLength),
- WriteCount: d.AvgDiskWriteQueueLength,
- ReadBytes: uint64(d.AvgDiskBytesPerRead),
- WriteBytes: uint64(d.AvgDiskBytesPerWrite),
- ReadTime: d.AvgDisksecPerRead,
- WriteTime: d.AvgDisksecPerWrite,
- }
- }
- return ret, nil
-}
diff --git a/vendor/github.com/shirou/gopsutil/disk/types_freebsd.go b/vendor/github.com/shirou/gopsutil/disk/types_freebsd.go
deleted file mode 100644
index dd6ddc4..0000000
--- a/vendor/github.com/shirou/gopsutil/disk/types_freebsd.go
+++ /dev/null
@@ -1,88 +0,0 @@
-// +build ignore
-// Hand writing: _Ctype_struct___0
-
-/*
-Input to cgo -godefs.
-
-*/
-
-package disk
-
-/*
-#include
-#include
-#include
-
-enum {
- sizeofPtr = sizeof(void*),
-};
-
-// because statinfo has long double snap_time, redefine with changing long long
-struct statinfo2 {
- long cp_time[CPUSTATES];
- long tk_nin;
- long tk_nout;
- struct devinfo *dinfo;
- long long snap_time;
-};
-*/
-import "C"
-
-// Machine characteristics; for internal use.
-
-const (
- sizeofPtr = C.sizeofPtr
- sizeofShort = C.sizeof_short
- sizeofInt = C.sizeof_int
- sizeofLong = C.sizeof_long
- sizeofLongLong = C.sizeof_longlong
- sizeofLongDouble = C.sizeof_longlong
-
- DEVSTAT_NO_DATA = 0x00
- DEVSTAT_READ = 0x01
- DEVSTAT_WRITE = 0x02
- DEVSTAT_FREE = 0x03
-
- // from sys/mount.h
- MNT_RDONLY = 0x00000001 /* read only filesystem */
- MNT_SYNCHRONOUS = 0x00000002 /* filesystem written synchronously */
- MNT_NOEXEC = 0x00000004 /* can't exec from filesystem */
- MNT_NOSUID = 0x00000008 /* don't honor setuid bits on fs */
- MNT_UNION = 0x00000020 /* union with underlying filesystem */
- MNT_ASYNC = 0x00000040 /* filesystem written asynchronously */
- MNT_SUIDDIR = 0x00100000 /* special handling of SUID on dirs */
- MNT_SOFTDEP = 0x00200000 /* soft updates being done */
- MNT_NOSYMFOLLOW = 0x00400000 /* do not follow symlinks */
- MNT_GJOURNAL = 0x02000000 /* GEOM journal support enabled */
- MNT_MULTILABEL = 0x04000000 /* MAC support for individual objects */
- MNT_ACLS = 0x08000000 /* ACL support enabled */
- MNT_NOATIME = 0x10000000 /* disable update of file access time */
- MNT_NOCLUSTERR = 0x40000000 /* disable cluster read */
- MNT_NOCLUSTERW = 0x80000000 /* disable cluster write */
- MNT_NFS4ACLS = 0x00000010
-
- MNT_WAIT = 1 /* synchronously wait for I/O to complete */
- MNT_NOWAIT = 2 /* start all I/O, but do not wait for it */
- MNT_LAZY = 3 /* push data not written by filesystem syncer */
- MNT_SUSPEND = 4 /* Suspend file system after sync */
-)
-
-const (
- sizeOfDevstat = C.sizeof_struct_devstat
-)
-
-// Basic types
-
-type (
- _C_short C.short
- _C_int C.int
- _C_long C.long
- _C_long_long C.longlong
- _C_long_double C.longlong
-)
-
-type Statfs C.struct_statfs
-type Fsid C.struct_fsid
-
-type Devstat C.struct_devstat
-type Bintime C.struct_bintime
diff --git a/vendor/github.com/shirou/gopsutil/disk/types_openbsd.go b/vendor/github.com/shirou/gopsutil/disk/types_openbsd.go
deleted file mode 100644
index 1e3ddef..0000000
--- a/vendor/github.com/shirou/gopsutil/disk/types_openbsd.go
+++ /dev/null
@@ -1,70 +0,0 @@
-// +build ignore
-// Hand writing: _Ctype_struct___0
-
-/*
-Input to cgo -godefs.
-*/
-
-package disk
-
-/*
-#include
-#include
-#include
-
-enum {
- sizeofPtr = sizeof(void*),
-};
-
-*/
-import "C"
-
-// Machine characteristics; for internal use.
-
-const (
- sizeofPtr = C.sizeofPtr
- sizeofShort = C.sizeof_short
- sizeofInt = C.sizeof_int
- sizeofLong = C.sizeof_long
- sizeofLongLong = C.sizeof_longlong
- sizeofLongDouble = C.sizeof_longlong
-
- DEVSTAT_NO_DATA = 0x00
- DEVSTAT_READ = 0x01
- DEVSTAT_WRITE = 0x02
- DEVSTAT_FREE = 0x03
-
- // from sys/mount.h
- MNT_RDONLY = 0x00000001 /* read only filesystem */
- MNT_SYNCHRONOUS = 0x00000002 /* filesystem written synchronously */
- MNT_NOEXEC = 0x00000004 /* can't exec from filesystem */
- MNT_NOSUID = 0x00000008 /* don't honor setuid bits on fs */
- MNT_NODEV = 0x00000010 /* don't interpret special files */
- MNT_ASYNC = 0x00000040 /* filesystem written asynchronously */
-
- MNT_WAIT = 1 /* synchronously wait for I/O to complete */
- MNT_NOWAIT = 2 /* start all I/O, but do not wait for it */
- MNT_LAZY = 3 /* push data not written by filesystem syncer */
-)
-
-const (
- sizeOfDiskstats = C.sizeof_struct_diskstats
-)
-
-// Basic types
-
-type (
- _C_short C.short
- _C_int C.int
- _C_long C.long
- _C_long_long C.longlong
- _C_long_double C.longlong
-)
-
-type Statfs C.struct_statfs
-type Diskstats C.struct_diskstats
-type Fsid C.fsid_t
-type Timeval C.struct_timeval
-
-type Diskstat C.struct_diskstat
-type Bintime C.struct_bintime
diff --git a/vendor/github.com/shirou/gopsutil/host/host.go b/vendor/github.com/shirou/gopsutil/host/host.go
deleted file mode 100644
index 1e9e9bb..0000000
--- a/vendor/github.com/shirou/gopsutil/host/host.go
+++ /dev/null
@@ -1,53 +0,0 @@
-package host
-
-import (
- "encoding/json"
-
- "github.com/shirou/gopsutil/internal/common"
-)
-
-var invoke common.Invoker = common.Invoke{}
-
-// A HostInfoStat describes the host status.
-// This is not in the psutil but it useful.
-type InfoStat struct {
- Hostname string `json:"hostname"`
- Uptime uint64 `json:"uptime"`
- BootTime uint64 `json:"bootTime"`
- Procs uint64 `json:"procs"` // number of processes
- OS string `json:"os"` // ex: freebsd, linux
- Platform string `json:"platform"` // ex: ubuntu, linuxmint
- PlatformFamily string `json:"platformFamily"` // ex: debian, rhel
- PlatformVersion string `json:"platformVersion"` // version of the complete OS
- KernelVersion string `json:"kernelVersion"` // version of the OS kernel (if available)
- VirtualizationSystem string `json:"virtualizationSystem"`
- VirtualizationRole string `json:"virtualizationRole"` // guest or host
- HostID string `json:"hostid"` // ex: uuid
-}
-
-type UserStat struct {
- User string `json:"user"`
- Terminal string `json:"terminal"`
- Host string `json:"host"`
- Started int `json:"started"`
-}
-
-type TemperatureStat struct {
- SensorKey string `json:"sensorKey"`
- Temperature float64 `json:"sensorTemperature"`
-}
-
-func (h InfoStat) String() string {
- s, _ := json.Marshal(h)
- return string(s)
-}
-
-func (u UserStat) String() string {
- s, _ := json.Marshal(u)
- return string(s)
-}
-
-func (t TemperatureStat) String() string {
- s, _ := json.Marshal(t)
- return string(s)
-}
diff --git a/vendor/github.com/shirou/gopsutil/host/host_darwin.go b/vendor/github.com/shirou/gopsutil/host/host_darwin.go
deleted file mode 100644
index 5a4066a..0000000
--- a/vendor/github.com/shirou/gopsutil/host/host_darwin.go
+++ /dev/null
@@ -1,227 +0,0 @@
-// +build darwin
-
-package host
-
-import (
- "bytes"
- "context"
- "encoding/binary"
- "io/ioutil"
- "os"
- "os/exec"
- "runtime"
- "strconv"
- "strings"
- "sync/atomic"
- "time"
- "unsafe"
-
- "github.com/shirou/gopsutil/internal/common"
- "github.com/shirou/gopsutil/process"
-)
-
-// from utmpx.h
-const USER_PROCESS = 7
-
-func Info() (*InfoStat, error) {
- return InfoWithContext(context.Background())
-}
-
-func InfoWithContext(ctx context.Context) (*InfoStat, error) {
- ret := &InfoStat{
- OS: runtime.GOOS,
- PlatformFamily: "darwin",
- }
-
- hostname, err := os.Hostname()
- if err == nil {
- ret.Hostname = hostname
- }
-
- uname, err := exec.LookPath("uname")
- if err == nil {
- out, err := invoke.CommandWithContext(ctx, uname, "-r")
- if err == nil {
- ret.KernelVersion = strings.ToLower(strings.TrimSpace(string(out)))
- }
- }
-
- platform, family, pver, err := PlatformInformation()
- if err == nil {
- ret.Platform = platform
- ret.PlatformFamily = family
- ret.PlatformVersion = pver
- }
-
- system, role, err := Virtualization()
- if err == nil {
- ret.VirtualizationSystem = system
- ret.VirtualizationRole = role
- }
-
- boot, err := BootTime()
- if err == nil {
- ret.BootTime = boot
- ret.Uptime = uptime(boot)
- }
-
- procs, err := process.Pids()
- if err == nil {
- ret.Procs = uint64(len(procs))
- }
-
- values, err := common.DoSysctrlWithContext(ctx, "kern.uuid")
- if err == nil && len(values) == 1 && values[0] != "" {
- ret.HostID = strings.ToLower(values[0])
- }
-
- return ret, nil
-}
-
-// cachedBootTime must be accessed via atomic.Load/StoreUint64
-var cachedBootTime uint64
-
-func BootTime() (uint64, error) {
- return BootTimeWithContext(context.Background())
-}
-
-func BootTimeWithContext(ctx context.Context) (uint64, error) {
- t := atomic.LoadUint64(&cachedBootTime)
- if t != 0 {
- return t, nil
- }
- values, err := common.DoSysctrlWithContext(ctx, "kern.boottime")
- if err != nil {
- return 0, err
- }
- // ex: { sec = 1392261637, usec = 627534 } Thu Feb 13 12:20:37 2014
- v := strings.Replace(values[2], ",", "", 1)
- boottime, err := strconv.ParseInt(v, 10, 64)
- if err != nil {
- return 0, err
- }
- t = uint64(boottime)
- atomic.StoreUint64(&cachedBootTime, t)
-
- return t, nil
-}
-
-func uptime(boot uint64) uint64 {
- return uint64(time.Now().Unix()) - boot
-}
-
-func Uptime() (uint64, error) {
- return UptimeWithContext(context.Background())
-}
-
-func UptimeWithContext(ctx context.Context) (uint64, error) {
- boot, err := BootTime()
- if err != nil {
- return 0, err
- }
- return uptime(boot), nil
-}
-
-func Users() ([]UserStat, error) {
- return UsersWithContext(context.Background())
-}
-
-func UsersWithContext(ctx context.Context) ([]UserStat, error) {
- utmpfile := "/var/run/utmpx"
- var ret []UserStat
-
- file, err := os.Open(utmpfile)
- if err != nil {
- return ret, err
- }
- defer file.Close()
-
- buf, err := ioutil.ReadAll(file)
- if err != nil {
- return ret, err
- }
-
- u := Utmpx{}
- entrySize := int(unsafe.Sizeof(u))
- count := len(buf) / entrySize
-
- for i := 0; i < count; i++ {
- b := buf[i*entrySize : i*entrySize+entrySize]
-
- var u Utmpx
- br := bytes.NewReader(b)
- err := binary.Read(br, binary.LittleEndian, &u)
- if err != nil {
- continue
- }
- if u.Type != USER_PROCESS {
- continue
- }
- user := UserStat{
- User: common.IntToString(u.User[:]),
- Terminal: common.IntToString(u.Line[:]),
- Host: common.IntToString(u.Host[:]),
- Started: int(u.Tv.Sec),
- }
- ret = append(ret, user)
- }
-
- return ret, nil
-
-}
-
-func PlatformInformation() (string, string, string, error) {
- return PlatformInformationWithContext(context.Background())
-}
-
-func PlatformInformationWithContext(ctx context.Context) (string, string, string, error) {
- platform := ""
- family := ""
- pver := ""
-
- sw_vers, err := exec.LookPath("sw_vers")
- if err != nil {
- return "", "", "", err
- }
- uname, err := exec.LookPath("uname")
- if err != nil {
- return "", "", "", err
- }
-
- out, err := invoke.CommandWithContext(ctx, uname, "-s")
- if err == nil {
- platform = strings.ToLower(strings.TrimSpace(string(out)))
- }
-
- out, err = invoke.CommandWithContext(ctx, sw_vers, "-productVersion")
- if err == nil {
- pver = strings.ToLower(strings.TrimSpace(string(out)))
- }
-
- return platform, family, pver, nil
-}
-
-func Virtualization() (string, string, error) {
- return VirtualizationWithContext(context.Background())
-}
-
-func VirtualizationWithContext(ctx context.Context) (string, string, error) {
- return "", "", common.ErrNotImplementedError
-}
-
-func KernelVersion() (string, error) {
- return KernelVersionWithContext(context.Background())
-}
-
-func KernelVersionWithContext(ctx context.Context) (string, error) {
- _, _, version, err := PlatformInformation()
- return version, err
-}
-
-func SensorsTemperatures() ([]TemperatureStat, error) {
- return SensorsTemperaturesWithContext(context.Background())
-}
-
-func SensorsTemperaturesWithContext(ctx context.Context) ([]TemperatureStat, error) {
- return []TemperatureStat{}, common.ErrNotImplementedError
-}
diff --git a/vendor/github.com/shirou/gopsutil/host/host_darwin_386.go b/vendor/github.com/shirou/gopsutil/host/host_darwin_386.go
deleted file mode 100644
index c3596f9..0000000
--- a/vendor/github.com/shirou/gopsutil/host/host_darwin_386.go
+++ /dev/null
@@ -1,19 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_darwin.go
-
-package host
-
-type Utmpx struct {
- User [256]int8
- ID [4]int8
- Line [32]int8
- Pid int32
- Type int16
- Pad_cgo_0 [6]byte
- Tv Timeval
- Host [256]int8
- Pad [16]uint32
-}
-type Timeval struct {
- Sec int32
-}
diff --git a/vendor/github.com/shirou/gopsutil/host/host_darwin_amd64.go b/vendor/github.com/shirou/gopsutil/host/host_darwin_amd64.go
deleted file mode 100644
index c3596f9..0000000
--- a/vendor/github.com/shirou/gopsutil/host/host_darwin_amd64.go
+++ /dev/null
@@ -1,19 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_darwin.go
-
-package host
-
-type Utmpx struct {
- User [256]int8
- ID [4]int8
- Line [32]int8
- Pid int32
- Type int16
- Pad_cgo_0 [6]byte
- Tv Timeval
- Host [256]int8
- Pad [16]uint32
-}
-type Timeval struct {
- Sec int32
-}
diff --git a/vendor/github.com/shirou/gopsutil/host/host_fallback.go b/vendor/github.com/shirou/gopsutil/host/host_fallback.go
deleted file mode 100644
index e80d7ea..0000000
--- a/vendor/github.com/shirou/gopsutil/host/host_fallback.go
+++ /dev/null
@@ -1,65 +0,0 @@
-// +build !darwin,!linux,!freebsd,!openbsd,!solaris,!windows
-
-package host
-
-import (
- "context"
-
- "github.com/shirou/gopsutil/internal/common"
-)
-
-func Info() (*InfoStat, error) {
- return InfoWithContext(context.Background())
-}
-
-func InfoWithContext(ctx context.Context) (*InfoStat, error) {
- return nil, common.ErrNotImplementedError
-}
-
-func BootTime() (uint64, error) {
- return BootTimeWithContext(context.Background())
-}
-
-func BootTimeWithContext(ctx context.Context) (uint64, error) {
- return 0, common.ErrNotImplementedError
-}
-
-func Uptime() (uint64, error) {
- return UptimeWithContext(context.Background())
-}
-
-func UptimeWithContext(ctx context.Context) (uint64, error) {
- return 0, common.ErrNotImplementedError
-}
-
-func Users() ([]UserStat, error) {
- return UsersWithContext(context.Background())
-}
-
-func UsersWithContext(ctx context.Context) ([]UserStat, error) {
- return []UserStat{}, common.ErrNotImplementedError
-}
-
-func Virtualization() (string, string, error) {
- return VirtualizationWithContext(context.Background())
-}
-
-func VirtualizationWithContext(ctx context.Context) (string, string, error) {
- return "", "", common.ErrNotImplementedError
-}
-
-func KernelVersion() (string, error) {
- return KernelVersionWithContext(context.Background())
-}
-
-func KernelVersionWithContext(ctx context.Context) (string, error) {
- return "", common.ErrNotImplementedError
-}
-
-func PlatformInformation() (string, string, string, error) {
- return PlatformInformationWithContext(context.Background())
-}
-
-func PlatformInformationWithContext(ctx context.Context) (string, string, string, error) {
- return "", "", "", common.ErrNotImplementedError
-}
diff --git a/vendor/github.com/shirou/gopsutil/host/host_freebsd.go b/vendor/github.com/shirou/gopsutil/host/host_freebsd.go
deleted file mode 100644
index 00a8519..0000000
--- a/vendor/github.com/shirou/gopsutil/host/host_freebsd.go
+++ /dev/null
@@ -1,245 +0,0 @@
-// +build freebsd
-
-package host
-
-import (
- "bytes"
- "context"
- "encoding/binary"
- "io/ioutil"
- "os"
- "runtime"
- "strings"
- "sync/atomic"
- "syscall"
- "time"
- "unsafe"
-
- "github.com/shirou/gopsutil/internal/common"
- "github.com/shirou/gopsutil/process"
- "golang.org/x/sys/unix"
-)
-
-const (
- UTNameSize = 16 /* see MAXLOGNAME in */
- UTLineSize = 8
- UTHostSize = 16
-)
-
-func Info() (*InfoStat, error) {
- return InfoWithContext(context.Background())
-}
-
-func InfoWithContext(ctx context.Context) (*InfoStat, error) {
- ret := &InfoStat{
- OS: runtime.GOOS,
- PlatformFamily: "freebsd",
- }
-
- hostname, err := os.Hostname()
- if err == nil {
- ret.Hostname = hostname
- }
-
- platform, family, version, err := PlatformInformation()
- if err == nil {
- ret.Platform = platform
- ret.PlatformFamily = family
- ret.PlatformVersion = version
- ret.KernelVersion = version
- }
-
- system, role, err := Virtualization()
- if err == nil {
- ret.VirtualizationSystem = system
- ret.VirtualizationRole = role
- }
-
- boot, err := BootTime()
- if err == nil {
- ret.BootTime = boot
- ret.Uptime = uptime(boot)
- }
-
- procs, err := process.Pids()
- if err == nil {
- ret.Procs = uint64(len(procs))
- }
-
- hostid, err := unix.Sysctl("kern.hostuuid")
- if err == nil && hostid != "" {
- ret.HostID = strings.ToLower(hostid)
- }
-
- return ret, nil
-}
-
-// cachedBootTime must be accessed via atomic.Load/StoreUint64
-var cachedBootTime uint64
-
-func BootTime() (uint64, error) {
- return BootTimeWithContext(context.Background())
-}
-
-func BootTimeWithContext(ctx context.Context) (uint64, error) {
- t := atomic.LoadUint64(&cachedBootTime)
- if t != 0 {
- return t, nil
- }
- buf, err := unix.SysctlRaw("kern.boottime")
- if err != nil {
- return 0, err
- }
-
- tv := *(*syscall.Timeval)(unsafe.Pointer((&buf[0])))
- atomic.StoreUint64(&cachedBootTime, uint64(tv.Sec))
-
- return t, nil
-}
-
-func uptime(boot uint64) uint64 {
- return uint64(time.Now().Unix()) - boot
-}
-
-func Uptime() (uint64, error) {
- return UptimeWithContext(context.Background())
-}
-
-func UptimeWithContext(ctx context.Context) (uint64, error) {
- boot, err := BootTime()
- if err != nil {
- return 0, err
- }
- return uptime(boot), nil
-}
-
-func Users() ([]UserStat, error) {
- return UsersWithContext(context.Background())
-}
-
-func UsersWithContext(ctx context.Context) ([]UserStat, error) {
- utmpfile := "/var/run/utx.active"
- if !common.PathExists(utmpfile) {
- utmpfile = "/var/run/utmp" // before 9.0
- return getUsersFromUtmp(utmpfile)
- }
-
- var ret []UserStat
- file, err := os.Open(utmpfile)
- if err != nil {
- return ret, err
- }
- defer file.Close()
-
- buf, err := ioutil.ReadAll(file)
- if err != nil {
- return ret, err
- }
-
- entrySize := sizeOfUtmpx
- count := len(buf) / entrySize
-
- for i := 0; i < count; i++ {
- b := buf[i*sizeOfUtmpx : (i+1)*sizeOfUtmpx]
- var u Utmpx
- br := bytes.NewReader(b)
- err := binary.Read(br, binary.LittleEndian, &u)
- if err != nil || u.Type != 4 {
- continue
- }
- sec := (binary.LittleEndian.Uint32(u.Tv.Sec[:])) / 2 // TODO:
- user := UserStat{
- User: common.IntToString(u.User[:]),
- Terminal: common.IntToString(u.Line[:]),
- Host: common.IntToString(u.Host[:]),
- Started: int(sec),
- }
-
- ret = append(ret, user)
- }
-
- return ret, nil
-
-}
-
-func PlatformInformation() (string, string, string, error) {
- return PlatformInformationWithContext(context.Background())
-}
-
-func PlatformInformationWithContext(ctx context.Context) (string, string, string, error) {
- platform, err := unix.Sysctl("kern.ostype")
- if err != nil {
- return "", "", "", err
- }
-
- version, err := unix.Sysctl("kern.osrelease")
- if err != nil {
- return "", "", "", err
- }
-
- return strings.ToLower(platform), "", strings.ToLower(version), nil
-}
-
-func Virtualization() (string, string, error) {
- return VirtualizationWithContext(context.Background())
-}
-
-func VirtualizationWithContext(ctx context.Context) (string, string, error) {
- return "", "", common.ErrNotImplementedError
-}
-
-// before 9.0
-func getUsersFromUtmp(utmpfile string) ([]UserStat, error) {
- var ret []UserStat
- file, err := os.Open(utmpfile)
- if err != nil {
- return ret, err
- }
- defer file.Close()
-
- buf, err := ioutil.ReadAll(file)
- if err != nil {
- return ret, err
- }
-
- u := Utmp{}
- entrySize := int(unsafe.Sizeof(u))
- count := len(buf) / entrySize
-
- for i := 0; i < count; i++ {
- b := buf[i*entrySize : i*entrySize+entrySize]
- var u Utmp
- br := bytes.NewReader(b)
- err := binary.Read(br, binary.LittleEndian, &u)
- if err != nil || u.Time == 0 {
- continue
- }
- user := UserStat{
- User: common.IntToString(u.Name[:]),
- Terminal: common.IntToString(u.Line[:]),
- Host: common.IntToString(u.Host[:]),
- Started: int(u.Time),
- }
-
- ret = append(ret, user)
- }
-
- return ret, nil
-}
-
-func SensorsTemperatures() ([]TemperatureStat, error) {
- return SensorsTemperaturesWithContext(context.Background())
-}
-
-func SensorsTemperaturesWithContext(ctx context.Context) ([]TemperatureStat, error) {
- return []TemperatureStat{}, common.ErrNotImplementedError
-}
-
-func KernelVersion() (string, error) {
- return KernelVersionWithContext(context.Background())
-}
-
-func KernelVersionWithContext(ctx context.Context) (string, error) {
- _, _, version, err := PlatformInformation()
- return version, err
-}
diff --git a/vendor/github.com/shirou/gopsutil/host/host_freebsd_386.go b/vendor/github.com/shirou/gopsutil/host/host_freebsd_386.go
deleted file mode 100644
index 7f06d8f..0000000
--- a/vendor/github.com/shirou/gopsutil/host/host_freebsd_386.go
+++ /dev/null
@@ -1,43 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_freebsd.go
-
-package host
-
-const (
- sizeofPtr = 0x4
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x4
- sizeofLongLong = 0x8
- sizeOfUtmpx = 197 // TODO why should 197
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int32
- _C_long_long int64
-)
-
-type Utmp struct {
- Line [8]int8
- Name [16]int8
- Host [16]int8
- Time int32
-}
-
-type Utmpx struct {
- Type int16
- Tv Timeval
- Id [8]int8
- Pid int32
- User [32]int8
- Line [16]int8
- Host [125]int8
- // X__ut_spare [64]int8
-}
-
-type Timeval struct {
- Sec [4]byte
- Usec [3]byte
-}
diff --git a/vendor/github.com/shirou/gopsutil/host/host_freebsd_amd64.go b/vendor/github.com/shirou/gopsutil/host/host_freebsd_amd64.go
deleted file mode 100644
index 3f015f0..0000000
--- a/vendor/github.com/shirou/gopsutil/host/host_freebsd_amd64.go
+++ /dev/null
@@ -1,44 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_freebsd.go
-
-package host
-
-const (
- sizeofPtr = 0x8
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x8
- sizeofLongLong = 0x8
- sizeOfUtmpx = 197 // TODO: why should 197, not 0x118
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int64
- _C_long_long int64
-)
-
-type Utmp struct {
- Line [8]int8
- Name [16]int8
- Host [16]int8
- Time int32
-}
-
-type Utmpx struct {
- Type int16
- Tv Timeval
- Id [8]int8
- Pid int32
- User [32]int8
- Line [16]int8
- Host [125]int8
- // Host [128]int8
- // X__ut_spare [64]int8
-}
-
-type Timeval struct {
- Sec [4]byte
- Usec [3]byte
-}
diff --git a/vendor/github.com/shirou/gopsutil/host/host_freebsd_arm.go b/vendor/github.com/shirou/gopsutil/host/host_freebsd_arm.go
deleted file mode 100644
index ac74980..0000000
--- a/vendor/github.com/shirou/gopsutil/host/host_freebsd_arm.go
+++ /dev/null
@@ -1,44 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_freebsd.go
-
-package host
-
-const (
- sizeofPtr = 0x4
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x8
- sizeofLongLong = 0x8
- sizeOfUtmpx = 197 // TODO: why should 197, not 0x118
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int32
- _C_long_long int64
-)
-
-type Utmp struct {
- Line [8]int8
- Name [16]int8
- Host [16]int8
- Time int32
-}
-
-type Utmpx struct {
- Type int16
- Tv Timeval
- Id [8]int8
- Pid int32
- User [32]int8
- Line [16]int8
- Host [125]int8
- // Host [128]int8
- // X__ut_spare [64]int8
-}
-
-type Timeval struct {
- Sec [4]byte
- Usec [3]byte
-}
diff --git a/vendor/github.com/shirou/gopsutil/host/host_linux.go b/vendor/github.com/shirou/gopsutil/host/host_linux.go
deleted file mode 100644
index 7ca5089..0000000
--- a/vendor/github.com/shirou/gopsutil/host/host_linux.go
+++ /dev/null
@@ -1,669 +0,0 @@
-// +build linux
-
-package host
-
-import (
- "bytes"
- "context"
- "encoding/binary"
- "fmt"
- "io/ioutil"
- "os"
- "os/exec"
- "path/filepath"
- "regexp"
- "runtime"
- "strconv"
- "strings"
- "sync/atomic"
- "time"
-
- "github.com/shirou/gopsutil/internal/common"
-)
-
-type LSB struct {
- ID string
- Release string
- Codename string
- Description string
-}
-
-// from utmp.h
-const USER_PROCESS = 7
-
-func Info() (*InfoStat, error) {
- return InfoWithContext(context.Background())
-}
-
-func InfoWithContext(ctx context.Context) (*InfoStat, error) {
- ret := &InfoStat{
- OS: runtime.GOOS,
- }
-
- hostname, err := os.Hostname()
- if err == nil {
- ret.Hostname = hostname
- }
-
- platform, family, version, err := PlatformInformation()
- if err == nil {
- ret.Platform = platform
- ret.PlatformFamily = family
- ret.PlatformVersion = version
- }
- kernelVersion, err := KernelVersion()
- if err == nil {
- ret.KernelVersion = kernelVersion
- }
-
- system, role, err := Virtualization()
- if err == nil {
- ret.VirtualizationSystem = system
- ret.VirtualizationRole = role
- }
-
- boot, err := BootTime()
- if err == nil {
- ret.BootTime = boot
- ret.Uptime = uptime(boot)
- }
-
- if numProcs, err := common.NumProcs(); err == nil {
- ret.Procs = numProcs
- }
-
- sysProductUUID := common.HostSys("class/dmi/id/product_uuid")
- switch {
- case common.PathExists(sysProductUUID):
- lines, err := common.ReadLines(sysProductUUID)
- if err == nil && len(lines) > 0 && lines[0] != "" {
- ret.HostID = strings.ToLower(lines[0])
- break
- }
- fallthrough
- default:
- values, err := common.DoSysctrl("kernel.random.boot_id")
- if err == nil && len(values) == 1 && values[0] != "" {
- ret.HostID = strings.ToLower(values[0])
- }
- }
-
- return ret, nil
-}
-
-// cachedBootTime must be accessed via atomic.Load/StoreUint64
-var cachedBootTime uint64
-
-// BootTime returns the system boot time expressed in seconds since the epoch.
-func BootTime() (uint64, error) {
- return BootTimeWithContext(context.Background())
-}
-
-func BootTimeWithContext(ctx context.Context) (uint64, error) {
- t := atomic.LoadUint64(&cachedBootTime)
- if t != 0 {
- return t, nil
- }
-
- system, role, err := Virtualization()
- if err != nil {
- return 0, err
- }
-
- statFile := "stat"
- if system == "lxc" && role == "guest" {
- // if lxc, /proc/uptime is used.
- statFile = "uptime"
- } else if system == "docker" && role == "guest" {
- // also docker, guest
- statFile = "uptime"
- }
-
- filename := common.HostProc(statFile)
- lines, err := common.ReadLines(filename)
- if err != nil {
- return 0, err
- }
-
- if statFile == "stat" {
- for _, line := range lines {
- if strings.HasPrefix(line, "btime") {
- f := strings.Fields(line)
- if len(f) != 2 {
- return 0, fmt.Errorf("wrong btime format")
- }
- b, err := strconv.ParseInt(f[1], 10, 64)
- if err != nil {
- return 0, err
- }
- t = uint64(b)
- atomic.StoreUint64(&cachedBootTime, t)
- return t, nil
- }
- }
- } else if statFile == "uptime" {
- if len(lines) != 1 {
- return 0, fmt.Errorf("wrong uptime format")
- }
- f := strings.Fields(lines[0])
- b, err := strconv.ParseFloat(f[0], 64)
- if err != nil {
- return 0, err
- }
- t = uint64(time.Now().Unix()) - uint64(b)
- atomic.StoreUint64(&cachedBootTime, t)
- return t, nil
- }
-
- return 0, fmt.Errorf("could not find btime")
-}
-
-func uptime(boot uint64) uint64 {
- return uint64(time.Now().Unix()) - boot
-}
-
-func Uptime() (uint64, error) {
- return UptimeWithContext(context.Background())
-}
-
-func UptimeWithContext(ctx context.Context) (uint64, error) {
- boot, err := BootTime()
- if err != nil {
- return 0, err
- }
- return uptime(boot), nil
-}
-
-func Users() ([]UserStat, error) {
- return UsersWithContext(context.Background())
-}
-
-func UsersWithContext(ctx context.Context) ([]UserStat, error) {
- utmpfile := common.HostVar("run/utmp")
-
- file, err := os.Open(utmpfile)
- if err != nil {
- return nil, err
- }
- defer file.Close()
-
- buf, err := ioutil.ReadAll(file)
- if err != nil {
- return nil, err
- }
-
- count := len(buf) / sizeOfUtmp
-
- ret := make([]UserStat, 0, count)
-
- for i := 0; i < count; i++ {
- b := buf[i*sizeOfUtmp : (i+1)*sizeOfUtmp]
-
- var u utmp
- br := bytes.NewReader(b)
- err := binary.Read(br, binary.LittleEndian, &u)
- if err != nil {
- continue
- }
- if u.Type != USER_PROCESS {
- continue
- }
- user := UserStat{
- User: common.IntToString(u.User[:]),
- Terminal: common.IntToString(u.Line[:]),
- Host: common.IntToString(u.Host[:]),
- Started: int(u.Tv.Sec),
- }
- ret = append(ret, user)
- }
-
- return ret, nil
-
-}
-
-func getOSRelease() (platform string, version string, err error) {
- contents, err := common.ReadLines(common.HostEtc("os-release"))
- if err != nil {
- return "", "", nil // return empty
- }
- for _, line := range contents {
- field := strings.Split(line, "=")
- if len(field) < 2 {
- continue
- }
- switch field[0] {
- case "ID": // use ID for lowercase
- platform = field[1]
- case "VERSION":
- version = field[1]
- }
- }
- return platform, version, nil
-}
-
-func getLSB() (*LSB, error) {
- ret := &LSB{}
- if common.PathExists(common.HostEtc("lsb-release")) {
- contents, err := common.ReadLines(common.HostEtc("lsb-release"))
- if err != nil {
- return ret, err // return empty
- }
- for _, line := range contents {
- field := strings.Split(line, "=")
- if len(field) < 2 {
- continue
- }
- switch field[0] {
- case "DISTRIB_ID":
- ret.ID = field[1]
- case "DISTRIB_RELEASE":
- ret.Release = field[1]
- case "DISTRIB_CODENAME":
- ret.Codename = field[1]
- case "DISTRIB_DESCRIPTION":
- ret.Description = field[1]
- }
- }
- } else if common.PathExists("/usr/bin/lsb_release") {
- lsb_release, err := exec.LookPath("/usr/bin/lsb_release")
- if err != nil {
- return ret, err
- }
- out, err := invoke.Command(lsb_release)
- if err != nil {
- return ret, err
- }
- for _, line := range strings.Split(string(out), "\n") {
- field := strings.Split(line, ":")
- if len(field) < 2 {
- continue
- }
- switch field[0] {
- case "Distributor ID":
- ret.ID = field[1]
- case "Release":
- ret.Release = field[1]
- case "Codename":
- ret.Codename = field[1]
- case "Description":
- ret.Description = field[1]
- }
- }
-
- }
-
- return ret, nil
-}
-
-func PlatformInformation() (platform string, family string, version string, err error) {
- return PlatformInformationWithContext(context.Background())
-}
-
-func PlatformInformationWithContext(ctx context.Context) (platform string, family string, version string, err error) {
-
- lsb, err := getLSB()
- if err != nil {
- lsb = &LSB{}
- }
-
- if common.PathExists(common.HostEtc("oracle-release")) {
- platform = "oracle"
- contents, err := common.ReadLines(common.HostEtc("oracle-release"))
- if err == nil {
- version = getRedhatishVersion(contents)
- }
-
- } else if common.PathExists(common.HostEtc("enterprise-release")) {
- platform = "oracle"
- contents, err := common.ReadLines(common.HostEtc("enterprise-release"))
- if err == nil {
- version = getRedhatishVersion(contents)
- }
- } else if common.PathExists(common.HostEtc("slackware-version")) {
- platform = "slackware"
- contents, err := common.ReadLines(common.HostEtc("slackware-version"))
- if err == nil {
- version = getSlackwareVersion(contents)
- }
- } else if common.PathExists(common.HostEtc("debian_version")) {
- if lsb.ID == "Ubuntu" {
- platform = "ubuntu"
- version = lsb.Release
- } else if lsb.ID == "LinuxMint" {
- platform = "linuxmint"
- version = lsb.Release
- } else {
- if common.PathExists("/usr/bin/raspi-config") {
- platform = "raspbian"
- } else {
- platform = "debian"
- }
- contents, err := common.ReadLines(common.HostEtc("debian_version"))
- if err == nil {
- version = contents[0]
- }
- }
- } else if common.PathExists(common.HostEtc("redhat-release")) {
- contents, err := common.ReadLines(common.HostEtc("redhat-release"))
- if err == nil {
- version = getRedhatishVersion(contents)
- platform = getRedhatishPlatform(contents)
- }
- } else if common.PathExists(common.HostEtc("system-release")) {
- contents, err := common.ReadLines(common.HostEtc("system-release"))
- if err == nil {
- version = getRedhatishVersion(contents)
- platform = getRedhatishPlatform(contents)
- }
- } else if common.PathExists(common.HostEtc("gentoo-release")) {
- platform = "gentoo"
- contents, err := common.ReadLines(common.HostEtc("gentoo-release"))
- if err == nil {
- version = getRedhatishVersion(contents)
- }
- } else if common.PathExists(common.HostEtc("SuSE-release")) {
- contents, err := common.ReadLines(common.HostEtc("SuSE-release"))
- if err == nil {
- version = getSuseVersion(contents)
- platform = getSusePlatform(contents)
- }
- // TODO: slackware detecion
- } else if common.PathExists(common.HostEtc("arch-release")) {
- platform = "arch"
- version = lsb.Release
- } else if common.PathExists(common.HostEtc("alpine-release")) {
- platform = "alpine"
- contents, err := common.ReadLines(common.HostEtc("alpine-release"))
- if err == nil && len(contents) > 0 {
- version = contents[0]
- }
- } else if common.PathExists(common.HostEtc("os-release")) {
- p, v, err := getOSRelease()
- if err == nil {
- platform = p
- version = v
- }
- } else if lsb.ID == "RedHat" {
- platform = "redhat"
- version = lsb.Release
- } else if lsb.ID == "Amazon" {
- platform = "amazon"
- version = lsb.Release
- } else if lsb.ID == "ScientificSL" {
- platform = "scientific"
- version = lsb.Release
- } else if lsb.ID == "XenServer" {
- platform = "xenserver"
- version = lsb.Release
- } else if lsb.ID != "" {
- platform = strings.ToLower(lsb.ID)
- version = lsb.Release
- }
-
- switch platform {
- case "debian", "ubuntu", "linuxmint", "raspbian":
- family = "debian"
- case "fedora":
- family = "fedora"
- case "oracle", "centos", "redhat", "scientific", "enterpriseenterprise", "amazon", "xenserver", "cloudlinux", "ibm_powerkvm":
- family = "rhel"
- case "suse", "opensuse":
- family = "suse"
- case "gentoo":
- family = "gentoo"
- case "slackware":
- family = "slackware"
- case "arch":
- family = "arch"
- case "exherbo":
- family = "exherbo"
- case "alpine":
- family = "alpine"
- case "coreos":
- family = "coreos"
- }
-
- return platform, family, version, nil
-
-}
-
-func KernelVersion() (version string, err error) {
- return KernelVersionWithContext(context.Background())
-}
-
-func KernelVersionWithContext(ctx context.Context) (version string, err error) {
- filename := common.HostProc("sys/kernel/osrelease")
- if common.PathExists(filename) {
- contents, err := common.ReadLines(filename)
- if err != nil {
- return "", err
- }
-
- if len(contents) > 0 {
- version = contents[0]
- }
- }
-
- return version, nil
-}
-
-func getSlackwareVersion(contents []string) string {
- c := strings.ToLower(strings.Join(contents, ""))
- c = strings.Replace(c, "slackware ", "", 1)
- return c
-}
-
-func getRedhatishVersion(contents []string) string {
- c := strings.ToLower(strings.Join(contents, ""))
-
- if strings.Contains(c, "rawhide") {
- return "rawhide"
- }
- if matches := regexp.MustCompile(`release (\d[\d.]*)`).FindStringSubmatch(c); matches != nil {
- return matches[1]
- }
- return ""
-}
-
-func getRedhatishPlatform(contents []string) string {
- c := strings.ToLower(strings.Join(contents, ""))
-
- if strings.Contains(c, "red hat") {
- return "redhat"
- }
- f := strings.Split(c, " ")
-
- return f[0]
-}
-
-func getSuseVersion(contents []string) string {
- version := ""
- for _, line := range contents {
- if matches := regexp.MustCompile(`VERSION = ([\d.]+)`).FindStringSubmatch(line); matches != nil {
- version = matches[1]
- } else if matches := regexp.MustCompile(`PATCHLEVEL = ([\d]+)`).FindStringSubmatch(line); matches != nil {
- version = version + "." + matches[1]
- }
- }
- return version
-}
-
-func getSusePlatform(contents []string) string {
- c := strings.ToLower(strings.Join(contents, ""))
- if strings.Contains(c, "opensuse") {
- return "opensuse"
- }
- return "suse"
-}
-
-func Virtualization() (string, string, error) {
- return VirtualizationWithContext(context.Background())
-}
-
-func VirtualizationWithContext(ctx context.Context) (string, string, error) {
- var system string
- var role string
-
- filename := common.HostProc("xen")
- if common.PathExists(filename) {
- system = "xen"
- role = "guest" // assume guest
-
- if common.PathExists(filepath.Join(filename, "capabilities")) {
- contents, err := common.ReadLines(filepath.Join(filename, "capabilities"))
- if err == nil {
- if common.StringsContains(contents, "control_d") {
- role = "host"
- }
- }
- }
- }
-
- filename = common.HostProc("modules")
- if common.PathExists(filename) {
- contents, err := common.ReadLines(filename)
- if err == nil {
- if common.StringsContains(contents, "kvm") {
- system = "kvm"
- role = "host"
- } else if common.StringsContains(contents, "vboxdrv") {
- system = "vbox"
- role = "host"
- } else if common.StringsContains(contents, "vboxguest") {
- system = "vbox"
- role = "guest"
- } else if common.StringsContains(contents, "vmware") {
- system = "vmware"
- role = "guest"
- }
- }
- }
-
- filename = common.HostProc("cpuinfo")
- if common.PathExists(filename) {
- contents, err := common.ReadLines(filename)
- if err == nil {
- if common.StringsContains(contents, "QEMU Virtual CPU") ||
- common.StringsContains(contents, "Common KVM processor") ||
- common.StringsContains(contents, "Common 32-bit KVM processor") {
- system = "kvm"
- role = "guest"
- }
- }
- }
-
- filename = common.HostProc()
- if common.PathExists(filepath.Join(filename, "bc", "0")) {
- system = "openvz"
- role = "host"
- } else if common.PathExists(filepath.Join(filename, "vz")) {
- system = "openvz"
- role = "guest"
- }
-
- // not use dmidecode because it requires root
- if common.PathExists(filepath.Join(filename, "self", "status")) {
- contents, err := common.ReadLines(filepath.Join(filename, "self", "status"))
- if err == nil {
-
- if common.StringsContains(contents, "s_context:") ||
- common.StringsContains(contents, "VxID:") {
- system = "linux-vserver"
- }
- // TODO: guest or host
- }
- }
-
- if common.PathExists(filepath.Join(filename, "self", "cgroup")) {
- contents, err := common.ReadLines(filepath.Join(filename, "self", "cgroup"))
- if err == nil {
- if common.StringsContains(contents, "lxc") {
- system = "lxc"
- role = "guest"
- } else if common.StringsContains(contents, "docker") {
- system = "docker"
- role = "guest"
- } else if common.StringsContains(contents, "machine-rkt") {
- system = "rkt"
- role = "guest"
- } else if common.PathExists("/usr/bin/lxc-version") {
- system = "lxc"
- role = "host"
- }
- }
- }
-
- if common.PathExists(common.HostEtc("os-release")) {
- p, _, err := getOSRelease()
- if err == nil && p == "coreos" {
- system = "rkt" // Is it true?
- role = "host"
- }
- }
- return system, role, nil
-}
-
-func SensorsTemperatures() ([]TemperatureStat, error) {
- return SensorsTemperaturesWithContext(context.Background())
-}
-
-func SensorsTemperaturesWithContext(ctx context.Context) ([]TemperatureStat, error) {
- var temperatures []TemperatureStat
- files, err := filepath.Glob(common.HostSys("/class/hwmon/hwmon*/temp*_*"))
- if err != nil {
- return temperatures, err
- }
- if len(files) == 0 {
- // CentOS has an intermediate /device directory:
- // https://github.com/giampaolo/psutil/issues/971
- files, err = filepath.Glob(common.HostSys("/class/hwmon/hwmon*/device/temp*_*"))
- if err != nil {
- return temperatures, err
- }
- }
-
- // example directory
- // device/ temp1_crit_alarm temp2_crit_alarm temp3_crit_alarm temp4_crit_alarm temp5_crit_alarm temp6_crit_alarm temp7_crit_alarm
- // name temp1_input temp2_input temp3_input temp4_input temp5_input temp6_input temp7_input
- // power/ temp1_label temp2_label temp3_label temp4_label temp5_label temp6_label temp7_label
- // subsystem/ temp1_max temp2_max temp3_max temp4_max temp5_max temp6_max temp7_max
- // temp1_crit temp2_crit temp3_crit temp4_crit temp5_crit temp6_crit temp7_crit uevent
- for _, file := range files {
- filename := strings.Split(filepath.Base(file), "_")
- if filename[1] == "label" {
- // Do not try to read the temperature of the label file
- continue
- }
-
- // Get the label of the temperature you are reading
- var label string
- c, _ := ioutil.ReadFile(filepath.Join(filepath.Dir(file), filename[0]+"_label"))
- if c != nil {
- //format the label from "Core 0" to "core0_"
- label = fmt.Sprintf("%s_", strings.Join(strings.Split(strings.TrimSpace(strings.ToLower(string(c))), " "), ""))
- }
-
- // Get the name of the tempearture you are reading
- name, err := ioutil.ReadFile(filepath.Join(filepath.Dir(file), "name"))
- if err != nil {
- return temperatures, err
- }
-
- // Get the temperature reading
- current, err := ioutil.ReadFile(file)
- if err != nil {
- return temperatures, err
- }
- temperature, err := strconv.ParseFloat(strings.TrimSpace(string(current)), 64)
- if err != nil {
- continue
- }
-
- tempName := strings.TrimSpace(strings.ToLower(string(strings.Join(filename[1:], ""))))
- temperatures = append(temperatures, TemperatureStat{
- SensorKey: fmt.Sprintf("%s_%s%s", strings.TrimSpace(string(name)), label, tempName),
- Temperature: temperature / 1000.0,
- })
- }
- return temperatures, nil
-}
diff --git a/vendor/github.com/shirou/gopsutil/host/host_linux_386.go b/vendor/github.com/shirou/gopsutil/host/host_linux_386.go
deleted file mode 100644
index 79b5cb5..0000000
--- a/vendor/github.com/shirou/gopsutil/host/host_linux_386.go
+++ /dev/null
@@ -1,45 +0,0 @@
-// ATTENTION - FILE MANUAL FIXED AFTER CGO.
-// Fixed line: Tv _Ctype_struct_timeval -> Tv UtTv
-// Created by cgo -godefs, MANUAL FIXED
-// cgo -godefs types_linux.go
-
-package host
-
-const (
- sizeofPtr = 0x4
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x4
- sizeofLongLong = 0x8
- sizeOfUtmp = 0x180
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int32
- _C_long_long int64
-)
-
-type utmp struct {
- Type int16
- Pad_cgo_0 [2]byte
- Pid int32
- Line [32]int8
- ID [4]int8
- User [32]int8
- Host [256]int8
- Exit exit_status
- Session int32
- Tv UtTv
- Addr_v6 [4]int32
- X__unused [20]int8
-}
-type exit_status struct {
- Termination int16
- Exit int16
-}
-type UtTv struct {
- Sec int32
- Usec int32
-}
diff --git a/vendor/github.com/shirou/gopsutil/host/host_linux_amd64.go b/vendor/github.com/shirou/gopsutil/host/host_linux_amd64.go
deleted file mode 100644
index 9a69652..0000000
--- a/vendor/github.com/shirou/gopsutil/host/host_linux_amd64.go
+++ /dev/null
@@ -1,48 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_linux.go
-
-package host
-
-const (
- sizeofPtr = 0x8
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x8
- sizeofLongLong = 0x8
- sizeOfUtmp = 0x180
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int64
- _C_long_long int64
-)
-
-type utmp struct {
- Type int16
- Pad_cgo_0 [2]byte
- Pid int32
- Line [32]int8
- Id [4]int8
- User [32]int8
- Host [256]int8
- Exit exit_status
- Session int32
- Tv _Ctype_struct___0
- Addr_v6 [4]int32
- X__glibc_reserved [20]int8
-}
-type exit_status struct {
- Termination int16
- Exit int16
-}
-type timeval struct {
- Sec int64
- Usec int64
-}
-
-type _Ctype_struct___0 struct {
- Sec int32
- Usec int32
-}
diff --git a/vendor/github.com/shirou/gopsutil/host/host_linux_arm.go b/vendor/github.com/shirou/gopsutil/host/host_linux_arm.go
deleted file mode 100644
index e2cf448..0000000
--- a/vendor/github.com/shirou/gopsutil/host/host_linux_arm.go
+++ /dev/null
@@ -1,43 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_linux.go | sed "s/uint8/int8/g"
-
-package host
-
-const (
- sizeofPtr = 0x4
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x4
- sizeofLongLong = 0x8
- sizeOfUtmp = 0x180
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int32
- _C_long_long int64
-)
-
-type utmp struct {
- Type int16
- Pad_cgo_0 [2]byte
- Pid int32
- Line [32]int8
- Id [4]int8
- User [32]int8
- Host [256]int8
- Exit exit_status
- Session int32
- Tv timeval
- Addr_v6 [4]int32
- X__glibc_reserved [20]int8
-}
-type exit_status struct {
- Termination int16
- Exit int16
-}
-type timeval struct {
- Sec int32
- Usec int32
-}
diff --git a/vendor/github.com/shirou/gopsutil/host/host_linux_arm64.go b/vendor/github.com/shirou/gopsutil/host/host_linux_arm64.go
deleted file mode 100644
index 37dbe5c..0000000
--- a/vendor/github.com/shirou/gopsutil/host/host_linux_arm64.go
+++ /dev/null
@@ -1,43 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_linux.go
-
-package host
-
-const (
- sizeofPtr = 0x8
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x8
- sizeofLongLong = 0x8
- sizeOfUtmp = 0x180
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int64
- _C_long_long int64
-)
-
-type utmp struct {
- Type int16
- Pad_cgo_0 [2]byte
- Pid int32
- Line [32]int8
- Id [4]int8
- User [32]int8
- Host [256]int8
- Exit exit_status
- Session int32
- Tv timeval
- Addr_v6 [4]int32
- X__glibc_reserved [20]int8
-}
-type exit_status struct {
- Termination int16
- Exit int16
-}
-type timeval struct {
- Sec int64
- Usec int64
-}
diff --git a/vendor/github.com/shirou/gopsutil/host/host_linux_mips.go b/vendor/github.com/shirou/gopsutil/host/host_linux_mips.go
deleted file mode 100644
index b0fca09..0000000
--- a/vendor/github.com/shirou/gopsutil/host/host_linux_mips.go
+++ /dev/null
@@ -1,43 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_linux.go
-
-package host
-
-const (
- sizeofPtr = 0x4
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x4
- sizeofLongLong = 0x8
- sizeOfUtmp = 0x180
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int32
- _C_long_long int64
-)
-
-type utmp struct {
- Type int16
- Pad_cgo_0 [2]byte
- Pid int32
- Line [32]int8
- Id [4]int8
- User [32]int8
- Host [256]int8
- Exit exit_status
- Session int32
- Tv timeval
- Addr_v6 [4]int32
- X__unused [20]int8
-}
-type exit_status struct {
- Termination int16
- Exit int16
-}
-type timeval struct {
- Sec int32
- Usec int32
-}
diff --git a/vendor/github.com/shirou/gopsutil/host/host_linux_mips64.go b/vendor/github.com/shirou/gopsutil/host/host_linux_mips64.go
deleted file mode 100644
index b0fca09..0000000
--- a/vendor/github.com/shirou/gopsutil/host/host_linux_mips64.go
+++ /dev/null
@@ -1,43 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_linux.go
-
-package host
-
-const (
- sizeofPtr = 0x4
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x4
- sizeofLongLong = 0x8
- sizeOfUtmp = 0x180
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int32
- _C_long_long int64
-)
-
-type utmp struct {
- Type int16
- Pad_cgo_0 [2]byte
- Pid int32
- Line [32]int8
- Id [4]int8
- User [32]int8
- Host [256]int8
- Exit exit_status
- Session int32
- Tv timeval
- Addr_v6 [4]int32
- X__unused [20]int8
-}
-type exit_status struct {
- Termination int16
- Exit int16
-}
-type timeval struct {
- Sec int32
- Usec int32
-}
diff --git a/vendor/github.com/shirou/gopsutil/host/host_linux_mips64le.go b/vendor/github.com/shirou/gopsutil/host/host_linux_mips64le.go
deleted file mode 100644
index b0fca09..0000000
--- a/vendor/github.com/shirou/gopsutil/host/host_linux_mips64le.go
+++ /dev/null
@@ -1,43 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_linux.go
-
-package host
-
-const (
- sizeofPtr = 0x4
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x4
- sizeofLongLong = 0x8
- sizeOfUtmp = 0x180
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int32
- _C_long_long int64
-)
-
-type utmp struct {
- Type int16
- Pad_cgo_0 [2]byte
- Pid int32
- Line [32]int8
- Id [4]int8
- User [32]int8
- Host [256]int8
- Exit exit_status
- Session int32
- Tv timeval
- Addr_v6 [4]int32
- X__unused [20]int8
-}
-type exit_status struct {
- Termination int16
- Exit int16
-}
-type timeval struct {
- Sec int32
- Usec int32
-}
diff --git a/vendor/github.com/shirou/gopsutil/host/host_linux_mipsle.go b/vendor/github.com/shirou/gopsutil/host/host_linux_mipsle.go
deleted file mode 100644
index b0fca09..0000000
--- a/vendor/github.com/shirou/gopsutil/host/host_linux_mipsle.go
+++ /dev/null
@@ -1,43 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_linux.go
-
-package host
-
-const (
- sizeofPtr = 0x4
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x4
- sizeofLongLong = 0x8
- sizeOfUtmp = 0x180
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int32
- _C_long_long int64
-)
-
-type utmp struct {
- Type int16
- Pad_cgo_0 [2]byte
- Pid int32
- Line [32]int8
- Id [4]int8
- User [32]int8
- Host [256]int8
- Exit exit_status
- Session int32
- Tv timeval
- Addr_v6 [4]int32
- X__unused [20]int8
-}
-type exit_status struct {
- Termination int16
- Exit int16
-}
-type timeval struct {
- Sec int32
- Usec int32
-}
diff --git a/vendor/github.com/shirou/gopsutil/host/host_linux_ppc64le.go b/vendor/github.com/shirou/gopsutil/host/host_linux_ppc64le.go
deleted file mode 100644
index d081a08..0000000
--- a/vendor/github.com/shirou/gopsutil/host/host_linux_ppc64le.go
+++ /dev/null
@@ -1,45 +0,0 @@
-// +build linux
-// +build ppc64le
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_linux.go
-
-package host
-
-const (
- sizeofPtr = 0x8
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x8
- sizeofLongLong = 0x8
- sizeOfUtmp = 0x180
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int64
- _C_long_long int64
-)
-
-type utmp struct {
- Type int16
- Pad_cgo_0 [2]byte
- Pid int32
- Line [32]int8
- Id [4]int8
- User [32]int8
- Host [256]int8
- Exit exit_status
- Session int32
- Tv timeval
- Addr_v6 [4]int32
- X__glibc_reserved [20]int8
-}
-type exit_status struct {
- Termination int16
- Exit int16
-}
-type timeval struct {
- Sec int64
- Usec int64
-}
diff --git a/vendor/github.com/shirou/gopsutil/host/host_linux_s390x.go b/vendor/github.com/shirou/gopsutil/host/host_linux_s390x.go
deleted file mode 100644
index 083fbf9..0000000
--- a/vendor/github.com/shirou/gopsutil/host/host_linux_s390x.go
+++ /dev/null
@@ -1,45 +0,0 @@
-// +build linux
-// +build s390x
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_linux.go
-
-package host
-
-const (
- sizeofPtr = 0x8
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x8
- sizeofLongLong = 0x8
- sizeOfUtmp = 0x180
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int64
- _C_long_long int64
-)
-
-type utmp struct {
- Type int16
- Pad_cgo_0 [2]byte
- Pid int32
- Line [32]int8
- Id [4]int8
- User [32]int8
- Host [256]int8
- Exit exit_status
- Session int32
- Tv timeval
- Addr_v6 [4]int32
- X__glibc_reserved [20]int8
-}
-type exit_status struct {
- Termination int16
- Exit int16
-}
-type timeval struct {
- Sec int64
- Usec int64
-}
diff --git a/vendor/github.com/shirou/gopsutil/host/host_openbsd.go b/vendor/github.com/shirou/gopsutil/host/host_openbsd.go
deleted file mode 100644
index 2ad64d7..0000000
--- a/vendor/github.com/shirou/gopsutil/host/host_openbsd.go
+++ /dev/null
@@ -1,195 +0,0 @@
-// +build openbsd
-
-package host
-
-import (
- "bytes"
- "context"
- "encoding/binary"
- "io/ioutil"
- "os"
- "os/exec"
- "runtime"
- "strconv"
- "strings"
- "time"
- "unsafe"
-
- "github.com/shirou/gopsutil/internal/common"
- "github.com/shirou/gopsutil/process"
-)
-
-const (
- UTNameSize = 32 /* see MAXLOGNAME in */
- UTLineSize = 8
- UTHostSize = 16
-)
-
-func Info() (*InfoStat, error) {
- return InfoWithContext(context.Background())
-}
-
-func InfoWithContext(ctx context.Context) (*InfoStat, error) {
- ret := &InfoStat{
- OS: runtime.GOOS,
- PlatformFamily: "openbsd",
- }
-
- hostname, err := os.Hostname()
- if err == nil {
- ret.Hostname = hostname
- }
-
- platform, family, version, err := PlatformInformation()
- if err == nil {
- ret.Platform = platform
- ret.PlatformFamily = family
- ret.PlatformVersion = version
- }
- system, role, err := Virtualization()
- if err == nil {
- ret.VirtualizationSystem = system
- ret.VirtualizationRole = role
- }
-
- procs, err := process.Pids()
- if err == nil {
- ret.Procs = uint64(len(procs))
- }
-
- boot, err := BootTime()
- if err == nil {
- ret.BootTime = boot
- ret.Uptime = uptime(boot)
- }
-
- return ret, nil
-}
-
-func BootTime() (uint64, error) {
- return BootTimeWithContext(context.Background())
-}
-
-func BootTimeWithContext(ctx context.Context) (uint64, error) {
- val, err := common.DoSysctrl("kern.boottime")
- if err != nil {
- return 0, err
- }
-
- boottime, err := strconv.ParseUint(val[0], 10, 64)
- if err != nil {
- return 0, err
- }
-
- return boottime, nil
-}
-
-func uptime(boot uint64) uint64 {
- return uint64(time.Now().Unix()) - boot
-}
-
-func Uptime() (uint64, error) {
- return UptimeWithContext(context.Background())
-}
-
-func UptimeWithContext(ctx context.Context) (uint64, error) {
- boot, err := BootTime()
- if err != nil {
- return 0, err
- }
- return uptime(boot), nil
-}
-
-func PlatformInformation() (string, string, string, error) {
- return PlatformInformationWithContext(context.Background())
-}
-
-func PlatformInformationWithContext(ctx context.Context) (string, string, string, error) {
- platform := ""
- family := ""
- version := ""
- uname, err := exec.LookPath("uname")
- if err != nil {
- return "", "", "", err
- }
-
- out, err := invoke.CommandWithContext(ctx, uname, "-s")
- if err == nil {
- platform = strings.ToLower(strings.TrimSpace(string(out)))
- }
-
- out, err = invoke.CommandWithContext(ctx, uname, "-r")
- if err == nil {
- version = strings.ToLower(strings.TrimSpace(string(out)))
- }
-
- return platform, family, version, nil
-}
-
-func Virtualization() (string, string, error) {
- return VirtualizationWithContext(context.Background())
-}
-
-func VirtualizationWithContext(ctx context.Context) (string, string, error) {
- return "", "", common.ErrNotImplementedError
-}
-
-func Users() ([]UserStat, error) {
- return UsersWithContext(context.Background())
-}
-
-func UsersWithContext(ctx context.Context) ([]UserStat, error) {
- var ret []UserStat
- utmpfile := "/var/run/utmp"
- file, err := os.Open(utmpfile)
- if err != nil {
- return ret, err
- }
- defer file.Close()
-
- buf, err := ioutil.ReadAll(file)
- if err != nil {
- return ret, err
- }
-
- u := Utmp{}
- entrySize := int(unsafe.Sizeof(u))
- count := len(buf) / entrySize
-
- for i := 0; i < count; i++ {
- b := buf[i*entrySize : i*entrySize+entrySize]
- var u Utmp
- br := bytes.NewReader(b)
- err := binary.Read(br, binary.LittleEndian, &u)
- if err != nil || u.Time == 0 {
- continue
- }
- user := UserStat{
- User: common.IntToString(u.Name[:]),
- Terminal: common.IntToString(u.Line[:]),
- Host: common.IntToString(u.Host[:]),
- Started: int(u.Time),
- }
-
- ret = append(ret, user)
- }
-
- return ret, nil
-}
-
-func SensorsTemperatures() ([]TemperatureStat, error) {
- return SensorsTemperaturesWithContext(context.Background())
-}
-
-func SensorsTemperaturesWithContext(ctx context.Context) ([]TemperatureStat, error) {
- return []TemperatureStat{}, common.ErrNotImplementedError
-}
-
-func KernelVersion() (string, error) {
- return KernelVersionWithContext(context.Background())
-}
-
-func KernelVersionWithContext(ctx context.Context) (string, error) {
- _, _, version, err := PlatformInformation()
- return version, err
-}
diff --git a/vendor/github.com/shirou/gopsutil/host/host_openbsd_amd64.go b/vendor/github.com/shirou/gopsutil/host/host_openbsd_amd64.go
deleted file mode 100644
index afe0943..0000000
--- a/vendor/github.com/shirou/gopsutil/host/host_openbsd_amd64.go
+++ /dev/null
@@ -1,31 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_openbsd.go
-
-package host
-
-const (
- sizeofPtr = 0x8
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x8
- sizeofLongLong = 0x8
- sizeOfUtmp = 0x130
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int64
- _C_long_long int64
-)
-
-type Utmp struct {
- Line [8]int8
- Name [32]int8
- Host [256]int8
- Time int64
-}
-type Timeval struct {
- Sec int64
- Usec int64
-}
diff --git a/vendor/github.com/shirou/gopsutil/host/host_solaris.go b/vendor/github.com/shirou/gopsutil/host/host_solaris.go
deleted file mode 100644
index bb83bfc..0000000
--- a/vendor/github.com/shirou/gopsutil/host/host_solaris.go
+++ /dev/null
@@ -1,248 +0,0 @@
-package host
-
-import (
- "bufio"
- "bytes"
- "context"
- "fmt"
- "io/ioutil"
- "os"
- "os/exec"
- "regexp"
- "runtime"
- "strconv"
- "strings"
- "time"
-
- "github.com/shirou/gopsutil/internal/common"
-)
-
-func Info() (*InfoStat, error) {
- return InfoWithContext(context.Background())
-}
-
-func InfoWithContext(ctx context.Context) (*InfoStat, error) {
- result := &InfoStat{
- OS: runtime.GOOS,
- }
-
- hostname, err := os.Hostname()
- if err != nil {
- return nil, err
- }
- result.Hostname = hostname
-
- // Parse versions from output of `uname(1)`
- uname, err := exec.LookPath("/usr/bin/uname")
- if err != nil {
- return nil, err
- }
-
- out, err := invoke.CommandWithContext(ctx, uname, "-srv")
- if err != nil {
- return nil, err
- }
-
- fields := strings.Fields(string(out))
- if len(fields) >= 1 {
- result.PlatformFamily = fields[0]
- }
- if len(fields) >= 2 {
- result.KernelVersion = fields[1]
- }
- if len(fields) == 3 {
- result.PlatformVersion = fields[2]
- }
-
- // Find distribution name from /etc/release
- fh, err := os.Open("/etc/release")
- if err != nil {
- return nil, err
- }
- defer fh.Close()
-
- sc := bufio.NewScanner(fh)
- if sc.Scan() {
- line := strings.TrimSpace(sc.Text())
- switch {
- case strings.HasPrefix(line, "SmartOS"):
- result.Platform = "SmartOS"
- case strings.HasPrefix(line, "OpenIndiana"):
- result.Platform = "OpenIndiana"
- case strings.HasPrefix(line, "OmniOS"):
- result.Platform = "OmniOS"
- case strings.HasPrefix(line, "Open Storage"):
- result.Platform = "NexentaStor"
- case strings.HasPrefix(line, "Solaris"):
- result.Platform = "Solaris"
- case strings.HasPrefix(line, "Oracle Solaris"):
- result.Platform = "Solaris"
- default:
- result.Platform = strings.Fields(line)[0]
- }
- }
-
- switch result.Platform {
- case "SmartOS":
- // If everything works, use the current zone ID as the HostID if present.
- zonename, err := exec.LookPath("/usr/bin/zonename")
- if err == nil {
- out, err := invoke.CommandWithContext(ctx, zonename)
- if err == nil {
- sc := bufio.NewScanner(bytes.NewReader(out))
- for sc.Scan() {
- line := sc.Text()
-
- // If we're in the global zone, rely on the hostname.
- if line == "global" {
- hostname, err := os.Hostname()
- if err == nil {
- result.HostID = hostname
- }
- } else {
- result.HostID = strings.TrimSpace(line)
- break
- }
- }
- }
- }
- }
-
- // If HostID is still empty, use hostid(1), which can lie to callers but at
- // this point there are no hardware facilities available. This behavior
- // matches that of other supported OSes.
- if result.HostID == "" {
- hostID, err := exec.LookPath("/usr/bin/hostid")
- if err == nil {
- out, err := invoke.CommandWithContext(ctx, hostID)
- if err == nil {
- sc := bufio.NewScanner(bytes.NewReader(out))
- for sc.Scan() {
- line := sc.Text()
- result.HostID = strings.TrimSpace(line)
- break
- }
- }
- }
- }
-
- // Find the boot time and calculate uptime relative to it
- bootTime, err := BootTime()
- if err != nil {
- return nil, err
- }
- result.BootTime = bootTime
- result.Uptime = uptimeSince(bootTime)
-
- // Count number of processes based on the number of entries in /proc
- dirs, err := ioutil.ReadDir("/proc")
- if err != nil {
- return nil, err
- }
- result.Procs = uint64(len(dirs))
-
- return result, nil
-}
-
-var kstatMatch = regexp.MustCompile(`([^\s]+)[\s]+([^\s]*)`)
-
-func BootTime() (uint64, error) {
- return BootTimeWithContext(context.Background())
-}
-
-func BootTimeWithContext(ctx context.Context) (uint64, error) {
- kstat, err := exec.LookPath("/usr/bin/kstat")
- if err != nil {
- return 0, err
- }
-
- out, err := invoke.CommandWithContext(ctx, kstat, "-p", "unix:0:system_misc:boot_time")
- if err != nil {
- return 0, err
- }
-
- kstats := kstatMatch.FindAllStringSubmatch(string(out), -1)
- if len(kstats) != 1 {
- return 0, fmt.Errorf("expected 1 kstat, found %d", len(kstats))
- }
-
- return strconv.ParseUint(kstats[0][2], 10, 64)
-}
-
-func Uptime() (uint64, error) {
- return UptimeWithContext(context.Background())
-}
-
-func UptimeWithContext(ctx context.Context) (uint64, error) {
- bootTime, err := BootTime()
- if err != nil {
- return 0, err
- }
- return uptimeSince(bootTime), nil
-}
-
-func uptimeSince(since uint64) uint64 {
- return uint64(time.Now().Unix()) - since
-}
-
-func Users() ([]UserStat, error) {
- return UsersWithContext(context.Background())
-}
-
-func UsersWithContext(ctx context.Context) ([]UserStat, error) {
- return []UserStat{}, common.ErrNotImplementedError
-}
-
-func SensorsTemperatures() ([]TemperatureStat, error) {
- return SensorsTemperaturesWithContext(context.Background())
-}
-
-func SensorsTemperaturesWithContext(ctx context.Context) ([]TemperatureStat, error) {
- return []TemperatureStat{}, common.ErrNotImplementedError
-}
-
-func Virtualization() (string, string, error) {
- return VirtualizationWithContext(context.Background())
-}
-
-func VirtualizationWithContext(ctx context.Context) (string, string, error) {
- return "", "", common.ErrNotImplementedError
-}
-
-func KernelVersion() (string, error) {
- return KernelVersionWithContext(context.Background())
-}
-
-func KernelVersionWithContext(ctx context.Context) (string, error) {
- // Parse versions from output of `uname(1)`
- uname, err := exec.LookPath("/usr/bin/uname")
- if err != nil {
- return "", err
- }
-
- out, err := invoke.CommandWithContext(ctx, uname, "-srv")
- if err != nil {
- return "", err
- }
-
- fields := strings.Fields(string(out))
- if len(fields) >= 2 {
- return fields[1], nil
- }
- return "", fmt.Errorf("could not get kernel version")
-}
-
-func PlatformInformation() (platform string, family string, version string, err error) {
- return PlatformInformationWithContext(context.Background())
-}
-
-func PlatformInformationWithContext(ctx context.Context) (platform string, family string, version string, err error) {
- /* This is not finished yet at all. Please contribute! */
-
- version, err = KernelVersion()
- if err != nil {
- return "", "", "", err
- }
-
- return "solaris", "solaris", version, nil
-}
diff --git a/vendor/github.com/shirou/gopsutil/host/host_windows.go b/vendor/github.com/shirou/gopsutil/host/host_windows.go
deleted file mode 100644
index d89e191..0000000
--- a/vendor/github.com/shirou/gopsutil/host/host_windows.go
+++ /dev/null
@@ -1,295 +0,0 @@
-// +build windows
-
-package host
-
-import (
- "context"
- "fmt"
- "math"
- "os"
- "runtime"
- "strings"
- "sync/atomic"
- "syscall"
- "time"
- "unsafe"
-
- "github.com/StackExchange/wmi"
- "github.com/shirou/gopsutil/internal/common"
- process "github.com/shirou/gopsutil/process"
- "golang.org/x/sys/windows"
-)
-
-var (
- procGetSystemTimeAsFileTime = common.Modkernel32.NewProc("GetSystemTimeAsFileTime")
- procGetTickCount32 = common.Modkernel32.NewProc("GetTickCount")
- procGetTickCount64 = common.Modkernel32.NewProc("GetTickCount64")
- procRtlGetVersion = common.ModNt.NewProc("RtlGetVersion")
-)
-
-// https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/wdm/ns-wdm-_osversioninfoexw
-type osVersionInfoExW struct {
- dwOSVersionInfoSize uint32
- dwMajorVersion uint32
- dwMinorVersion uint32
- dwBuildNumber uint32
- dwPlatformId uint32
- szCSDVersion [128]uint16
- wServicePackMajor uint16
- wServicePackMinor uint16
- wSuiteMask uint16
- wProductType uint8
- wReserved uint8
-}
-
-type msAcpi_ThermalZoneTemperature struct {
- Active bool
- CriticalTripPoint uint32
- CurrentTemperature uint32
- InstanceName string
-}
-
-func Info() (*InfoStat, error) {
- return InfoWithContext(context.Background())
-}
-
-func InfoWithContext(ctx context.Context) (*InfoStat, error) {
- ret := &InfoStat{
- OS: runtime.GOOS,
- }
-
- {
- hostname, err := os.Hostname()
- if err == nil {
- ret.Hostname = hostname
- }
- }
-
- {
- platform, family, version, err := PlatformInformationWithContext(ctx)
- if err == nil {
- ret.Platform = platform
- ret.PlatformFamily = family
- ret.PlatformVersion = version
- } else {
- return ret, err
- }
- }
-
- {
- boot, err := BootTime()
- if err == nil {
- ret.BootTime = boot
- ret.Uptime, _ = Uptime()
- }
- }
-
- {
- hostID, err := getMachineGuid()
- if err == nil {
- ret.HostID = strings.ToLower(hostID)
- }
- }
-
- {
- procs, err := process.Pids()
- if err == nil {
- ret.Procs = uint64(len(procs))
- }
- }
-
- return ret, nil
-}
-
-func getMachineGuid() (string, error) {
- // there has been reports of issues on 32bit using golang.org/x/sys/windows/registry, see https://github.com/shirou/gopsutil/pull/312#issuecomment-277422612
- // for rationale of using windows.RegOpenKeyEx/RegQueryValueEx instead of registry.OpenKey/GetStringValue
- var h windows.Handle
- err := windows.RegOpenKeyEx(windows.HKEY_LOCAL_MACHINE, windows.StringToUTF16Ptr(`SOFTWARE\Microsoft\Cryptography`), 0, windows.KEY_READ|windows.KEY_WOW64_64KEY, &h)
- if err != nil {
- return "", err
- }
- defer windows.RegCloseKey(h)
-
- const windowsRegBufLen = 74 // len(`{`) + len(`abcdefgh-1234-456789012-123345456671` * 2) + len(`}`) // 2 == bytes/UTF16
- const uuidLen = 36
-
- var regBuf [windowsRegBufLen]uint16
- bufLen := uint32(windowsRegBufLen)
- var valType uint32
- err = windows.RegQueryValueEx(h, windows.StringToUTF16Ptr(`MachineGuid`), nil, &valType, (*byte)(unsafe.Pointer(®Buf[0])), &bufLen)
- if err != nil {
- return "", err
- }
-
- hostID := windows.UTF16ToString(regBuf[:])
- hostIDLen := len(hostID)
- if hostIDLen != uuidLen {
- return "", fmt.Errorf("HostID incorrect: %q\n", hostID)
- }
-
- return hostID, nil
-}
-
-func Uptime() (uint64, error) {
- return UptimeWithContext(context.Background())
-}
-
-func UptimeWithContext(ctx context.Context) (uint64, error) {
- procGetTickCount := procGetTickCount64
- err := procGetTickCount64.Find()
- if err != nil {
- procGetTickCount = procGetTickCount32 // handle WinXP, but keep in mind that "the time will wrap around to zero if the system is run continuously for 49.7 days." from MSDN
- }
- r1, _, lastErr := syscall.Syscall(procGetTickCount.Addr(), 0, 0, 0, 0)
- if lastErr != 0 {
- return 0, lastErr
- }
- return uint64((time.Duration(r1) * time.Millisecond).Seconds()), nil
-}
-
-func bootTimeFromUptime(up uint64) uint64 {
- return uint64(time.Now().Unix()) - up
-}
-
-// cachedBootTime must be accessed via atomic.Load/StoreUint64
-var cachedBootTime uint64
-
-func BootTime() (uint64, error) {
- return BootTimeWithContext(context.Background())
-}
-
-func BootTimeWithContext(ctx context.Context) (uint64, error) {
- t := atomic.LoadUint64(&cachedBootTime)
- if t != 0 {
- return t, nil
- }
- up, err := Uptime()
- if err != nil {
- return 0, err
- }
- t = bootTimeFromUptime(up)
- atomic.StoreUint64(&cachedBootTime, t)
- return t, nil
-}
-
-func PlatformInformation() (platform string, family string, version string, err error) {
- return PlatformInformationWithContext(context.Background())
-}
-
-func PlatformInformationWithContext(ctx context.Context) (platform string, family string, version string, err error) {
- // GetVersionEx lies on Windows 8.1 and returns as Windows 8 if we don't declare compatibility in manifest
- // RtlGetVersion bypasses this lying layer and returns the true Windows version
- // https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/wdm/nf-wdm-rtlgetversion
- // https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/wdm/ns-wdm-_osversioninfoexw
- var osInfo osVersionInfoExW
- osInfo.dwOSVersionInfoSize = uint32(unsafe.Sizeof(osInfo))
- ret, _, err := procRtlGetVersion.Call(uintptr(unsafe.Pointer(&osInfo)))
- if ret != 0 {
- return
- }
-
- // Platform
- var h windows.Handle // like getMachineGuid(), we query the registry using the raw windows.RegOpenKeyEx/RegQueryValueEx
- err = windows.RegOpenKeyEx(windows.HKEY_LOCAL_MACHINE, windows.StringToUTF16Ptr(`SOFTWARE\Microsoft\Windows NT\CurrentVersion`), 0, windows.KEY_READ|windows.KEY_WOW64_64KEY, &h)
- if err != nil {
- return
- }
- defer windows.RegCloseKey(h)
- var bufLen uint32
- var valType uint32
- err = windows.RegQueryValueEx(h, windows.StringToUTF16Ptr(`ProductName`), nil, &valType, nil, &bufLen)
- if err != nil {
- return
- }
- regBuf := make([]uint16, bufLen/2+1)
- err = windows.RegQueryValueEx(h, windows.StringToUTF16Ptr(`ProductName`), nil, &valType, (*byte)(unsafe.Pointer(®Buf[0])), &bufLen)
- if err != nil {
- return
- }
- platform = windows.UTF16ToString(regBuf[:])
- if !strings.HasPrefix(platform, "Microsoft") {
- platform = "Microsoft " + platform
- }
- err = windows.RegQueryValueEx(h, windows.StringToUTF16Ptr(`CSDVersion`), nil, &valType, nil, &bufLen) // append Service Pack number, only on success
- if err == nil { // don't return an error if only the Service Pack retrieval fails
- regBuf = make([]uint16, bufLen/2+1)
- err = windows.RegQueryValueEx(h, windows.StringToUTF16Ptr(`CSDVersion`), nil, &valType, (*byte)(unsafe.Pointer(®Buf[0])), &bufLen)
- if err == nil {
- platform += " " + windows.UTF16ToString(regBuf[:])
- }
- }
-
- // PlatformFamily
- switch osInfo.wProductType {
- case 1:
- family = "Standalone Workstation"
- case 2:
- family = "Server (Domain Controller)"
- case 3:
- family = "Server"
- }
-
- // Platform Version
- version = fmt.Sprintf("%d.%d.%d Build %d", osInfo.dwMajorVersion, osInfo.dwMinorVersion, osInfo.dwBuildNumber, osInfo.dwBuildNumber)
-
- return platform, family, version, nil
-}
-
-func Users() ([]UserStat, error) {
- return UsersWithContext(context.Background())
-}
-
-func UsersWithContext(ctx context.Context) ([]UserStat, error) {
- var ret []UserStat
-
- return ret, nil
-}
-
-func SensorsTemperatures() ([]TemperatureStat, error) {
- return SensorsTemperaturesWithContext(context.Background())
-}
-
-func SensorsTemperaturesWithContext(ctx context.Context) ([]TemperatureStat, error) {
- var ret []TemperatureStat
- var dst []msAcpi_ThermalZoneTemperature
- q := wmi.CreateQuery(&dst, "")
- if err := common.WMIQueryWithContext(ctx, q, &dst, nil, "root/wmi"); err != nil {
- return ret, err
- }
-
- for _, v := range dst {
- ts := TemperatureStat{
- SensorKey: v.InstanceName,
- Temperature: kelvinToCelsius(v.CurrentTemperature, 2),
- }
- ret = append(ret, ts)
- }
-
- return ret, nil
-}
-
-func kelvinToCelsius(temp uint32, n int) float64 {
- // wmi return temperature Kelvin * 10, so need to divide the result by 10,
- // and then minus 273.15 to get °Celsius.
- t := float64(temp/10) - 273.15
- n10 := math.Pow10(n)
- return math.Trunc((t+0.5/n10)*n10) / n10
-}
-
-func Virtualization() (string, string, error) {
- return VirtualizationWithContext(context.Background())
-}
-
-func VirtualizationWithContext(ctx context.Context) (string, string, error) {
- return "", "", common.ErrNotImplementedError
-}
-
-func KernelVersion() (string, error) {
- return KernelVersionWithContext(context.Background())
-}
-
-func KernelVersionWithContext(ctx context.Context) (string, error) {
- _, _, version, err := PlatformInformation()
- return version, err
-}
diff --git a/vendor/github.com/shirou/gopsutil/host/types_darwin.go b/vendor/github.com/shirou/gopsutil/host/types_darwin.go
deleted file mode 100644
index b858227..0000000
--- a/vendor/github.com/shirou/gopsutil/host/types_darwin.go
+++ /dev/null
@@ -1,17 +0,0 @@
-// +build ignore
-// plus hand editing about timeval
-
-/*
-Input to cgo -godefs.
-*/
-
-package host
-
-/*
-#include
-#include
-*/
-import "C"
-
-type Utmpx C.struct_utmpx
-type Timeval C.struct_timeval
diff --git a/vendor/github.com/shirou/gopsutil/host/types_freebsd.go b/vendor/github.com/shirou/gopsutil/host/types_freebsd.go
deleted file mode 100644
index e70677f..0000000
--- a/vendor/github.com/shirou/gopsutil/host/types_freebsd.go
+++ /dev/null
@@ -1,44 +0,0 @@
-// +build ignore
-
-/*
-Input to cgo -godefs.
-*/
-
-package host
-
-/*
-#define KERNEL
-#include
-#include
-#include
-
-enum {
- sizeofPtr = sizeof(void*),
-};
-
-*/
-import "C"
-
-// Machine characteristics; for internal use.
-
-const (
- sizeofPtr = C.sizeofPtr
- sizeofShort = C.sizeof_short
- sizeofInt = C.sizeof_int
- sizeofLong = C.sizeof_long
- sizeofLongLong = C.sizeof_longlong
- sizeOfUtmpx = C.sizeof_struct_utmpx
-)
-
-// Basic types
-
-type (
- _C_short C.short
- _C_int C.int
- _C_long C.long
- _C_long_long C.longlong
-)
-
-type Utmp C.struct_utmp
-type Utmpx C.struct_utmpx
-type Timeval C.struct_timeval
diff --git a/vendor/github.com/shirou/gopsutil/host/types_linux.go b/vendor/github.com/shirou/gopsutil/host/types_linux.go
deleted file mode 100644
index 8adecb6..0000000
--- a/vendor/github.com/shirou/gopsutil/host/types_linux.go
+++ /dev/null
@@ -1,42 +0,0 @@
-// +build ignore
-
-/*
-Input to cgo -godefs.
-*/
-
-package host
-
-/*
-#include
-#include
-
-enum {
- sizeofPtr = sizeof(void*),
-};
-
-*/
-import "C"
-
-// Machine characteristics; for internal use.
-
-const (
- sizeofPtr = C.sizeofPtr
- sizeofShort = C.sizeof_short
- sizeofInt = C.sizeof_int
- sizeofLong = C.sizeof_long
- sizeofLongLong = C.sizeof_longlong
- sizeOfUtmp = C.sizeof_struct_utmp
-)
-
-// Basic types
-
-type (
- _C_short C.short
- _C_int C.int
- _C_long C.long
- _C_long_long C.longlong
-)
-
-type utmp C.struct_utmp
-type exit_status C.struct_exit_status
-type timeval C.struct_timeval
diff --git a/vendor/github.com/shirou/gopsutil/host/types_openbsd.go b/vendor/github.com/shirou/gopsutil/host/types_openbsd.go
deleted file mode 100644
index 9ebb97c..0000000
--- a/vendor/github.com/shirou/gopsutil/host/types_openbsd.go
+++ /dev/null
@@ -1,43 +0,0 @@
-// +build ignore
-
-/*
-Input to cgo -godefs.
-*/
-
-package host
-
-/*
-#define KERNEL
-#include
-#include
-#include
-
-enum {
- sizeofPtr = sizeof(void*),
-};
-
-*/
-import "C"
-
-// Machine characteristics; for internal use.
-
-const (
- sizeofPtr = C.sizeofPtr
- sizeofShort = C.sizeof_short
- sizeofInt = C.sizeof_int
- sizeofLong = C.sizeof_long
- sizeofLongLong = C.sizeof_longlong
- sizeOfUtmp = C.sizeof_struct_utmp
-)
-
-// Basic types
-
-type (
- _C_short C.short
- _C_int C.int
- _C_long C.long
- _C_long_long C.longlong
-)
-
-type Utmp C.struct_utmp
-type Timeval C.struct_timeval
diff --git a/vendor/github.com/shirou/gopsutil/internal/common/binary.go b/vendor/github.com/shirou/gopsutil/internal/common/binary.go
deleted file mode 100644
index 9b5dc55..0000000
--- a/vendor/github.com/shirou/gopsutil/internal/common/binary.go
+++ /dev/null
@@ -1,634 +0,0 @@
-package common
-
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Package binary implements simple translation between numbers and byte
-// sequences and encoding and decoding of varints.
-//
-// Numbers are translated by reading and writing fixed-size values.
-// A fixed-size value is either a fixed-size arithmetic
-// type (int8, uint8, int16, float32, complex64, ...)
-// or an array or struct containing only fixed-size values.
-//
-// The varint functions encode and decode single integer values using
-// a variable-length encoding; smaller values require fewer bytes.
-// For a specification, see
-// http://code.google.com/apis/protocolbuffers/docs/encoding.html.
-//
-// This package favors simplicity over efficiency. Clients that require
-// high-performance serialization, especially for large data structures,
-// should look at more advanced solutions such as the encoding/gob
-// package or protocol buffers.
-import (
- "errors"
- "io"
- "math"
- "reflect"
-)
-
-// A ByteOrder specifies how to convert byte sequences into
-// 16-, 32-, or 64-bit unsigned integers.
-type ByteOrder interface {
- Uint16([]byte) uint16
- Uint32([]byte) uint32
- Uint64([]byte) uint64
- PutUint16([]byte, uint16)
- PutUint32([]byte, uint32)
- PutUint64([]byte, uint64)
- String() string
-}
-
-// LittleEndian is the little-endian implementation of ByteOrder.
-var LittleEndian littleEndian
-
-// BigEndian is the big-endian implementation of ByteOrder.
-var BigEndian bigEndian
-
-type littleEndian struct{}
-
-func (littleEndian) Uint16(b []byte) uint16 { return uint16(b[0]) | uint16(b[1])<<8 }
-
-func (littleEndian) PutUint16(b []byte, v uint16) {
- b[0] = byte(v)
- b[1] = byte(v >> 8)
-}
-
-func (littleEndian) Uint32(b []byte) uint32 {
- return uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24
-}
-
-func (littleEndian) PutUint32(b []byte, v uint32) {
- b[0] = byte(v)
- b[1] = byte(v >> 8)
- b[2] = byte(v >> 16)
- b[3] = byte(v >> 24)
-}
-
-func (littleEndian) Uint64(b []byte) uint64 {
- return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 |
- uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56
-}
-
-func (littleEndian) PutUint64(b []byte, v uint64) {
- b[0] = byte(v)
- b[1] = byte(v >> 8)
- b[2] = byte(v >> 16)
- b[3] = byte(v >> 24)
- b[4] = byte(v >> 32)
- b[5] = byte(v >> 40)
- b[6] = byte(v >> 48)
- b[7] = byte(v >> 56)
-}
-
-func (littleEndian) String() string { return "LittleEndian" }
-
-func (littleEndian) GoString() string { return "binary.LittleEndian" }
-
-type bigEndian struct{}
-
-func (bigEndian) Uint16(b []byte) uint16 { return uint16(b[1]) | uint16(b[0])<<8 }
-
-func (bigEndian) PutUint16(b []byte, v uint16) {
- b[0] = byte(v >> 8)
- b[1] = byte(v)
-}
-
-func (bigEndian) Uint32(b []byte) uint32 {
- return uint32(b[3]) | uint32(b[2])<<8 | uint32(b[1])<<16 | uint32(b[0])<<24
-}
-
-func (bigEndian) PutUint32(b []byte, v uint32) {
- b[0] = byte(v >> 24)
- b[1] = byte(v >> 16)
- b[2] = byte(v >> 8)
- b[3] = byte(v)
-}
-
-func (bigEndian) Uint64(b []byte) uint64 {
- return uint64(b[7]) | uint64(b[6])<<8 | uint64(b[5])<<16 | uint64(b[4])<<24 |
- uint64(b[3])<<32 | uint64(b[2])<<40 | uint64(b[1])<<48 | uint64(b[0])<<56
-}
-
-func (bigEndian) PutUint64(b []byte, v uint64) {
- b[0] = byte(v >> 56)
- b[1] = byte(v >> 48)
- b[2] = byte(v >> 40)
- b[3] = byte(v >> 32)
- b[4] = byte(v >> 24)
- b[5] = byte(v >> 16)
- b[6] = byte(v >> 8)
- b[7] = byte(v)
-}
-
-func (bigEndian) String() string { return "BigEndian" }
-
-func (bigEndian) GoString() string { return "binary.BigEndian" }
-
-// Read reads structured binary data from r into data.
-// Data must be a pointer to a fixed-size value or a slice
-// of fixed-size values.
-// Bytes read from r are decoded using the specified byte order
-// and written to successive fields of the data.
-// When reading into structs, the field data for fields with
-// blank (_) field names is skipped; i.e., blank field names
-// may be used for padding.
-// When reading into a struct, all non-blank fields must be exported.
-func Read(r io.Reader, order ByteOrder, data interface{}) error {
- // Fast path for basic types and slices.
- if n := intDataSize(data); n != 0 {
- var b [8]byte
- var bs []byte
- if n > len(b) {
- bs = make([]byte, n)
- } else {
- bs = b[:n]
- }
- if _, err := io.ReadFull(r, bs); err != nil {
- return err
- }
- switch data := data.(type) {
- case *int8:
- *data = int8(b[0])
- case *uint8:
- *data = b[0]
- case *int16:
- *data = int16(order.Uint16(bs))
- case *uint16:
- *data = order.Uint16(bs)
- case *int32:
- *data = int32(order.Uint32(bs))
- case *uint32:
- *data = order.Uint32(bs)
- case *int64:
- *data = int64(order.Uint64(bs))
- case *uint64:
- *data = order.Uint64(bs)
- case []int8:
- for i, x := range bs { // Easier to loop over the input for 8-bit values.
- data[i] = int8(x)
- }
- case []uint8:
- copy(data, bs)
- case []int16:
- for i := range data {
- data[i] = int16(order.Uint16(bs[2*i:]))
- }
- case []uint16:
- for i := range data {
- data[i] = order.Uint16(bs[2*i:])
- }
- case []int32:
- for i := range data {
- data[i] = int32(order.Uint32(bs[4*i:]))
- }
- case []uint32:
- for i := range data {
- data[i] = order.Uint32(bs[4*i:])
- }
- case []int64:
- for i := range data {
- data[i] = int64(order.Uint64(bs[8*i:]))
- }
- case []uint64:
- for i := range data {
- data[i] = order.Uint64(bs[8*i:])
- }
- }
- return nil
- }
-
- // Fallback to reflect-based decoding.
- v := reflect.ValueOf(data)
- size := -1
- switch v.Kind() {
- case reflect.Ptr:
- v = v.Elem()
- size = dataSize(v)
- case reflect.Slice:
- size = dataSize(v)
- }
- if size < 0 {
- return errors.New("binary.Read: invalid type " + reflect.TypeOf(data).String())
- }
- d := &decoder{order: order, buf: make([]byte, size)}
- if _, err := io.ReadFull(r, d.buf); err != nil {
- return err
- }
- d.value(v)
- return nil
-}
-
-// Write writes the binary representation of data into w.
-// Data must be a fixed-size value or a slice of fixed-size
-// values, or a pointer to such data.
-// Bytes written to w are encoded using the specified byte order
-// and read from successive fields of the data.
-// When writing structs, zero values are written for fields
-// with blank (_) field names.
-func Write(w io.Writer, order ByteOrder, data interface{}) error {
- // Fast path for basic types and slices.
- if n := intDataSize(data); n != 0 {
- var b [8]byte
- var bs []byte
- if n > len(b) {
- bs = make([]byte, n)
- } else {
- bs = b[:n]
- }
- switch v := data.(type) {
- case *int8:
- bs = b[:1]
- b[0] = byte(*v)
- case int8:
- bs = b[:1]
- b[0] = byte(v)
- case []int8:
- for i, x := range v {
- bs[i] = byte(x)
- }
- case *uint8:
- bs = b[:1]
- b[0] = *v
- case uint8:
- bs = b[:1]
- b[0] = byte(v)
- case []uint8:
- bs = v
- case *int16:
- bs = b[:2]
- order.PutUint16(bs, uint16(*v))
- case int16:
- bs = b[:2]
- order.PutUint16(bs, uint16(v))
- case []int16:
- for i, x := range v {
- order.PutUint16(bs[2*i:], uint16(x))
- }
- case *uint16:
- bs = b[:2]
- order.PutUint16(bs, *v)
- case uint16:
- bs = b[:2]
- order.PutUint16(bs, v)
- case []uint16:
- for i, x := range v {
- order.PutUint16(bs[2*i:], x)
- }
- case *int32:
- bs = b[:4]
- order.PutUint32(bs, uint32(*v))
- case int32:
- bs = b[:4]
- order.PutUint32(bs, uint32(v))
- case []int32:
- for i, x := range v {
- order.PutUint32(bs[4*i:], uint32(x))
- }
- case *uint32:
- bs = b[:4]
- order.PutUint32(bs, *v)
- case uint32:
- bs = b[:4]
- order.PutUint32(bs, v)
- case []uint32:
- for i, x := range v {
- order.PutUint32(bs[4*i:], x)
- }
- case *int64:
- bs = b[:8]
- order.PutUint64(bs, uint64(*v))
- case int64:
- bs = b[:8]
- order.PutUint64(bs, uint64(v))
- case []int64:
- for i, x := range v {
- order.PutUint64(bs[8*i:], uint64(x))
- }
- case *uint64:
- bs = b[:8]
- order.PutUint64(bs, *v)
- case uint64:
- bs = b[:8]
- order.PutUint64(bs, v)
- case []uint64:
- for i, x := range v {
- order.PutUint64(bs[8*i:], x)
- }
- }
- _, err := w.Write(bs)
- return err
- }
-
- // Fallback to reflect-based encoding.
- v := reflect.Indirect(reflect.ValueOf(data))
- size := dataSize(v)
- if size < 0 {
- return errors.New("binary.Write: invalid type " + reflect.TypeOf(data).String())
- }
- buf := make([]byte, size)
- e := &encoder{order: order, buf: buf}
- e.value(v)
- _, err := w.Write(buf)
- return err
-}
-
-// Size returns how many bytes Write would generate to encode the value v, which
-// must be a fixed-size value or a slice of fixed-size values, or a pointer to such data.
-// If v is neither of these, Size returns -1.
-func Size(v interface{}) int {
- return dataSize(reflect.Indirect(reflect.ValueOf(v)))
-}
-
-// dataSize returns the number of bytes the actual data represented by v occupies in memory.
-// For compound structures, it sums the sizes of the elements. Thus, for instance, for a slice
-// it returns the length of the slice times the element size and does not count the memory
-// occupied by the header. If the type of v is not acceptable, dataSize returns -1.
-func dataSize(v reflect.Value) int {
- if v.Kind() == reflect.Slice {
- if s := sizeof(v.Type().Elem()); s >= 0 {
- return s * v.Len()
- }
- return -1
- }
- return sizeof(v.Type())
-}
-
-// sizeof returns the size >= 0 of variables for the given type or -1 if the type is not acceptable.
-func sizeof(t reflect.Type) int {
- switch t.Kind() {
- case reflect.Array:
- if s := sizeof(t.Elem()); s >= 0 {
- return s * t.Len()
- }
-
- case reflect.Struct:
- sum := 0
- for i, n := 0, t.NumField(); i < n; i++ {
- s := sizeof(t.Field(i).Type)
- if s < 0 {
- return -1
- }
- sum += s
- }
- return sum
-
- case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64,
- reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
- reflect.Float32, reflect.Float64, reflect.Complex64, reflect.Complex128, reflect.Ptr:
- return int(t.Size())
- }
-
- return -1
-}
-
-type coder struct {
- order ByteOrder
- buf []byte
-}
-
-type decoder coder
-type encoder coder
-
-func (d *decoder) uint8() uint8 {
- x := d.buf[0]
- d.buf = d.buf[1:]
- return x
-}
-
-func (e *encoder) uint8(x uint8) {
- e.buf[0] = x
- e.buf = e.buf[1:]
-}
-
-func (d *decoder) uint16() uint16 {
- x := d.order.Uint16(d.buf[0:2])
- d.buf = d.buf[2:]
- return x
-}
-
-func (e *encoder) uint16(x uint16) {
- e.order.PutUint16(e.buf[0:2], x)
- e.buf = e.buf[2:]
-}
-
-func (d *decoder) uint32() uint32 {
- x := d.order.Uint32(d.buf[0:4])
- d.buf = d.buf[4:]
- return x
-}
-
-func (e *encoder) uint32(x uint32) {
- e.order.PutUint32(e.buf[0:4], x)
- e.buf = e.buf[4:]
-}
-
-func (d *decoder) uint64() uint64 {
- x := d.order.Uint64(d.buf[0:8])
- d.buf = d.buf[8:]
- return x
-}
-
-func (e *encoder) uint64(x uint64) {
- e.order.PutUint64(e.buf[0:8], x)
- e.buf = e.buf[8:]
-}
-
-func (d *decoder) int8() int8 { return int8(d.uint8()) }
-
-func (e *encoder) int8(x int8) { e.uint8(uint8(x)) }
-
-func (d *decoder) int16() int16 { return int16(d.uint16()) }
-
-func (e *encoder) int16(x int16) { e.uint16(uint16(x)) }
-
-func (d *decoder) int32() int32 { return int32(d.uint32()) }
-
-func (e *encoder) int32(x int32) { e.uint32(uint32(x)) }
-
-func (d *decoder) int64() int64 { return int64(d.uint64()) }
-
-func (e *encoder) int64(x int64) { e.uint64(uint64(x)) }
-
-func (d *decoder) value(v reflect.Value) {
- switch v.Kind() {
- case reflect.Array:
- l := v.Len()
- for i := 0; i < l; i++ {
- d.value(v.Index(i))
- }
-
- case reflect.Struct:
- t := v.Type()
- l := v.NumField()
- for i := 0; i < l; i++ {
- // Note: Calling v.CanSet() below is an optimization.
- // It would be sufficient to check the field name,
- // but creating the StructField info for each field is
- // costly (run "go test -bench=ReadStruct" and compare
- // results when making changes to this code).
- if v := v.Field(i); v.CanSet() || t.Field(i).Name != "_" {
- d.value(v)
- } else {
- d.skip(v)
- }
- }
-
- case reflect.Slice:
- l := v.Len()
- for i := 0; i < l; i++ {
- d.value(v.Index(i))
- }
-
- case reflect.Int8:
- v.SetInt(int64(d.int8()))
- case reflect.Int16:
- v.SetInt(int64(d.int16()))
- case reflect.Int32:
- v.SetInt(int64(d.int32()))
- case reflect.Int64:
- v.SetInt(d.int64())
-
- case reflect.Uint8:
- v.SetUint(uint64(d.uint8()))
- case reflect.Uint16:
- v.SetUint(uint64(d.uint16()))
- case reflect.Uint32:
- v.SetUint(uint64(d.uint32()))
- case reflect.Uint64:
- v.SetUint(d.uint64())
-
- case reflect.Float32:
- v.SetFloat(float64(math.Float32frombits(d.uint32())))
- case reflect.Float64:
- v.SetFloat(math.Float64frombits(d.uint64()))
-
- case reflect.Complex64:
- v.SetComplex(complex(
- float64(math.Float32frombits(d.uint32())),
- float64(math.Float32frombits(d.uint32())),
- ))
- case reflect.Complex128:
- v.SetComplex(complex(
- math.Float64frombits(d.uint64()),
- math.Float64frombits(d.uint64()),
- ))
- }
-}
-
-func (e *encoder) value(v reflect.Value) {
- switch v.Kind() {
- case reflect.Array:
- l := v.Len()
- for i := 0; i < l; i++ {
- e.value(v.Index(i))
- }
-
- case reflect.Struct:
- t := v.Type()
- l := v.NumField()
- for i := 0; i < l; i++ {
- // see comment for corresponding code in decoder.value()
- if v := v.Field(i); v.CanSet() || t.Field(i).Name != "_" {
- e.value(v)
- } else {
- e.skip(v)
- }
- }
-
- case reflect.Slice:
- l := v.Len()
- for i := 0; i < l; i++ {
- e.value(v.Index(i))
- }
-
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- switch v.Type().Kind() {
- case reflect.Int8:
- e.int8(int8(v.Int()))
- case reflect.Int16:
- e.int16(int16(v.Int()))
- case reflect.Int32:
- e.int32(int32(v.Int()))
- case reflect.Int64:
- e.int64(v.Int())
- }
-
- case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
- switch v.Type().Kind() {
- case reflect.Uint8:
- e.uint8(uint8(v.Uint()))
- case reflect.Uint16:
- e.uint16(uint16(v.Uint()))
- case reflect.Uint32:
- e.uint32(uint32(v.Uint()))
- case reflect.Uint64:
- e.uint64(v.Uint())
- }
-
- case reflect.Float32, reflect.Float64:
- switch v.Type().Kind() {
- case reflect.Float32:
- e.uint32(math.Float32bits(float32(v.Float())))
- case reflect.Float64:
- e.uint64(math.Float64bits(v.Float()))
- }
-
- case reflect.Complex64, reflect.Complex128:
- switch v.Type().Kind() {
- case reflect.Complex64:
- x := v.Complex()
- e.uint32(math.Float32bits(float32(real(x))))
- e.uint32(math.Float32bits(float32(imag(x))))
- case reflect.Complex128:
- x := v.Complex()
- e.uint64(math.Float64bits(real(x)))
- e.uint64(math.Float64bits(imag(x)))
- }
- }
-}
-
-func (d *decoder) skip(v reflect.Value) {
- d.buf = d.buf[dataSize(v):]
-}
-
-func (e *encoder) skip(v reflect.Value) {
- n := dataSize(v)
- for i := range e.buf[0:n] {
- e.buf[i] = 0
- }
- e.buf = e.buf[n:]
-}
-
-// intDataSize returns the size of the data required to represent the data when encoded.
-// It returns zero if the type cannot be implemented by the fast path in Read or Write.
-func intDataSize(data interface{}) int {
- switch data := data.(type) {
- case int8, *int8, *uint8:
- return 1
- case []int8:
- return len(data)
- case []uint8:
- return len(data)
- case int16, *int16, *uint16:
- return 2
- case []int16:
- return 2 * len(data)
- case []uint16:
- return 2 * len(data)
- case int32, *int32, *uint32:
- return 4
- case []int32:
- return 4 * len(data)
- case []uint32:
- return 4 * len(data)
- case int64, *int64, *uint64:
- return 8
- case []int64:
- return 8 * len(data)
- case []uint64:
- return 8 * len(data)
- }
- return 0
-}
diff --git a/vendor/github.com/shirou/gopsutil/internal/common/common.go b/vendor/github.com/shirou/gopsutil/internal/common/common.go
deleted file mode 100644
index 71c2257..0000000
--- a/vendor/github.com/shirou/gopsutil/internal/common/common.go
+++ /dev/null
@@ -1,392 +0,0 @@
-package common
-
-//
-// gopsutil is a port of psutil(http://pythonhosted.org/psutil/).
-// This covers these architectures.
-// - linux (amd64, arm)
-// - freebsd (amd64)
-// - windows (amd64)
-import (
- "bufio"
- "bytes"
- "context"
- "errors"
- "fmt"
- "io/ioutil"
- "net/url"
- "os"
- "os/exec"
- "path"
- "path/filepath"
- "reflect"
- "runtime"
- "strconv"
- "strings"
- "time"
-)
-
-var (
- Timeout = 3 * time.Second
- ErrTimeout = errors.New("command timed out")
-)
-
-type Invoker interface {
- Command(string, ...string) ([]byte, error)
- CommandWithContext(context.Context, string, ...string) ([]byte, error)
-}
-
-type Invoke struct{}
-
-func (i Invoke) Command(name string, arg ...string) ([]byte, error) {
- ctx, cancel := context.WithTimeout(context.Background(), Timeout)
- defer cancel()
- return i.CommandWithContext(ctx, name, arg...)
-}
-
-func (i Invoke) CommandWithContext(ctx context.Context, name string, arg ...string) ([]byte, error) {
- cmd := exec.CommandContext(ctx, name, arg...)
-
- var buf bytes.Buffer
- cmd.Stdout = &buf
- cmd.Stderr = &buf
-
- if err := cmd.Start(); err != nil {
- return buf.Bytes(), err
- }
-
- if err := cmd.Wait(); err != nil {
- return buf.Bytes(), err
- }
-
- return buf.Bytes(), nil
-}
-
-type FakeInvoke struct {
- Suffix string // Suffix species expected file name suffix such as "fail"
- Error error // If Error specfied, return the error.
-}
-
-// Command in FakeInvoke returns from expected file if exists.
-func (i FakeInvoke) Command(name string, arg ...string) ([]byte, error) {
- if i.Error != nil {
- return []byte{}, i.Error
- }
-
- arch := runtime.GOOS
-
- commandName := filepath.Base(name)
-
- fname := strings.Join(append([]string{commandName}, arg...), "")
- fname = url.QueryEscape(fname)
- fpath := path.Join("testdata", arch, fname)
- if i.Suffix != "" {
- fpath += "_" + i.Suffix
- }
- if PathExists(fpath) {
- return ioutil.ReadFile(fpath)
- }
- return []byte{}, fmt.Errorf("could not find testdata: %s", fpath)
-}
-
-func (i FakeInvoke) CommandWithContext(ctx context.Context, name string, arg ...string) ([]byte, error) {
- return i.Command(name, arg...)
-}
-
-var ErrNotImplementedError = errors.New("not implemented yet")
-
-// ReadLines reads contents from a file and splits them by new lines.
-// A convenience wrapper to ReadLinesOffsetN(filename, 0, -1).
-func ReadLines(filename string) ([]string, error) {
- return ReadLinesOffsetN(filename, 0, -1)
-}
-
-// ReadLines reads contents from file and splits them by new line.
-// The offset tells at which line number to start.
-// The count determines the number of lines to read (starting from offset):
-// n >= 0: at most n lines
-// n < 0: whole file
-func ReadLinesOffsetN(filename string, offset uint, n int) ([]string, error) {
- f, err := os.Open(filename)
- if err != nil {
- return []string{""}, err
- }
- defer f.Close()
-
- var ret []string
-
- r := bufio.NewReader(f)
- for i := 0; i < n+int(offset) || n < 0; i++ {
- line, err := r.ReadString('\n')
- if err != nil {
- break
- }
- if i < int(offset) {
- continue
- }
- ret = append(ret, strings.Trim(line, "\n"))
- }
-
- return ret, nil
-}
-
-func IntToString(orig []int8) string {
- ret := make([]byte, len(orig))
- size := -1
- for i, o := range orig {
- if o == 0 {
- size = i
- break
- }
- ret[i] = byte(o)
- }
- if size == -1 {
- size = len(orig)
- }
-
- return string(ret[0:size])
-}
-
-func UintToString(orig []uint8) string {
- ret := make([]byte, len(orig))
- size := -1
- for i, o := range orig {
- if o == 0 {
- size = i
- break
- }
- ret[i] = byte(o)
- }
- if size == -1 {
- size = len(orig)
- }
-
- return string(ret[0:size])
-}
-
-func ByteToString(orig []byte) string {
- n := -1
- l := -1
- for i, b := range orig {
- // skip left side null
- if l == -1 && b == 0 {
- continue
- }
- if l == -1 {
- l = i
- }
-
- if b == 0 {
- break
- }
- n = i + 1
- }
- if n == -1 {
- return string(orig)
- }
- return string(orig[l:n])
-}
-
-// ReadInts reads contents from single line file and returns them as []int32.
-func ReadInts(filename string) ([]int64, error) {
- f, err := os.Open(filename)
- if err != nil {
- return []int64{}, err
- }
- defer f.Close()
-
- var ret []int64
-
- r := bufio.NewReader(f)
-
- // The int files that this is concerned with should only be one liners.
- line, err := r.ReadString('\n')
- if err != nil {
- return []int64{}, err
- }
-
- i, err := strconv.ParseInt(strings.Trim(line, "\n"), 10, 32)
- if err != nil {
- return []int64{}, err
- }
- ret = append(ret, i)
-
- return ret, nil
-}
-
-// Parse to int32 without error
-func mustParseInt32(val string) int32 {
- vv, _ := strconv.ParseInt(val, 10, 32)
- return int32(vv)
-}
-
-// Parse to uint64 without error
-func mustParseUint64(val string) uint64 {
- vv, _ := strconv.ParseInt(val, 10, 64)
- return uint64(vv)
-}
-
-// Parse to Float64 without error
-func mustParseFloat64(val string) float64 {
- vv, _ := strconv.ParseFloat(val, 64)
- return vv
-}
-
-// StringsHas checks the target string slice contains src or not
-func StringsHas(target []string, src string) bool {
- for _, t := range target {
- if strings.TrimSpace(t) == src {
- return true
- }
- }
- return false
-}
-
-// StringsContains checks the src in any string of the target string slice
-func StringsContains(target []string, src string) bool {
- for _, t := range target {
- if strings.Contains(t, src) {
- return true
- }
- }
- return false
-}
-
-// IntContains checks the src in any int of the target int slice.
-func IntContains(target []int, src int) bool {
- for _, t := range target {
- if src == t {
- return true
- }
- }
- return false
-}
-
-// get struct attributes.
-// This method is used only for debugging platform dependent code.
-func attributes(m interface{}) map[string]reflect.Type {
- typ := reflect.TypeOf(m)
- if typ.Kind() == reflect.Ptr {
- typ = typ.Elem()
- }
-
- attrs := make(map[string]reflect.Type)
- if typ.Kind() != reflect.Struct {
- return nil
- }
-
- for i := 0; i < typ.NumField(); i++ {
- p := typ.Field(i)
- if !p.Anonymous {
- attrs[p.Name] = p.Type
- }
- }
-
- return attrs
-}
-
-func PathExists(filename string) bool {
- if _, err := os.Stat(filename); err == nil {
- return true
- }
- return false
-}
-
-//GetEnv retrieves the environment variable key. If it does not exist it returns the default.
-func GetEnv(key string, dfault string, combineWith ...string) string {
- value := os.Getenv(key)
- if value == "" {
- value = dfault
- }
-
- switch len(combineWith) {
- case 0:
- return value
- case 1:
- return filepath.Join(value, combineWith[0])
- default:
- all := make([]string, len(combineWith)+1)
- all[0] = value
- copy(all[1:], combineWith)
- return filepath.Join(all...)
- }
- panic("invalid switch case")
-}
-
-func HostProc(combineWith ...string) string {
- return GetEnv("HOST_PROC", "/proc", combineWith...)
-}
-
-func HostSys(combineWith ...string) string {
- return GetEnv("HOST_SYS", "/sys", combineWith...)
-}
-
-func HostEtc(combineWith ...string) string {
- return GetEnv("HOST_ETC", "/etc", combineWith...)
-}
-
-func HostVar(combineWith ...string) string {
- return GetEnv("HOST_VAR", "/var", combineWith...)
-}
-
-func HostRun(combineWith ...string) string {
- return GetEnv("HOST_RUN", "/run", combineWith...)
-}
-
-// https://gist.github.com/kylelemons/1525278
-func Pipeline(cmds ...*exec.Cmd) ([]byte, []byte, error) {
- // Require at least one command
- if len(cmds) < 1 {
- return nil, nil, nil
- }
-
- // Collect the output from the command(s)
- var output bytes.Buffer
- var stderr bytes.Buffer
-
- last := len(cmds) - 1
- for i, cmd := range cmds[:last] {
- var err error
- // Connect each command's stdin to the previous command's stdout
- if cmds[i+1].Stdin, err = cmd.StdoutPipe(); err != nil {
- return nil, nil, err
- }
- // Connect each command's stderr to a buffer
- cmd.Stderr = &stderr
- }
-
- // Connect the output and error for the last command
- cmds[last].Stdout, cmds[last].Stderr = &output, &stderr
-
- // Start each command
- for _, cmd := range cmds {
- if err := cmd.Start(); err != nil {
- return output.Bytes(), stderr.Bytes(), err
- }
- }
-
- // Wait for each command to complete
- for _, cmd := range cmds {
- if err := cmd.Wait(); err != nil {
- return output.Bytes(), stderr.Bytes(), err
- }
- }
-
- // Return the pipeline output and the collected standard error
- return output.Bytes(), stderr.Bytes(), nil
-}
-
-// getSysctrlEnv sets LC_ALL=C in a list of env vars for use when running
-// sysctl commands (see DoSysctrl).
-func getSysctrlEnv(env []string) []string {
- foundLC := false
- for i, line := range env {
- if strings.HasPrefix(line, "LC_ALL") {
- env[i] = "LC_ALL=C"
- foundLC = true
- }
- }
- if !foundLC {
- env = append(env, "LC_ALL=C")
- }
- return env
-}
diff --git a/vendor/github.com/shirou/gopsutil/internal/common/common_darwin.go b/vendor/github.com/shirou/gopsutil/internal/common/common_darwin.go
deleted file mode 100644
index 3e85cc0..0000000
--- a/vendor/github.com/shirou/gopsutil/internal/common/common_darwin.go
+++ /dev/null
@@ -1,69 +0,0 @@
-// +build darwin
-
-package common
-
-import (
- "context"
- "os"
- "os/exec"
- "strings"
- "unsafe"
-
- "golang.org/x/sys/unix"
-)
-
-func DoSysctrlWithContext(ctx context.Context, mib string) ([]string, error) {
- sysctl, err := exec.LookPath("/usr/sbin/sysctl")
- if err != nil {
- return []string{}, err
- }
- cmd := exec.CommandContext(ctx, sysctl, "-n", mib)
- cmd.Env = getSysctrlEnv(os.Environ())
- out, err := cmd.Output()
- if err != nil {
- return []string{}, err
- }
- v := strings.Replace(string(out), "{ ", "", 1)
- v = strings.Replace(string(v), " }", "", 1)
- values := strings.Fields(string(v))
-
- return values, nil
-}
-
-func CallSyscall(mib []int32) ([]byte, uint64, error) {
- miblen := uint64(len(mib))
-
- // get required buffer size
- length := uint64(0)
- _, _, err := unix.Syscall6(
- unix.SYS___SYSCTL,
- uintptr(unsafe.Pointer(&mib[0])),
- uintptr(miblen),
- 0,
- uintptr(unsafe.Pointer(&length)),
- 0,
- 0)
- if err != 0 {
- var b []byte
- return b, length, err
- }
- if length == 0 {
- var b []byte
- return b, length, err
- }
- // get proc info itself
- buf := make([]byte, length)
- _, _, err = unix.Syscall6(
- unix.SYS___SYSCTL,
- uintptr(unsafe.Pointer(&mib[0])),
- uintptr(miblen),
- uintptr(unsafe.Pointer(&buf[0])),
- uintptr(unsafe.Pointer(&length)),
- 0,
- 0)
- if err != 0 {
- return buf, length, err
- }
-
- return buf, length, nil
-}
diff --git a/vendor/github.com/shirou/gopsutil/internal/common/common_freebsd.go b/vendor/github.com/shirou/gopsutil/internal/common/common_freebsd.go
deleted file mode 100644
index 107e2c9..0000000
--- a/vendor/github.com/shirou/gopsutil/internal/common/common_freebsd.go
+++ /dev/null
@@ -1,69 +0,0 @@
-// +build freebsd openbsd
-
-package common
-
-import (
- "os"
- "os/exec"
- "strings"
- "unsafe"
-
- "golang.org/x/sys/unix"
-)
-
-func DoSysctrl(mib string) ([]string, error) {
- sysctl, err := exec.LookPath("/sbin/sysctl")
- if err != nil {
- return []string{}, err
- }
- cmd := exec.Command(sysctl, "-n", mib)
- cmd.Env = getSysctrlEnv(os.Environ())
- out, err := cmd.Output()
- if err != nil {
- return []string{}, err
- }
- v := strings.Replace(string(out), "{ ", "", 1)
- v = strings.Replace(string(v), " }", "", 1)
- values := strings.Fields(string(v))
-
- return values, nil
-}
-
-func CallSyscall(mib []int32) ([]byte, uint64, error) {
- mibptr := unsafe.Pointer(&mib[0])
- miblen := uint64(len(mib))
-
- // get required buffer size
- length := uint64(0)
- _, _, err := unix.Syscall6(
- unix.SYS___SYSCTL,
- uintptr(mibptr),
- uintptr(miblen),
- 0,
- uintptr(unsafe.Pointer(&length)),
- 0,
- 0)
- if err != 0 {
- var b []byte
- return b, length, err
- }
- if length == 0 {
- var b []byte
- return b, length, err
- }
- // get proc info itself
- buf := make([]byte, length)
- _, _, err = unix.Syscall6(
- unix.SYS___SYSCTL,
- uintptr(mibptr),
- uintptr(miblen),
- uintptr(unsafe.Pointer(&buf[0])),
- uintptr(unsafe.Pointer(&length)),
- 0,
- 0)
- if err != 0 {
- return buf, length, err
- }
-
- return buf, length, nil
-}
diff --git a/vendor/github.com/shirou/gopsutil/internal/common/common_linux.go b/vendor/github.com/shirou/gopsutil/internal/common/common_linux.go
deleted file mode 100644
index 4e829e0..0000000
--- a/vendor/github.com/shirou/gopsutil/internal/common/common_linux.go
+++ /dev/null
@@ -1,41 +0,0 @@
-// +build linux
-
-package common
-
-import (
- "os"
- "os/exec"
- "strings"
-)
-
-func DoSysctrl(mib string) ([]string, error) {
- sysctl, err := exec.LookPath("/sbin/sysctl")
- if err != nil {
- return []string{}, err
- }
- cmd := exec.Command(sysctl, "-n", mib)
- cmd.Env = getSysctrlEnv(os.Environ())
- out, err := cmd.Output()
- if err != nil {
- return []string{}, err
- }
- v := strings.Replace(string(out), "{ ", "", 1)
- v = strings.Replace(string(v), " }", "", 1)
- values := strings.Fields(string(v))
-
- return values, nil
-}
-
-func NumProcs() (uint64, error) {
- f, err := os.Open(HostProc())
- if err != nil {
- return 0, err
- }
- defer f.Close()
-
- list, err := f.Readdirnames(-1)
- if err != nil {
- return 0, err
- }
- return uint64(len(list)), err
-}
diff --git a/vendor/github.com/shirou/gopsutil/internal/common/common_openbsd.go b/vendor/github.com/shirou/gopsutil/internal/common/common_openbsd.go
deleted file mode 100644
index 398f785..0000000
--- a/vendor/github.com/shirou/gopsutil/internal/common/common_openbsd.go
+++ /dev/null
@@ -1,69 +0,0 @@
-// +build openbsd
-
-package common
-
-import (
- "os"
- "os/exec"
- "strings"
- "unsafe"
-
- "golang.org/x/sys/unix"
-)
-
-func DoSysctrl(mib string) ([]string, error) {
- sysctl, err := exec.LookPath("/sbin/sysctl")
- if err != nil {
- return []string{}, err
- }
- cmd := exec.Command(sysctl, "-n", mib)
- cmd.Env = getSysctrlEnv(os.Environ())
- out, err := cmd.Output()
- if err != nil {
- return []string{}, err
- }
- v := strings.Replace(string(out), "{ ", "", 1)
- v = strings.Replace(string(v), " }", "", 1)
- values := strings.Fields(string(v))
-
- return values, nil
-}
-
-func CallSyscall(mib []int32) ([]byte, uint64, error) {
- mibptr := unsafe.Pointer(&mib[0])
- miblen := uint64(len(mib))
-
- // get required buffer size
- length := uint64(0)
- _, _, err := unix.Syscall6(
- unix.SYS___SYSCTL,
- uintptr(mibptr),
- uintptr(miblen),
- 0,
- uintptr(unsafe.Pointer(&length)),
- 0,
- 0)
- if err != 0 {
- var b []byte
- return b, length, err
- }
- if length == 0 {
- var b []byte
- return b, length, err
- }
- // get proc info itself
- buf := make([]byte, length)
- _, _, err = unix.Syscall6(
- unix.SYS___SYSCTL,
- uintptr(mibptr),
- uintptr(miblen),
- uintptr(unsafe.Pointer(&buf[0])),
- uintptr(unsafe.Pointer(&length)),
- 0,
- 0)
- if err != 0 {
- return buf, length, err
- }
-
- return buf, length, nil
-}
diff --git a/vendor/github.com/shirou/gopsutil/internal/common/common_unix.go b/vendor/github.com/shirou/gopsutil/internal/common/common_unix.go
deleted file mode 100644
index 750a592..0000000
--- a/vendor/github.com/shirou/gopsutil/internal/common/common_unix.go
+++ /dev/null
@@ -1,67 +0,0 @@
-// +build linux freebsd darwin openbsd
-
-package common
-
-import (
- "context"
- "os/exec"
- "strconv"
- "strings"
-)
-
-func CallLsofWithContext(ctx context.Context, invoke Invoker, pid int32, args ...string) ([]string, error) {
- var cmd []string
- if pid == 0 { // will get from all processes.
- cmd = []string{"-a", "-n", "-P"}
- } else {
- cmd = []string{"-a", "-n", "-P", "-p", strconv.Itoa(int(pid))}
- }
- cmd = append(cmd, args...)
- lsof, err := exec.LookPath("lsof")
- if err != nil {
- return []string{}, err
- }
- out, err := invoke.CommandWithContext(ctx, lsof, cmd...)
- if err != nil {
- // if no pid found, lsof returnes code 1.
- if err.Error() == "exit status 1" && len(out) == 0 {
- return []string{}, nil
- }
- }
- lines := strings.Split(string(out), "\n")
-
- var ret []string
- for _, l := range lines[1:] {
- if len(l) == 0 {
- continue
- }
- ret = append(ret, l)
- }
- return ret, nil
-}
-
-func CallPgrepWithContext(ctx context.Context, invoke Invoker, pid int32) ([]int32, error) {
- var cmd []string
- cmd = []string{"-P", strconv.Itoa(int(pid))}
- pgrep, err := exec.LookPath("pgrep")
- if err != nil {
- return []int32{}, err
- }
- out, err := invoke.CommandWithContext(ctx, pgrep, cmd...)
- if err != nil {
- return []int32{}, err
- }
- lines := strings.Split(string(out), "\n")
- ret := make([]int32, 0, len(lines))
- for _, l := range lines {
- if len(l) == 0 {
- continue
- }
- i, err := strconv.Atoi(l)
- if err != nil {
- continue
- }
- ret = append(ret, int32(i))
- }
- return ret, nil
-}
diff --git a/vendor/github.com/shirou/gopsutil/internal/common/common_windows.go b/vendor/github.com/shirou/gopsutil/internal/common/common_windows.go
deleted file mode 100644
index b02c5cf..0000000
--- a/vendor/github.com/shirou/gopsutil/internal/common/common_windows.go
+++ /dev/null
@@ -1,135 +0,0 @@
-// +build windows
-
-package common
-
-import (
- "context"
- "unsafe"
-
- "github.com/StackExchange/wmi"
- "golang.org/x/sys/windows"
-)
-
-// for double values
-type PDH_FMT_COUNTERVALUE_DOUBLE struct {
- CStatus uint32
- DoubleValue float64
-}
-
-// for 64 bit integer values
-type PDH_FMT_COUNTERVALUE_LARGE struct {
- CStatus uint32
- LargeValue int64
-}
-
-// for long values
-type PDH_FMT_COUNTERVALUE_LONG struct {
- CStatus uint32
- LongValue int32
- padding [4]byte
-}
-
-// windows system const
-const (
- ERROR_SUCCESS = 0
- ERROR_FILE_NOT_FOUND = 2
- DRIVE_REMOVABLE = 2
- DRIVE_FIXED = 3
- HKEY_LOCAL_MACHINE = 0x80000002
- RRF_RT_REG_SZ = 0x00000002
- RRF_RT_REG_DWORD = 0x00000010
- PDH_FMT_LONG = 0x00000100
- PDH_FMT_DOUBLE = 0x00000200
- PDH_FMT_LARGE = 0x00000400
- PDH_INVALID_DATA = 0xc0000bc6
- PDH_INVALID_HANDLE = 0xC0000bbc
- PDH_NO_DATA = 0x800007d5
-)
-
-var (
- Modkernel32 = windows.NewLazyDLL("kernel32.dll")
- ModNt = windows.NewLazyDLL("ntdll.dll")
- ModPdh = windows.NewLazyDLL("pdh.dll")
- ModPsapi = windows.NewLazyDLL("psapi.dll")
-
- ProcGetSystemTimes = Modkernel32.NewProc("GetSystemTimes")
- ProcNtQuerySystemInformation = ModNt.NewProc("NtQuerySystemInformation")
- PdhOpenQuery = ModPdh.NewProc("PdhOpenQuery")
- PdhAddCounter = ModPdh.NewProc("PdhAddCounterW")
- PdhCollectQueryData = ModPdh.NewProc("PdhCollectQueryData")
- PdhGetFormattedCounterValue = ModPdh.NewProc("PdhGetFormattedCounterValue")
- PdhCloseQuery = ModPdh.NewProc("PdhCloseQuery")
-)
-
-type FILETIME struct {
- DwLowDateTime uint32
- DwHighDateTime uint32
-}
-
-// borrowed from net/interface_windows.go
-func BytePtrToString(p *uint8) string {
- a := (*[10000]uint8)(unsafe.Pointer(p))
- i := 0
- for a[i] != 0 {
- i++
- }
- return string(a[:i])
-}
-
-// CounterInfo
-// copied from https://github.com/mackerelio/mackerel-agent/
-type CounterInfo struct {
- PostName string
- CounterName string
- Counter windows.Handle
-}
-
-// CreateQuery XXX
-// copied from https://github.com/mackerelio/mackerel-agent/
-func CreateQuery() (windows.Handle, error) {
- var query windows.Handle
- r, _, err := PdhOpenQuery.Call(0, 0, uintptr(unsafe.Pointer(&query)))
- if r != 0 {
- return 0, err
- }
- return query, nil
-}
-
-// CreateCounter XXX
-func CreateCounter(query windows.Handle, pname, cname string) (*CounterInfo, error) {
- var counter windows.Handle
- r, _, err := PdhAddCounter.Call(
- uintptr(query),
- uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(cname))),
- 0,
- uintptr(unsafe.Pointer(&counter)))
- if r != 0 {
- return nil, err
- }
- return &CounterInfo{
- PostName: pname,
- CounterName: cname,
- Counter: counter,
- }, nil
-}
-
-// WMIQueryWithContext - wraps wmi.Query with a timed-out context to avoid hanging
-func WMIQueryWithContext(ctx context.Context, query string, dst interface{}, connectServerArgs ...interface{}) error {
- if _, ok := ctx.Deadline(); !ok {
- ctxTimeout, cancel := context.WithTimeout(ctx, Timeout)
- defer cancel()
- ctx = ctxTimeout
- }
-
- errChan := make(chan error, 1)
- go func() {
- errChan <- wmi.Query(query, dst, connectServerArgs...)
- }()
-
- select {
- case <-ctx.Done():
- return ctx.Err()
- case err := <-errChan:
- return err
- }
-}
diff --git a/vendor/github.com/shirou/gopsutil/mem/mem.go b/vendor/github.com/shirou/gopsutil/mem/mem.go
deleted file mode 100644
index e505662..0000000
--- a/vendor/github.com/shirou/gopsutil/mem/mem.go
+++ /dev/null
@@ -1,96 +0,0 @@
-package mem
-
-import (
- "encoding/json"
-
- "github.com/shirou/gopsutil/internal/common"
-)
-
-var invoke common.Invoker = common.Invoke{}
-
-// Memory usage statistics. Total, Available and Used contain numbers of bytes
-// for human consumption.
-//
-// The other fields in this struct contain kernel specific values.
-type VirtualMemoryStat struct {
- // Total amount of RAM on this system
- Total uint64 `json:"total"`
-
- // RAM available for programs to allocate
- //
- // This value is computed from the kernel specific values.
- Available uint64 `json:"available"`
-
- // RAM used by programs
- //
- // This value is computed from the kernel specific values.
- Used uint64 `json:"used"`
-
- // Percentage of RAM used by programs
- //
- // This value is computed from the kernel specific values.
- UsedPercent float64 `json:"usedPercent"`
-
- // This is the kernel's notion of free memory; RAM chips whose bits nobody
- // cares about the value of right now. For a human consumable number,
- // Available is what you really want.
- Free uint64 `json:"free"`
-
- // OS X / BSD specific numbers:
- // http://www.macyourself.com/2010/02/17/what-is-free-wired-active-and-inactive-system-memory-ram/
- Active uint64 `json:"active"`
- Inactive uint64 `json:"inactive"`
- Wired uint64 `json:"wired"`
-
- // FreeBSD specific numbers:
- // https://reviews.freebsd.org/D8467
- Laundry uint64 `json:"laundry"`
-
- // Linux specific numbers
- // https://www.centos.org/docs/5/html/5.1/Deployment_Guide/s2-proc-meminfo.html
- // https://www.kernel.org/doc/Documentation/filesystems/proc.txt
- // https://www.kernel.org/doc/Documentation/vm/overcommit-accounting
- Buffers uint64 `json:"buffers"`
- Cached uint64 `json:"cached"`
- Writeback uint64 `json:"writeback"`
- Dirty uint64 `json:"dirty"`
- WritebackTmp uint64 `json:"writebacktmp"`
- Shared uint64 `json:"shared"`
- Slab uint64 `json:"slab"`
- PageTables uint64 `json:"pagetables"`
- SwapCached uint64 `json:"swapcached"`
- CommitLimit uint64 `json:"commitlimit"`
- CommittedAS uint64 `json:"committedas"`
- HighTotal uint64 `json:"hightotal"`
- HighFree uint64 `json:"highfree"`
- LowTotal uint64 `json:"lowtotal"`
- LowFree uint64 `json:"lowfree"`
- SwapTotal uint64 `json:"swaptotal"`
- SwapFree uint64 `json:"swapfree"`
- Mapped uint64 `json:"mapped"`
- VMallocTotal uint64 `json:"vmalloctotal"`
- VMallocUsed uint64 `json:"vmallocused"`
- VMallocChunk uint64 `json:"vmallocchunk"`
- HugePagesTotal uint64 `json:"hugepagestotal"`
- HugePagesFree uint64 `json:"hugepagesfree"`
- HugePageSize uint64 `json:"hugepagesize"`
-}
-
-type SwapMemoryStat struct {
- Total uint64 `json:"total"`
- Used uint64 `json:"used"`
- Free uint64 `json:"free"`
- UsedPercent float64 `json:"usedPercent"`
- Sin uint64 `json:"sin"`
- Sout uint64 `json:"sout"`
-}
-
-func (m VirtualMemoryStat) String() string {
- s, _ := json.Marshal(m)
- return string(s)
-}
-
-func (m SwapMemoryStat) String() string {
- s, _ := json.Marshal(m)
- return string(s)
-}
diff --git a/vendor/github.com/shirou/gopsutil/mem/mem_darwin.go b/vendor/github.com/shirou/gopsutil/mem/mem_darwin.go
deleted file mode 100644
index 4fe7009..0000000
--- a/vendor/github.com/shirou/gopsutil/mem/mem_darwin.go
+++ /dev/null
@@ -1,74 +0,0 @@
-// +build darwin
-
-package mem
-
-import (
- "context"
- "encoding/binary"
- "strconv"
- "strings"
-
- "github.com/shirou/gopsutil/internal/common"
- "golang.org/x/sys/unix"
-)
-
-func getHwMemsize() (uint64, error) {
- totalString, err := unix.Sysctl("hw.memsize")
- if err != nil {
- return 0, err
- }
-
- // unix.sysctl() helpfully assumes the result is a null-terminated string and
- // removes the last byte of the result if it's 0 :/
- totalString += "\x00"
-
- total := uint64(binary.LittleEndian.Uint64([]byte(totalString)))
-
- return total, nil
-}
-
-// SwapMemory returns swapinfo.
-func SwapMemory() (*SwapMemoryStat, error) {
- return SwapMemoryWithContext(context.Background())
-}
-
-func SwapMemoryWithContext(ctx context.Context) (*SwapMemoryStat, error) {
- var ret *SwapMemoryStat
-
- swapUsage, err := common.DoSysctrlWithContext(ctx, "vm.swapusage")
- if err != nil {
- return ret, err
- }
-
- total := strings.Replace(swapUsage[2], "M", "", 1)
- used := strings.Replace(swapUsage[5], "M", "", 1)
- free := strings.Replace(swapUsage[8], "M", "", 1)
-
- total_v, err := strconv.ParseFloat(total, 64)
- if err != nil {
- return nil, err
- }
- used_v, err := strconv.ParseFloat(used, 64)
- if err != nil {
- return nil, err
- }
- free_v, err := strconv.ParseFloat(free, 64)
- if err != nil {
- return nil, err
- }
-
- u := float64(0)
- if total_v != 0 {
- u = ((total_v - free_v) / total_v) * 100.0
- }
-
- // vm.swapusage shows "M", multiply 1024 * 1024 to convert bytes.
- ret = &SwapMemoryStat{
- Total: uint64(total_v * 1024 * 1024),
- Used: uint64(used_v * 1024 * 1024),
- Free: uint64(free_v * 1024 * 1024),
- UsedPercent: u,
- }
-
- return ret, nil
-}
diff --git a/vendor/github.com/shirou/gopsutil/mem/mem_darwin_cgo.go b/vendor/github.com/shirou/gopsutil/mem/mem_darwin_cgo.go
deleted file mode 100644
index 389f8cd..0000000
--- a/vendor/github.com/shirou/gopsutil/mem/mem_darwin_cgo.go
+++ /dev/null
@@ -1,59 +0,0 @@
-// +build darwin
-// +build cgo
-
-package mem
-
-/*
-#include
-*/
-import "C"
-
-import (
- "context"
- "fmt"
- "unsafe"
-
- "golang.org/x/sys/unix"
-)
-
-// VirtualMemory returns VirtualmemoryStat.
-func VirtualMemory() (*VirtualMemoryStat, error) {
- return VirtualMemoryWithContext(context.Background())
-}
-
-func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) {
- count := C.mach_msg_type_number_t(C.HOST_VM_INFO_COUNT)
- var vmstat C.vm_statistics_data_t
-
- status := C.host_statistics(C.host_t(C.mach_host_self()),
- C.HOST_VM_INFO,
- C.host_info_t(unsafe.Pointer(&vmstat)),
- &count)
-
- if status != C.KERN_SUCCESS {
- return nil, fmt.Errorf("host_statistics error=%d", status)
- }
-
- pageSize := uint64(unix.Getpagesize())
- total, err := getHwMemsize()
- if err != nil {
- return nil, err
- }
- totalCount := C.natural_t(total / pageSize)
-
- availableCount := vmstat.inactive_count + vmstat.free_count
- usedPercent := 100 * float64(totalCount-availableCount) / float64(totalCount)
-
- usedCount := totalCount - availableCount
-
- return &VirtualMemoryStat{
- Total: total,
- Available: pageSize * uint64(availableCount),
- Used: pageSize * uint64(usedCount),
- UsedPercent: usedPercent,
- Free: pageSize * uint64(vmstat.free_count),
- Active: pageSize * uint64(vmstat.active_count),
- Inactive: pageSize * uint64(vmstat.inactive_count),
- Wired: pageSize * uint64(vmstat.wire_count),
- }, nil
-}
diff --git a/vendor/github.com/shirou/gopsutil/mem/mem_darwin_nocgo.go b/vendor/github.com/shirou/gopsutil/mem/mem_darwin_nocgo.go
deleted file mode 100644
index dd7c2e6..0000000
--- a/vendor/github.com/shirou/gopsutil/mem/mem_darwin_nocgo.go
+++ /dev/null
@@ -1,94 +0,0 @@
-// +build darwin
-// +build !cgo
-
-package mem
-
-import (
- "context"
- "os/exec"
- "strconv"
- "strings"
-
- "golang.org/x/sys/unix"
-)
-
-// Runs vm_stat and returns Free and inactive pages
-func getVMStat(vms *VirtualMemoryStat) error {
- vm_stat, err := exec.LookPath("vm_stat")
- if err != nil {
- return err
- }
- out, err := invoke.Command(vm_stat)
- if err != nil {
- return err
- }
- return parseVMStat(string(out), vms)
-}
-
-func parseVMStat(out string, vms *VirtualMemoryStat) error {
- var err error
-
- lines := strings.Split(out, "\n")
- pagesize := uint64(unix.Getpagesize())
- for _, line := range lines {
- fields := strings.Split(line, ":")
- if len(fields) < 2 {
- continue
- }
- key := strings.TrimSpace(fields[0])
- value := strings.Trim(fields[1], " .")
- switch key {
- case "Pages free":
- free, e := strconv.ParseUint(value, 10, 64)
- if e != nil {
- err = e
- }
- vms.Free = free * pagesize
- case "Pages inactive":
- inactive, e := strconv.ParseUint(value, 10, 64)
- if e != nil {
- err = e
- }
- vms.Inactive = inactive * pagesize
- case "Pages active":
- active, e := strconv.ParseUint(value, 10, 64)
- if e != nil {
- err = e
- }
- vms.Active = active * pagesize
- case "Pages wired down":
- wired, e := strconv.ParseUint(value, 10, 64)
- if e != nil {
- err = e
- }
- vms.Wired = wired * pagesize
- }
- }
- return err
-}
-
-// VirtualMemory returns VirtualmemoryStat.
-func VirtualMemory() (*VirtualMemoryStat, error) {
- return VirtualMemoryWithContext(context.Background())
-}
-
-func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) {
- ret := &VirtualMemoryStat{}
-
- total, err := getHwMemsize()
- if err != nil {
- return nil, err
- }
- err = getVMStat(ret)
- if err != nil {
- return nil, err
- }
-
- ret.Available = ret.Free + ret.Inactive
- ret.Total = total
-
- ret.Used = ret.Total - ret.Available
- ret.UsedPercent = 100 * float64(ret.Used) / float64(ret.Total)
-
- return ret, nil
-}
diff --git a/vendor/github.com/shirou/gopsutil/mem/mem_fallback.go b/vendor/github.com/shirou/gopsutil/mem/mem_fallback.go
deleted file mode 100644
index 2a0fd45..0000000
--- a/vendor/github.com/shirou/gopsutil/mem/mem_fallback.go
+++ /dev/null
@@ -1,25 +0,0 @@
-// +build !darwin,!linux,!freebsd,!openbsd,!solaris,!windows
-
-package mem
-
-import (
- "context"
-
- "github.com/shirou/gopsutil/internal/common"
-)
-
-func VirtualMemory() (*VirtualMemoryStat, error) {
- return VirtualMemoryWithContext(context.Background())
-}
-
-func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) {
- return nil, common.ErrNotImplementedError
-}
-
-func SwapMemory() (*SwapMemoryStat, error) {
- return SwapMemoryWithContext(context.Background())
-}
-
-func SwapMemoryWithContext(ctx context.Context) (*SwapMemoryStat, error) {
- return nil, common.ErrNotImplementedError
-}
diff --git a/vendor/github.com/shirou/gopsutil/mem/mem_freebsd.go b/vendor/github.com/shirou/gopsutil/mem/mem_freebsd.go
deleted file mode 100644
index a792281..0000000
--- a/vendor/github.com/shirou/gopsutil/mem/mem_freebsd.go
+++ /dev/null
@@ -1,142 +0,0 @@
-// +build freebsd
-
-package mem
-
-import (
- "context"
- "errors"
- "unsafe"
-
- "golang.org/x/sys/unix"
-)
-
-func VirtualMemory() (*VirtualMemoryStat, error) {
- return VirtualMemoryWithContext(context.Background())
-}
-
-func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) {
- pageSize, err := unix.SysctlUint32("vm.stats.vm.v_page_size")
- if err != nil {
- return nil, err
- }
- physmem, err := unix.SysctlUint64("hw.physmem")
- if err != nil {
- return nil, err
- }
- free, err := unix.SysctlUint32("vm.stats.vm.v_free_count")
- if err != nil {
- return nil, err
- }
- active, err := unix.SysctlUint32("vm.stats.vm.v_active_count")
- if err != nil {
- return nil, err
- }
- inactive, err := unix.SysctlUint32("vm.stats.vm.v_inactive_count")
- if err != nil {
- return nil, err
- }
- buffers, err := unix.SysctlUint64("vfs.bufspace")
- if err != nil {
- return nil, err
- }
- wired, err := unix.SysctlUint32("vm.stats.vm.v_wire_count")
- if err != nil {
- return nil, err
- }
- var cached, laundry uint32
- osreldate, _ := unix.SysctlUint32("kern.osreldate")
- if osreldate < 1102000 {
- cached, err = unix.SysctlUint32("vm.stats.vm.v_cache_count")
- if err != nil {
- return nil, err
- }
- } else {
- laundry, err = unix.SysctlUint32("vm.stats.vm.v_laundry_count")
- if err != nil {
- return nil, err
- }
- }
-
- p := uint64(pageSize)
- ret := &VirtualMemoryStat{
- Total: uint64(physmem),
- Free: uint64(free) * p,
- Active: uint64(active) * p,
- Inactive: uint64(inactive) * p,
- Cached: uint64(cached) * p,
- Buffers: uint64(buffers),
- Wired: uint64(wired) * p,
- Laundry: uint64(laundry) * p,
- }
-
- ret.Available = ret.Inactive + ret.Cached + ret.Free + ret.Laundry
- ret.Used = ret.Total - ret.Available
- ret.UsedPercent = float64(ret.Used) / float64(ret.Total) * 100.0
-
- return ret, nil
-}
-
-// Return swapinfo
-func SwapMemory() (*SwapMemoryStat, error) {
- return SwapMemoryWithContext(context.Background())
-}
-
-// Constants from vm/vm_param.h
-// nolint: golint
-const (
- XSWDEV_VERSION = 1
-)
-
-// Types from vm/vm_param.h
-type xswdev struct {
- Version uint32 // Version is the version
- Dev uint32 // Dev is the device identifier
- Flags int32 // Flags is the swap flags applied to the device
- NBlks int32 // NBlks is the total number of blocks
- Used int32 // Used is the number of blocks used
-}
-
-func SwapMemoryWithContext(ctx context.Context) (*SwapMemoryStat, error) {
- // FreeBSD can have multiple swap devices so we total them up
- i, err := unix.SysctlUint32("vm.nswapdev")
- if err != nil {
- return nil, err
- }
-
- if i == 0 {
- return nil, errors.New("no swap devices found")
- }
-
- c := int(i)
-
- i, err = unix.SysctlUint32("vm.stats.vm.v_page_size")
- if err != nil {
- return nil, err
- }
- pageSize := uint64(i)
-
- var buf []byte
- s := &SwapMemoryStat{}
- for n := 0; n < c; n++ {
- buf, err = unix.SysctlRaw("vm.swap_info", n)
- if err != nil {
- return nil, err
- }
-
- xsw := (*xswdev)(unsafe.Pointer(&buf[0]))
- if xsw.Version != XSWDEV_VERSION {
- return nil, errors.New("xswdev version mismatch")
- }
- s.Total += uint64(xsw.NBlks)
- s.Used += uint64(xsw.Used)
- }
-
- if s.Total != 0 {
- s.UsedPercent = float64(s.Used) / float64(s.Total) * 100
- }
- s.Total *= pageSize
- s.Used *= pageSize
- s.Free = s.Total - s.Used
-
- return s, nil
-}
diff --git a/vendor/github.com/shirou/gopsutil/mem/mem_linux.go b/vendor/github.com/shirou/gopsutil/mem/mem_linux.go
deleted file mode 100644
index fcc9a3f..0000000
--- a/vendor/github.com/shirou/gopsutil/mem/mem_linux.go
+++ /dev/null
@@ -1,153 +0,0 @@
-// +build linux
-
-package mem
-
-import (
- "context"
- "strconv"
- "strings"
-
- "github.com/shirou/gopsutil/internal/common"
- "golang.org/x/sys/unix"
-)
-
-func VirtualMemory() (*VirtualMemoryStat, error) {
- return VirtualMemoryWithContext(context.Background())
-}
-
-func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) {
- filename := common.HostProc("meminfo")
- lines, _ := common.ReadLines(filename)
- // flag if MemAvailable is in /proc/meminfo (kernel 3.14+)
- memavail := false
-
- ret := &VirtualMemoryStat{}
- for _, line := range lines {
- fields := strings.Split(line, ":")
- if len(fields) != 2 {
- continue
- }
- key := strings.TrimSpace(fields[0])
- value := strings.TrimSpace(fields[1])
- value = strings.Replace(value, " kB", "", -1)
-
- t, err := strconv.ParseUint(value, 10, 64)
- if err != nil {
- return ret, err
- }
- switch key {
- case "MemTotal":
- ret.Total = t * 1024
- case "MemFree":
- ret.Free = t * 1024
- case "MemAvailable":
- memavail = true
- ret.Available = t * 1024
- case "Buffers":
- ret.Buffers = t * 1024
- case "Cached":
- ret.Cached = t * 1024
- case "Active":
- ret.Active = t * 1024
- case "Inactive":
- ret.Inactive = t * 1024
- case "Writeback":
- ret.Writeback = t * 1024
- case "WritebackTmp":
- ret.WritebackTmp = t * 1024
- case "Dirty":
- ret.Dirty = t * 1024
- case "Shmem":
- ret.Shared = t * 1024
- case "Slab":
- ret.Slab = t * 1024
- case "PageTables":
- ret.PageTables = t * 1024
- case "SwapCached":
- ret.SwapCached = t * 1024
- case "CommitLimit":
- ret.CommitLimit = t * 1024
- case "Committed_AS":
- ret.CommittedAS = t * 1024
- case "HighTotal":
- ret.HighTotal = t * 1024
- case "HighFree":
- ret.HighFree = t * 1024
- case "LowTotal":
- ret.LowTotal = t * 1024
- case "LowFree":
- ret.LowFree = t * 1024
- case "SwapTotal":
- ret.SwapTotal = t * 1024
- case "SwapFree":
- ret.SwapFree = t * 1024
- case "Mapped":
- ret.Mapped = t * 1024
- case "VmallocTotal":
- ret.VMallocTotal = t * 1024
- case "VmallocUsed":
- ret.VMallocUsed = t * 1024
- case "VmallocChunk":
- ret.VMallocChunk = t * 1024
- case "HugePages_Total":
- ret.HugePagesTotal = t
- case "HugePages_Free":
- ret.HugePagesFree = t
- case "Hugepagesize":
- ret.HugePageSize = t * 1024
- }
- }
- if !memavail {
- ret.Available = ret.Free + ret.Buffers + ret.Cached
- }
- ret.Used = ret.Total - ret.Free - ret.Buffers - ret.Cached
- ret.UsedPercent = float64(ret.Used) / float64(ret.Total) * 100.0
-
- return ret, nil
-}
-
-func SwapMemory() (*SwapMemoryStat, error) {
- return SwapMemoryWithContext(context.Background())
-}
-
-func SwapMemoryWithContext(ctx context.Context) (*SwapMemoryStat, error) {
- sysinfo := &unix.Sysinfo_t{}
-
- if err := unix.Sysinfo(sysinfo); err != nil {
- return nil, err
- }
- ret := &SwapMemoryStat{
- Total: uint64(sysinfo.Totalswap) * uint64(sysinfo.Unit),
- Free: uint64(sysinfo.Freeswap) * uint64(sysinfo.Unit),
- }
- ret.Used = ret.Total - ret.Free
- //check Infinity
- if ret.Total != 0 {
- ret.UsedPercent = float64(ret.Total-ret.Free) / float64(ret.Total) * 100.0
- } else {
- ret.UsedPercent = 0
- }
- filename := common.HostProc("vmstat")
- lines, _ := common.ReadLines(filename)
- for _, l := range lines {
- fields := strings.Fields(l)
- if len(fields) < 2 {
- continue
- }
- switch fields[0] {
- case "pswpin":
- value, err := strconv.ParseUint(fields[1], 10, 64)
- if err != nil {
- continue
- }
- ret.Sin = value * 4 * 1024
- case "pswpout":
- value, err := strconv.ParseUint(fields[1], 10, 64)
- if err != nil {
- continue
- }
- ret.Sout = value * 4 * 1024
- }
- }
- return ret, nil
-}
diff --git a/vendor/github.com/shirou/gopsutil/mem/mem_openbsd.go b/vendor/github.com/shirou/gopsutil/mem/mem_openbsd.go
deleted file mode 100644
index 35472a3..0000000
--- a/vendor/github.com/shirou/gopsutil/mem/mem_openbsd.go
+++ /dev/null
@@ -1,124 +0,0 @@
-// +build openbsd
-
-package mem
-
-import (
- "bytes"
- "context"
- "encoding/binary"
- "errors"
- "fmt"
- "os/exec"
-
- "github.com/shirou/gopsutil/internal/common"
-)
-
-func GetPageSize() (uint64, error) {
- return GetPageSizeWithContext(context.Background())
-}
-
-func GetPageSizeWithContext(ctx context.Context) (uint64, error) {
- mib := []int32{CTLVm, VmUvmexp}
- buf, length, err := common.CallSyscall(mib)
- if err != nil {
- return 0, err
- }
- if length < sizeOfUvmexp {
- return 0, fmt.Errorf("short syscall ret %d bytes", length)
- }
- var uvmexp Uvmexp
- br := bytes.NewReader(buf)
- err = common.Read(br, binary.LittleEndian, &uvmexp)
- if err != nil {
- return 0, err
- }
- return uint64(uvmexp.Pagesize), nil
-}
-
-func VirtualMemory() (*VirtualMemoryStat, error) {
- return VirtualMemoryWithContext(context.Background())
-}
-
-func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) {
- mib := []int32{CTLVm, VmUvmexp}
- buf, length, err := common.CallSyscall(mib)
- if err != nil {
- return nil, err
- }
- if length < sizeOfUvmexp {
- return nil, fmt.Errorf("short syscall ret %d bytes", length)
- }
- var uvmexp Uvmexp
- br := bytes.NewReader(buf)
- err = common.Read(br, binary.LittleEndian, &uvmexp)
- if err != nil {
- return nil, err
- }
- p := uint64(uvmexp.Pagesize)
-
- ret := &VirtualMemoryStat{
- Total: uint64(uvmexp.Npages) * p,
- Free: uint64(uvmexp.Free) * p,
- Active: uint64(uvmexp.Active) * p,
- Inactive: uint64(uvmexp.Inactive) * p,
- Cached: 0, // not available
- Wired: uint64(uvmexp.Wired) * p,
- }
-
- ret.Available = ret.Inactive + ret.Cached + ret.Free
- ret.Used = ret.Total - ret.Available
- ret.UsedPercent = float64(ret.Used) / float64(ret.Total) * 100.0
-
- mib = []int32{CTLVfs, VfsGeneric, VfsBcacheStat}
- buf, length, err = common.CallSyscall(mib)
- if err != nil {
- return nil, err
- }
- if length < sizeOfBcachestats {
- return nil, fmt.Errorf("short syscall ret %d bytes", length)
- }
- var bcs Bcachestats
- br = bytes.NewReader(buf)
- err = common.Read(br, binary.LittleEndian, &bcs)
- if err != nil {
- return nil, err
- }
- ret.Buffers = uint64(bcs.Numbufpages) * p
-
- return ret, nil
-}
-
-// Return swapctl summary info
-func SwapMemory() (*SwapMemoryStat, error) {
- return SwapMemoryWithContext(context.Background())
-}
-
-func SwapMemoryWithContext(ctx context.Context) (*SwapMemoryStat, error) {
- swapctl, err := exec.LookPath("swapctl")
- if err != nil {
- return nil, err
- }
-
- out, err := invoke.CommandWithContext(ctx, swapctl, "-sk")
- if err != nil {
- return &SwapMemoryStat{}, nil
- }
-
- line := string(out)
- var total, used, free uint64
-
- _, err = fmt.Sscanf(line,
- "total: %d 1K-blocks allocated, %d used, %d available",
- &total, &used, &free)
- if err != nil {
- return nil, errors.New("failed to parse swapctl output")
- }
-
- percent := float64(used) / float64(total) * 100
- return &SwapMemoryStat{
- Total: total * 1024,
- Used: used * 1024,
- Free: free * 1024,
- UsedPercent: percent,
- }, nil
-}
diff --git a/vendor/github.com/shirou/gopsutil/mem/mem_openbsd_amd64.go b/vendor/github.com/shirou/gopsutil/mem/mem_openbsd_amd64.go
deleted file mode 100644
index e09b908..0000000
--- a/vendor/github.com/shirou/gopsutil/mem/mem_openbsd_amd64.go
+++ /dev/null
@@ -1,122 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_openbsd.go
-
-package mem
-
-const (
- CTLVm = 2
- CTLVfs = 10
- VmUvmexp = 4
- VfsGeneric = 0
- VfsBcacheStat = 3
-)
-
-const (
- sizeOfUvmexp = 0x154
- sizeOfBcachestats = 0x78
-)
-
-type Uvmexp struct {
- Pagesize int32
- Pagemask int32
- Pageshift int32
- Npages int32
- Free int32
- Active int32
- Inactive int32
- Paging int32
- Wired int32
- Zeropages int32
- Reserve_pagedaemon int32
- Reserve_kernel int32
- Anonpages int32
- Vnodepages int32
- Vtextpages int32
- Freemin int32
- Freetarg int32
- Inactarg int32
- Wiredmax int32
- Anonmin int32
- Vtextmin int32
- Vnodemin int32
- Anonminpct int32
- Vtextminpct int32
- Vnodeminpct int32
- Nswapdev int32
- Swpages int32
- Swpginuse int32
- Swpgonly int32
- Nswget int32
- Nanon int32
- Nanonneeded int32
- Nfreeanon int32
- Faults int32
- Traps int32
- Intrs int32
- Swtch int32
- Softs int32
- Syscalls int32
- Pageins int32
- Obsolete_swapins int32
- Obsolete_swapouts int32
- Pgswapin int32
- Pgswapout int32
- Forks int32
- Forks_ppwait int32
- Forks_sharevm int32
- Pga_zerohit int32
- Pga_zeromiss int32
- Zeroaborts int32
- Fltnoram int32
- Fltnoanon int32
- Fltpgwait int32
- Fltpgrele int32
- Fltrelck int32
- Fltrelckok int32
- Fltanget int32
- Fltanretry int32
- Fltamcopy int32
- Fltnamap int32
- Fltnomap int32
- Fltlget int32
- Fltget int32
- Flt_anon int32
- Flt_acow int32
- Flt_obj int32
- Flt_prcopy int32
- Flt_przero int32
- Pdwoke int32
- Pdrevs int32
- Pdswout int32
- Pdfreed int32
- Pdscans int32
- Pdanscan int32
- Pdobscan int32
- Pdreact int32
- Pdbusy int32
- Pdpageouts int32
- Pdpending int32
- Pddeact int32
- Pdreanon int32
- Pdrevnode int32
- Pdrevtext int32
- Fpswtch int32
- Kmapent int32
-}
-type Bcachestats struct {
- Numbufs int64
- Numbufpages int64
- Numdirtypages int64
- Numcleanpages int64
- Pendingwrites int64
- Pendingreads int64
- Numwrites int64
- Numreads int64
- Cachehits int64
- Busymapped int64
- Dmapages int64
- Highpages int64
- Delwribufs int64
- Kvaslots int64
- Avail int64
-}
diff --git a/vendor/github.com/shirou/gopsutil/mem/mem_solaris.go b/vendor/github.com/shirou/gopsutil/mem/mem_solaris.go
deleted file mode 100644
index 0736bc4..0000000
--- a/vendor/github.com/shirou/gopsutil/mem/mem_solaris.go
+++ /dev/null
@@ -1,121 +0,0 @@
-package mem
-
-import (
- "context"
- "errors"
- "fmt"
- "os/exec"
- "regexp"
- "strconv"
- "strings"
-
- "github.com/shirou/gopsutil/internal/common"
-)
-
-// VirtualMemory for Solaris is a minimal implementation which only returns
-// what Nomad needs. It does take into account global vs zone, however.
-func VirtualMemory() (*VirtualMemoryStat, error) {
- return VirtualMemoryWithContext(context.Background())
-}
-
-func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) {
- result := &VirtualMemoryStat{}
-
- zoneName, err := zoneName()
- if err != nil {
- return nil, err
- }
-
- if zoneName == "global" {
- cap, err := globalZoneMemoryCapacity()
- if err != nil {
- return nil, err
- }
- result.Total = cap
- } else {
- cap, err := nonGlobalZoneMemoryCapacity()
- if err != nil {
- return nil, err
- }
- result.Total = cap
- }
-
- return result, nil
-}
-
-func SwapMemory() (*SwapMemoryStat, error) {
- return SwapMemoryWithContext(context.Background())
-}
-
-func SwapMemoryWithContext(ctx context.Context) (*SwapMemoryStat, error) {
- return nil, common.ErrNotImplementedError
-}
-
-func zoneName() (string, error) {
- zonename, err := exec.LookPath("/usr/bin/zonename")
- if err != nil {
- return "", err
- }
-
- ctx := context.Background()
- out, err := invoke.CommandWithContext(ctx, zonename)
- if err != nil {
- return "", err
- }
-
- return strings.TrimSpace(string(out)), nil
-}
-
-var globalZoneMemoryCapacityMatch = regexp.MustCompile(`memory size: ([\d]+) Megabytes`)
-
-func globalZoneMemoryCapacity() (uint64, error) {
- prtconf, err := exec.LookPath("/usr/sbin/prtconf")
- if err != nil {
- return 0, err
- }
-
- ctx := context.Background()
- out, err := invoke.CommandWithContext(ctx, prtconf)
- if err != nil {
- return 0, err
- }
-
- match := globalZoneMemoryCapacityMatch.FindAllStringSubmatch(string(out), -1)
- if len(match) != 1 {
- return 0, errors.New("memory size not contained in output of /usr/sbin/prtconf")
- }
-
- totalMB, err := strconv.ParseUint(match[0][1], 10, 64)
- if err != nil {
- return 0, err
- }
-
- return totalMB * 1024 * 1024, nil
-}
-
-var kstatMatch = regexp.MustCompile(`([^\s]+)[\s]+([^\s]*)`)
-
-func nonGlobalZoneMemoryCapacity() (uint64, error) {
- kstat, err := exec.LookPath("/usr/bin/kstat")
- if err != nil {
- return 0, err
- }
-
- ctx := context.Background()
- out, err := invoke.CommandWithContext(ctx, kstat, "-p", "-c", "zone_memory_cap", "memory_cap:*:*:physcap")
- if err != nil {
- return 0, err
- }
-
- kstats := kstatMatch.FindAllStringSubmatch(string(out), -1)
- if len(kstats) != 1 {
- return 0, fmt.Errorf("expected 1 kstat, found %d", len(kstats))
- }
-
- memSizeBytes, err := strconv.ParseUint(kstats[0][2], 10, 64)
- if err != nil {
- return 0, err
- }
-
- return memSizeBytes, nil
-}
diff --git a/vendor/github.com/shirou/gopsutil/mem/mem_windows.go b/vendor/github.com/shirou/gopsutil/mem/mem_windows.go
deleted file mode 100644
index cfdf8bd..0000000
--- a/vendor/github.com/shirou/gopsutil/mem/mem_windows.go
+++ /dev/null
@@ -1,97 +0,0 @@
-// +build windows
-
-package mem
-
-import (
- "context"
- "unsafe"
-
- "github.com/shirou/gopsutil/internal/common"
- "golang.org/x/sys/windows"
-)
-
-var (
- procGlobalMemoryStatusEx = common.Modkernel32.NewProc("GlobalMemoryStatusEx")
- procGetPerformanceInfo = common.ModPsapi.NewProc("GetPerformanceInfo")
-)
-
-type memoryStatusEx struct {
- cbSize uint32
- dwMemoryLoad uint32
- ullTotalPhys uint64 // in bytes
- ullAvailPhys uint64
- ullTotalPageFile uint64
- ullAvailPageFile uint64
- ullTotalVirtual uint64
- ullAvailVirtual uint64
- ullAvailExtendedVirtual uint64
-}
-
-func VirtualMemory() (*VirtualMemoryStat, error) {
- return VirtualMemoryWithContext(context.Background())
-}
-
-func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) {
- var memInfo memoryStatusEx
- memInfo.cbSize = uint32(unsafe.Sizeof(memInfo))
- mem, _, _ := procGlobalMemoryStatusEx.Call(uintptr(unsafe.Pointer(&memInfo)))
- if mem == 0 {
- return nil, windows.GetLastError()
- }
-
- ret := &VirtualMemoryStat{
- Total: memInfo.ullTotalPhys,
- Available: memInfo.ullAvailPhys,
- UsedPercent: float64(memInfo.dwMemoryLoad),
- }
-
- ret.Used = ret.Total - ret.Available
- return ret, nil
-}
-
-type performanceInformation struct {
- cb uint32
- commitTotal uint64
- commitLimit uint64
- commitPeak uint64
- physicalTotal uint64
- physicalAvailable uint64
- systemCache uint64
- kernelTotal uint64
- kernelPaged uint64
- kernelNonpaged uint64
- pageSize uint64
- handleCount uint32
- processCount uint32
- threadCount uint32
-}
-
-func SwapMemory() (*SwapMemoryStat, error) {
- return SwapMemoryWithContext(context.Background())
-}
-
-func SwapMemoryWithContext(ctx context.Context) (*SwapMemoryStat, error) {
- var perfInfo performanceInformation
- perfInfo.cb = uint32(unsafe.Sizeof(perfInfo))
- mem, _, _ := procGetPerformanceInfo.Call(uintptr(unsafe.Pointer(&perfInfo)), uintptr(perfInfo.cb))
- if mem == 0 {
- return nil, windows.GetLastError()
- }
- tot := perfInfo.commitLimit * perfInfo.pageSize
- used := perfInfo.commitTotal * perfInfo.pageSize
- free := tot - used
- var usedPercent float64
- if tot == 0 {
- usedPercent = 0
- } else {
- usedPercent = float64(used) / float64(tot)
- }
- ret := &SwapMemoryStat{
- Total: tot,
- Used: used,
- Free: free,
- UsedPercent: usedPercent,
- }
-
- return ret, nil
-}
diff --git a/vendor/github.com/shirou/gopsutil/mem/types_openbsd.go b/vendor/github.com/shirou/gopsutil/mem/types_openbsd.go
deleted file mode 100644
index 83cb91a..0000000
--- a/vendor/github.com/shirou/gopsutil/mem/types_openbsd.go
+++ /dev/null
@@ -1,34 +0,0 @@
-// +build ignore
-
-/*
-Input to cgo -godefs.
-*/
-
-package mem
-
-/*
-#include
-#include
-#include
-#include
-
-*/
-import "C"
-
-// Machine characteristics; for internal use.
-
-const (
- CTLVm = 2
- CTLVfs = 10
- VmUvmexp = 4 // get uvmexp
- VfsGeneric = 0
- VfsBcacheStat = 3
-)
-
-const (
- sizeOfUvmexp = C.sizeof_struct_uvmexp
- sizeOfBcachestats = C.sizeof_struct_bcachestats
-)
-
-type Uvmexp C.struct_uvmexp
-type Bcachestats C.struct_bcachestats
diff --git a/vendor/github.com/shirou/gopsutil/net/net.go b/vendor/github.com/shirou/gopsutil/net/net.go
deleted file mode 100644
index fce86c7..0000000
--- a/vendor/github.com/shirou/gopsutil/net/net.go
+++ /dev/null
@@ -1,259 +0,0 @@
-package net
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "net"
- "strconv"
- "strings"
- "syscall"
-
- "github.com/shirou/gopsutil/internal/common"
-)
-
-var invoke common.Invoker = common.Invoke{}
-
-type IOCountersStat struct {
- Name string `json:"name"` // interface name
- BytesSent uint64 `json:"bytesSent"` // number of bytes sent
- BytesRecv uint64 `json:"bytesRecv"` // number of bytes received
- PacketsSent uint64 `json:"packetsSent"` // number of packets sent
- PacketsRecv uint64 `json:"packetsRecv"` // number of packets received
- Errin uint64 `json:"errin"` // total number of errors while receiving
- Errout uint64 `json:"errout"` // total number of errors while sending
- Dropin uint64 `json:"dropin"` // total number of incoming packets which were dropped
- Dropout uint64 `json:"dropout"` // total number of outgoing packets which were dropped (always 0 on OSX and BSD)
- Fifoin uint64 `json:"fifoin"` // total number of FIFO buffers errors while receiving
- Fifoout uint64 `json:"fifoout"` // total number of FIFO buffers errors while sending
-
-}
-
-// Addr is implemented compatibility to psutil
-type Addr struct {
- IP string `json:"ip"`
- Port uint32 `json:"port"`
-}
-
-type ConnectionStat struct {
- Fd uint32 `json:"fd"`
- Family uint32 `json:"family"`
- Type uint32 `json:"type"`
- Laddr Addr `json:"localaddr"`
- Raddr Addr `json:"remoteaddr"`
- Status string `json:"status"`
- Uids []int32 `json:"uids"`
- Pid int32 `json:"pid"`
-}
-
-// System wide stats about different network protocols
-type ProtoCountersStat struct {
- Protocol string `json:"protocol"`
- Stats map[string]int64 `json:"stats"`
-}
-
-// NetInterfaceAddr is designed for represent interface addresses
-type InterfaceAddr struct {
- Addr string `json:"addr"`
-}
-
-type InterfaceStat struct {
- MTU int `json:"mtu"` // maximum transmission unit
- Name string `json:"name"` // e.g., "en0", "lo0", "eth0.100"
- HardwareAddr string `json:"hardwareaddr"` // IEEE MAC-48, EUI-48 and EUI-64 form
- Flags []string `json:"flags"` // e.g., FlagUp, FlagLoopback, FlagMulticast
- Addrs []InterfaceAddr `json:"addrs"`
-}
-
-type FilterStat struct {
- ConnTrackCount int64 `json:"conntrackCount"`
- ConnTrackMax int64 `json:"conntrackMax"`
-}
-
-var constMap = map[string]int{
- "unix": syscall.AF_UNIX,
- "TCP": syscall.SOCK_STREAM,
- "UDP": syscall.SOCK_DGRAM,
- "IPv4": syscall.AF_INET,
- "IPv6": syscall.AF_INET6,
-}
-
-func (n IOCountersStat) String() string {
- s, _ := json.Marshal(n)
- return string(s)
-}
-
-func (n ConnectionStat) String() string {
- s, _ := json.Marshal(n)
- return string(s)
-}
-
-func (n ProtoCountersStat) String() string {
- s, _ := json.Marshal(n)
- return string(s)
-}
-
-func (a Addr) String() string {
- s, _ := json.Marshal(a)
- return string(s)
-}
-
-func (n InterfaceStat) String() string {
- s, _ := json.Marshal(n)
- return string(s)
-}
-
-func (n InterfaceAddr) String() string {
- s, _ := json.Marshal(n)
- return string(s)
-}
-
-func Interfaces() ([]InterfaceStat, error) {
- return InterfacesWithContext(context.Background())
-}
-
-func InterfacesWithContext(ctx context.Context) ([]InterfaceStat, error) {
- is, err := net.Interfaces()
- if err != nil {
- return nil, err
- }
- ret := make([]InterfaceStat, 0, len(is))
- for _, ifi := range is {
-
- var flags []string
- if ifi.Flags&net.FlagUp != 0 {
- flags = append(flags, "up")
- }
- if ifi.Flags&net.FlagBroadcast != 0 {
- flags = append(flags, "broadcast")
- }
- if ifi.Flags&net.FlagLoopback != 0 {
- flags = append(flags, "loopback")
- }
- if ifi.Flags&net.FlagPointToPoint != 0 {
- flags = append(flags, "pointtopoint")
- }
- if ifi.Flags&net.FlagMulticast != 0 {
- flags = append(flags, "multicast")
- }
-
- r := InterfaceStat{
- Name: ifi.Name,
- MTU: ifi.MTU,
- HardwareAddr: ifi.HardwareAddr.String(),
- Flags: flags,
- }
- addrs, err := ifi.Addrs()
- if err == nil {
- r.Addrs = make([]InterfaceAddr, 0, len(addrs))
- for _, addr := range addrs {
- r.Addrs = append(r.Addrs, InterfaceAddr{
- Addr: addr.String(),
- })
- }
-
- }
- ret = append(ret, r)
- }
-
- return ret, nil
-}
-
-func getIOCountersAll(n []IOCountersStat) ([]IOCountersStat, error) {
- r := IOCountersStat{
- Name: "all",
- }
- for _, nic := range n {
- r.BytesRecv += nic.BytesRecv
- r.PacketsRecv += nic.PacketsRecv
- r.Errin += nic.Errin
- r.Dropin += nic.Dropin
- r.BytesSent += nic.BytesSent
- r.PacketsSent += nic.PacketsSent
- r.Errout += nic.Errout
- r.Dropout += nic.Dropout
- }
-
- return []IOCountersStat{r}, nil
-}
-
-func parseNetLine(line string) (ConnectionStat, error) {
- f := strings.Fields(line)
- if len(f) < 8 {
- return ConnectionStat{}, fmt.Errorf("wrong line,%s", line)
- }
-
- if len(f) == 8 {
- f = append(f, f[7])
- f[7] = "unix"
- }
-
- pid, err := strconv.Atoi(f[1])
- if err != nil {
- return ConnectionStat{}, err
- }
- fd, err := strconv.Atoi(strings.Trim(f[3], "u"))
- if err != nil {
- return ConnectionStat{}, fmt.Errorf("unknown fd, %s", f[3])
- }
- netFamily, ok := constMap[f[4]]
- if !ok {
- return ConnectionStat{}, fmt.Errorf("unknown family, %s", f[4])
- }
- netType, ok := constMap[f[7]]
- if !ok {
- return ConnectionStat{}, fmt.Errorf("unknown type, %s", f[7])
- }
-
- var laddr, raddr Addr
- if f[7] == "unix" {
- laddr.IP = f[8]
- } else {
- laddr, raddr, err = parseNetAddr(f[8])
- if err != nil {
- return ConnectionStat{}, fmt.Errorf("failed to parse netaddr, %s", f[8])
- }
- }
-
- n := ConnectionStat{
- Fd: uint32(fd),
- Family: uint32(netFamily),
- Type: uint32(netType),
- Laddr: laddr,
- Raddr: raddr,
- Pid: int32(pid),
- }
- if len(f) == 10 {
- n.Status = strings.Trim(f[9], "()")
- }
-
- return n, nil
-}
-
-func parseNetAddr(line string) (laddr Addr, raddr Addr, err error) {
- parse := func(l string) (Addr, error) {
- host, port, err := net.SplitHostPort(l)
- if err != nil {
- return Addr{}, fmt.Errorf("wrong addr, %s", l)
- }
- lport, err := strconv.Atoi(port)
- if err != nil {
- return Addr{}, err
- }
- return Addr{IP: host, Port: uint32(lport)}, nil
- }
-
- addrs := strings.Split(line, "->")
- if len(addrs) == 0 {
- return laddr, raddr, fmt.Errorf("wrong netaddr, %s", line)
- }
- laddr, err = parse(addrs[0])
- if len(addrs) == 2 { // remote addr exists
- raddr, err = parse(addrs[1])
- if err != nil {
- return laddr, raddr, err
- }
- }
-
- return laddr, raddr, err
-}
diff --git a/vendor/github.com/shirou/gopsutil/net/net_darwin.go b/vendor/github.com/shirou/gopsutil/net/net_darwin.go
deleted file mode 100644
index 0d89280..0000000
--- a/vendor/github.com/shirou/gopsutil/net/net_darwin.go
+++ /dev/null
@@ -1,284 +0,0 @@
-// +build darwin
-
-package net
-
-import (
- "context"
- "errors"
- "fmt"
- "os/exec"
- "regexp"
- "strconv"
- "strings"
-)
-
-var (
- errNetstatHeader = errors.New("Can't parse header of netstat output")
- netstatLinkRegexp = regexp.MustCompile(`^$`)
-)
-
-const endOfLine = "\n"
-
-func parseNetstatLine(line string) (stat *IOCountersStat, linkID *uint, err error) {
- var (
- numericValue uint64
- columns = strings.Fields(line)
- )
-
- if columns[0] == "Name" {
- err = errNetstatHeader
- return
- }
-
- // try to extract the numeric value from
- if subMatch := netstatLinkRegexp.FindStringSubmatch(columns[2]); len(subMatch) == 2 {
- numericValue, err = strconv.ParseUint(subMatch[1], 10, 64)
- if err != nil {
- return
- }
- linkIDUint := uint(numericValue)
- linkID = &linkIDUint
- }
-
- base := 1
- numberColumns := len(columns)
- // sometimes Address is ommitted
- if numberColumns < 12 {
- base = 0
- }
- if numberColumns < 11 || numberColumns > 13 {
- err = fmt.Errorf("Line %q do have an invalid number of columns %d", line, numberColumns)
- return
- }
-
- parsed := make([]uint64, 0, 7)
- vv := []string{
- columns[base+3], // Ipkts == PacketsRecv
- columns[base+4], // Ierrs == Errin
- columns[base+5], // Ibytes == BytesRecv
- columns[base+6], // Opkts == PacketsSent
- columns[base+7], // Oerrs == Errout
- columns[base+8], // Obytes == BytesSent
- }
- if len(columns) == 12 {
- vv = append(vv, columns[base+10])
- }
-
- for _, target := range vv {
- if target == "-" {
- parsed = append(parsed, 0)
- continue
- }
-
- if numericValue, err = strconv.ParseUint(target, 10, 64); err != nil {
- return
- }
- parsed = append(parsed, numericValue)
- }
-
- stat = &IOCountersStat{
- Name: strings.Trim(columns[0], "*"), // remove the * that sometimes is on right on interface
- PacketsRecv: parsed[0],
- Errin: parsed[1],
- BytesRecv: parsed[2],
- PacketsSent: parsed[3],
- Errout: parsed[4],
- BytesSent: parsed[5],
- }
- if len(parsed) == 7 {
- stat.Dropout = parsed[6]
- }
- return
-}
-
-type netstatInterface struct {
- linkID *uint
- stat *IOCountersStat
-}
-
-func parseNetstatOutput(output string) ([]netstatInterface, error) {
- var (
- err error
- lines = strings.Split(strings.Trim(output, endOfLine), endOfLine)
- )
-
- // number of interfaces is number of lines less one for the header
- numberInterfaces := len(lines) - 1
-
- interfaces := make([]netstatInterface, numberInterfaces)
- // no output beside header
- if numberInterfaces == 0 {
- return interfaces, nil
- }
-
- for index := 0; index < numberInterfaces; index++ {
- nsIface := netstatInterface{}
- if nsIface.stat, nsIface.linkID, err = parseNetstatLine(lines[index+1]); err != nil {
- return nil, err
- }
- interfaces[index] = nsIface
- }
- return interfaces, nil
-}
-
-// map that hold the name of a network interface and the number of usage
-type mapInterfaceNameUsage map[string]uint
-
-func newMapInterfaceNameUsage(ifaces []netstatInterface) mapInterfaceNameUsage {
- output := make(mapInterfaceNameUsage)
- for index := range ifaces {
- if ifaces[index].linkID != nil {
- ifaceName := ifaces[index].stat.Name
- usage, ok := output[ifaceName]
- if ok {
- output[ifaceName] = usage + 1
- } else {
- output[ifaceName] = 1
- }
- }
- }
- return output
-}
-
-func (min mapInterfaceNameUsage) isTruncated() bool {
- for _, usage := range min {
- if usage > 1 {
- return true
- }
- }
- return false
-}
-
-func (min mapInterfaceNameUsage) notTruncated() []string {
- output := make([]string, 0)
- for ifaceName, usage := range min {
- if usage == 1 {
- output = append(output, ifaceName)
- }
- }
- return output
-}
-
-// example of `netstat -ibdnW` output on yosemite
-// Name Mtu Network Address Ipkts Ierrs Ibytes Opkts Oerrs Obytes Coll Drop
-// lo0 16384 869107 0 169411755 869107 0 169411755 0 0
-// lo0 16384 ::1/128 ::1 869107 - 169411755 869107 - 169411755 - -
-// lo0 16384 127 127.0.0.1 869107 - 169411755 869107 - 169411755 - -
-func IOCounters(pernic bool) ([]IOCountersStat, error) {
- return IOCountersWithContext(context.Background(), pernic)
-}
-
-func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat, error) {
- var (
- ret []IOCountersStat
- retIndex int
- )
-
- netstat, err := exec.LookPath("/usr/sbin/netstat")
- if err != nil {
- return nil, err
- }
-
- // try to get all interface metrics, and hope there won't be any truncated
- out, err := invoke.CommandWithContext(ctx, netstat, "-ibdnW")
- if err != nil {
- return nil, err
- }
-
- nsInterfaces, err := parseNetstatOutput(string(out))
- if err != nil {
- return nil, err
- }
-
- ifaceUsage := newMapInterfaceNameUsage(nsInterfaces)
- notTruncated := ifaceUsage.notTruncated()
- ret = make([]IOCountersStat, len(notTruncated))
-
- if !ifaceUsage.isTruncated() {
- // no truncated interface name, return stats of all interface with
- for index := range nsInterfaces {
- if nsInterfaces[index].linkID != nil {
- ret[retIndex] = *nsInterfaces[index].stat
- retIndex++
- }
- }
- } else {
- // duplicated interface, list all interfaces
- ifconfig, err := exec.LookPath("/sbin/ifconfig")
- if err != nil {
- return nil, err
- }
- if out, err = invoke.CommandWithContext(ctx, ifconfig, "-l"); err != nil {
- return nil, err
- }
- interfaceNames := strings.Fields(strings.TrimRight(string(out), endOfLine))
-
- // for each of the interface name, run netstat if we don't have any stats yet
- for _, interfaceName := range interfaceNames {
- truncated := true
- for index := range nsInterfaces {
- if nsInterfaces[index].linkID != nil && nsInterfaces[index].stat.Name == interfaceName {
- // handle the non truncated name to avoid execute netstat for them again
- ret[retIndex] = *nsInterfaces[index].stat
- retIndex++
- truncated = false
- break
- }
- }
- if truncated {
- // run netstat with -I$ifacename
- if out, err = invoke.CommandWithContext(ctx, netstat, "-ibdnWI"+interfaceName); err != nil {
- return nil, err
- }
- parsedIfaces, err := parseNetstatOutput(string(out))
- if err != nil {
- return nil, err
- }
- if len(parsedIfaces) == 0 {
- // interface had been removed since `ifconfig -l` had been executed
- continue
- }
- for index := range parsedIfaces {
- if parsedIfaces[index].linkID != nil {
- ret = append(ret, *parsedIfaces[index].stat)
- break
- }
- }
- }
- }
- }
-
- if pernic == false {
- return getIOCountersAll(ret)
- }
- return ret, nil
-}
-
-// NetIOCountersByFile is an method which is added just a compatibility for linux.
-func IOCountersByFile(pernic bool, filename string) ([]IOCountersStat, error) {
- return IOCountersByFileWithContext(context.Background(), pernic, filename)
-}
-
-func IOCountersByFileWithContext(ctx context.Context, pernic bool, filename string) ([]IOCountersStat, error) {
- return IOCounters(pernic)
-}
-
-func FilterCounters() ([]FilterStat, error) {
- return FilterCountersWithContext(context.Background())
-}
-
-func FilterCountersWithContext(ctx context.Context) ([]FilterStat, error) {
- return nil, errors.New("NetFilterCounters not implemented for darwin")
-}
-
-// NetProtoCounters returns network statistics for the entire system
-// If protocols is empty then all protocols are returned, otherwise
-// just the protocols in the list are returned.
-// Not Implemented for Darwin
-func ProtoCounters(protocols []string) ([]ProtoCountersStat, error) {
- return ProtoCountersWithContext(context.Background(), protocols)
-}
-
-func ProtoCountersWithContext(ctx context.Context, protocols []string) ([]ProtoCountersStat, error) {
- return nil, errors.New("NetProtoCounters not implemented for darwin")
-}
diff --git a/vendor/github.com/shirou/gopsutil/net/net_fallback.go b/vendor/github.com/shirou/gopsutil/net/net_fallback.go
deleted file mode 100644
index 7c5e632..0000000
--- a/vendor/github.com/shirou/gopsutil/net/net_fallback.go
+++ /dev/null
@@ -1,49 +0,0 @@
-// +build !darwin,!linux,!freebsd,!openbsd,!windows
-
-package net
-
-import (
- "context"
-
- "github.com/shirou/gopsutil/internal/common"
-)
-
-func IOCounters(pernic bool) ([]IOCountersStat, error) {
- return IOCountersWithContext(context.Background(), pernic)
-}
-
-func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat, error) {
- return []IOCountersStat{}, common.ErrNotImplementedError
-}
-
-func FilterCounters() ([]FilterStat, error) {
- return FilterCountersWithContext(context.Background())
-}
-
-func FilterCountersWithContext(ctx context.Context) ([]FilterStat, error) {
- return []FilterStat{}, common.ErrNotImplementedError
-}
-
-func ProtoCounters(protocols []string) ([]ProtoCountersStat, error) {
- return ProtoCountersWithContext(context.Background(), protocols)
-}
-
-func ProtoCountersWithContext(ctx context.Context, protocols []string) ([]ProtoCountersStat, error) {
- return []ProtoCountersStat{}, common.ErrNotImplementedError
-}
-
-func Connections(kind string) ([]ConnectionStat, error) {
- return ConnectionsWithContext(context.Background(), kind)
-}
-
-func ConnectionsWithContext(ctx context.Context, kind string) ([]ConnectionStat, error) {
- return []ConnectionStat{}, common.ErrNotImplementedError
-}
-
-func ConnectionsMax(kind string, max int) ([]ConnectionStat, error) {
- return ConnectionsMaxWithContext(context.Background(), kind, max)
-}
-
-func ConnectionsMaxWithContext(ctx context.Context, kind string, max int) ([]ConnectionStat, error) {
- return []ConnectionStat{}, common.ErrNotImplementedError
-}
diff --git a/vendor/github.com/shirou/gopsutil/net/net_freebsd.go b/vendor/github.com/shirou/gopsutil/net/net_freebsd.go
deleted file mode 100644
index ce02415..0000000
--- a/vendor/github.com/shirou/gopsutil/net/net_freebsd.go
+++ /dev/null
@@ -1,125 +0,0 @@
-// +build freebsd
-
-package net
-
-import (
- "context"
- "errors"
- "os/exec"
- "strconv"
- "strings"
-
- "github.com/shirou/gopsutil/internal/common"
-)
-
-func IOCounters(pernic bool) ([]IOCountersStat, error) {
- return IOCountersWithContext(context.Background(), pernic)
-}
-
-func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat, error) {
- netstat, err := exec.LookPath("/usr/bin/netstat")
- if err != nil {
- return nil, err
- }
- out, err := invoke.CommandWithContext(ctx, netstat, "-ibdnW")
- if err != nil {
- return nil, err
- }
-
- lines := strings.Split(string(out), "\n")
- ret := make([]IOCountersStat, 0, len(lines)-1)
- exists := make([]string, 0, len(ret))
-
- for _, line := range lines {
- values := strings.Fields(line)
- if len(values) < 1 || values[0] == "Name" {
- continue
- }
- if common.StringsHas(exists, values[0]) {
- // skip if already get
- continue
- }
- exists = append(exists, values[0])
-
- if len(values) < 12 {
- continue
- }
- base := 1
- // sometimes Address is ommitted
- if len(values) < 13 {
- base = 0
- }
-
- parsed := make([]uint64, 0, 8)
- vv := []string{
- values[base+3], // PacketsRecv
- values[base+4], // Errin
- values[base+5], // Dropin
- values[base+6], // BytesRecvn
- values[base+7], // PacketSent
- values[base+8], // Errout
- values[base+9], // BytesSent
- values[base+11], // Dropout
- }
- for _, target := range vv {
- if target == "-" {
- parsed = append(parsed, 0)
- continue
- }
-
- t, err := strconv.ParseUint(target, 10, 64)
- if err != nil {
- return nil, err
- }
- parsed = append(parsed, t)
- }
-
- n := IOCountersStat{
- Name: values[0],
- PacketsRecv: parsed[0],
- Errin: parsed[1],
- Dropin: parsed[2],
- BytesRecv: parsed[3],
- PacketsSent: parsed[4],
- Errout: parsed[5],
- BytesSent: parsed[6],
- Dropout: parsed[7],
- }
- ret = append(ret, n)
- }
-
- if pernic == false {
- return getIOCountersAll(ret)
- }
-
- return ret, nil
-}
-
-// NetIOCountersByFile is an method which is added just a compatibility for linux.
-func IOCountersByFile(pernic bool, filename string) ([]IOCountersStat, error) {
- return IOCountersByFileWithContext(context.Background(), pernic, filename)
-}
-
-func IOCountersByFileWithContext(ctx context.Context, pernic bool, filename string) ([]IOCountersStat, error) {
- return IOCounters(pernic)
-}
-
-func FilterCounters() ([]FilterStat, error) {
- return FilterCountersWithContext(context.Background())
-}
-
-func FilterCountersWithContext(ctx context.Context) ([]FilterStat, error) {
- return nil, errors.New("NetFilterCounters not implemented for freebsd")
-}
-
-// NetProtoCounters returns network statistics for the entire system
-// If protocols is empty then all protocols are returned, otherwise
-// just the protocols in the list are returned.
-// Not Implemented for FreeBSD
-func ProtoCounters(protocols []string) ([]ProtoCountersStat, error) {
- return ProtoCountersWithContext(context.Background(), protocols)
-}
-
-func ProtoCountersWithContext(ctx context.Context, protocols []string) ([]ProtoCountersStat, error) {
- return nil, errors.New("NetProtoCounters not implemented for freebsd")
-}
diff --git a/vendor/github.com/shirou/gopsutil/net/net_linux.go b/vendor/github.com/shirou/gopsutil/net/net_linux.go
deleted file mode 100644
index fc2b22e..0000000
--- a/vendor/github.com/shirou/gopsutil/net/net_linux.go
+++ /dev/null
@@ -1,791 +0,0 @@
-// +build linux
-
-package net
-
-import (
- "bytes"
- "context"
- "encoding/hex"
- "errors"
- "fmt"
- "io/ioutil"
- "net"
- "os"
- "strconv"
- "strings"
- "syscall"
-
- "github.com/shirou/gopsutil/internal/common"
-)
-
-// NetIOCounters returnes network I/O statistics for every network
-// interface installed on the system. If pernic argument is false,
-// return only sum of all information (which name is 'all'). If true,
-// every network interface installed on the system is returned
-// separately.
-func IOCounters(pernic bool) ([]IOCountersStat, error) {
- return IOCountersWithContext(context.Background(), pernic)
-}
-
-func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat, error) {
- filename := common.HostProc("net/dev")
- return IOCountersByFile(pernic, filename)
-}
-
-func IOCountersByFile(pernic bool, filename string) ([]IOCountersStat, error) {
- return IOCountersByFileWithContext(context.Background(), pernic, filename)
-}
-
-func IOCountersByFileWithContext(ctx context.Context, pernic bool, filename string) ([]IOCountersStat, error) {
- lines, err := common.ReadLines(filename)
- if err != nil {
- return nil, err
- }
-
- parts := make([]string, 2)
-
- statlen := len(lines) - 1
-
- ret := make([]IOCountersStat, 0, statlen)
-
- for _, line := range lines[2:] {
- separatorPos := strings.LastIndex(line, ":")
- if separatorPos == -1 {
- continue
- }
- parts[0] = line[0:separatorPos]
- parts[1] = line[separatorPos+1:]
-
- interfaceName := strings.TrimSpace(parts[0])
- if interfaceName == "" {
- continue
- }
-
- fields := strings.Fields(strings.TrimSpace(parts[1]))
- bytesRecv, err := strconv.ParseUint(fields[0], 10, 64)
- if err != nil {
- return ret, err
- }
- packetsRecv, err := strconv.ParseUint(fields[1], 10, 64)
- if err != nil {
- return ret, err
- }
- errIn, err := strconv.ParseUint(fields[2], 10, 64)
- if err != nil {
- return ret, err
- }
- dropIn, err := strconv.ParseUint(fields[3], 10, 64)
- if err != nil {
- return ret, err
- }
- fifoIn, err := strconv.ParseUint(fields[4], 10, 64)
- if err != nil {
- return ret, err
- }
- bytesSent, err := strconv.ParseUint(fields[8], 10, 64)
- if err != nil {
- return ret, err
- }
- packetsSent, err := strconv.ParseUint(fields[9], 10, 64)
- if err != nil {
- return ret, err
- }
- errOut, err := strconv.ParseUint(fields[10], 10, 64)
- if err != nil {
- return ret, err
- }
- dropOut, err := strconv.ParseUint(fields[11], 10, 64)
- if err != nil {
- return ret, err
- }
- fifoOut, err := strconv.ParseUint(fields[12], 10, 64)
- if err != nil {
- return ret, err
- }
-
- nic := IOCountersStat{
- Name: interfaceName,
- BytesRecv: bytesRecv,
- PacketsRecv: packetsRecv,
- Errin: errIn,
- Dropin: dropIn,
- Fifoin: fifoIn,
- BytesSent: bytesSent,
- PacketsSent: packetsSent,
- Errout: errOut,
- Dropout: dropOut,
- Fifoout: fifoOut,
- }
- ret = append(ret, nic)
- }
-
- if pernic == false {
- return getIOCountersAll(ret)
- }
-
- return ret, nil
-}
-
-var netProtocols = []string{
- "ip",
- "icmp",
- "icmpmsg",
- "tcp",
- "udp",
- "udplite",
-}
-
-// NetProtoCounters returns network statistics for the entire system
-// If protocols is empty then all protocols are returned, otherwise
-// just the protocols in the list are returned.
-// Available protocols:
-// ip,icmp,icmpmsg,tcp,udp,udplite
-func ProtoCounters(protocols []string) ([]ProtoCountersStat, error) {
- return ProtoCountersWithContext(context.Background(), protocols)
-}
-
-func ProtoCountersWithContext(ctx context.Context, protocols []string) ([]ProtoCountersStat, error) {
- if len(protocols) == 0 {
- protocols = netProtocols
- }
-
- stats := make([]ProtoCountersStat, 0, len(protocols))
- protos := make(map[string]bool, len(protocols))
- for _, p := range protocols {
- protos[p] = true
- }
-
- filename := common.HostProc("net/snmp")
- lines, err := common.ReadLines(filename)
- if err != nil {
- return nil, err
- }
-
- linecount := len(lines)
- for i := 0; i < linecount; i++ {
- line := lines[i]
- r := strings.IndexRune(line, ':')
- if r == -1 {
- return nil, errors.New(filename + " is not fomatted correctly, expected ':'.")
- }
- proto := strings.ToLower(line[:r])
- if !protos[proto] {
- // skip protocol and data line
- i++
- continue
- }
-
- // Read header line
- statNames := strings.Split(line[r+2:], " ")
-
- // Read data line
- i++
- statValues := strings.Split(lines[i][r+2:], " ")
- if len(statNames) != len(statValues) {
- return nil, errors.New(filename + " is not fomatted correctly, expected same number of columns.")
- }
- stat := ProtoCountersStat{
- Protocol: proto,
- Stats: make(map[string]int64, len(statNames)),
- }
- for j := range statNames {
- value, err := strconv.ParseInt(statValues[j], 10, 64)
- if err != nil {
- return nil, err
- }
- stat.Stats[statNames[j]] = value
- }
- stats = append(stats, stat)
- }
- return stats, nil
-}
-
-// NetFilterCounters returns iptables conntrack statistics
-// the currently in use conntrack count and the max.
-// If the file does not exist or is invalid it will return nil.
-func FilterCounters() ([]FilterStat, error) {
- return FilterCountersWithContext(context.Background())
-}
-
-func FilterCountersWithContext(ctx context.Context) ([]FilterStat, error) {
- countfile := common.HostProc("sys/net/netfilter/nf_conntrack_count")
- maxfile := common.HostProc("sys/net/netfilter/nf_conntrack_max")
-
- count, err := common.ReadInts(countfile)
-
- if err != nil {
- return nil, err
- }
- stats := make([]FilterStat, 0, 1)
-
- max, err := common.ReadInts(maxfile)
- if err != nil {
- return nil, err
- }
-
- payload := FilterStat{
- ConnTrackCount: count[0],
- ConnTrackMax: max[0],
- }
-
- stats = append(stats, payload)
- return stats, nil
-}
-
-// http://students.mimuw.edu.pl/lxr/source/include/net/tcp_states.h
-var TCPStatuses = map[string]string{
- "01": "ESTABLISHED",
- "02": "SYN_SENT",
- "03": "SYN_RECV",
- "04": "FIN_WAIT1",
- "05": "FIN_WAIT2",
- "06": "TIME_WAIT",
- "07": "CLOSE",
- "08": "CLOSE_WAIT",
- "09": "LAST_ACK",
- "0A": "LISTEN",
- "0B": "CLOSING",
-}
-
-type netConnectionKindType struct {
- family uint32
- sockType uint32
- filename string
-}
-
-var kindTCP4 = netConnectionKindType{
- family: syscall.AF_INET,
- sockType: syscall.SOCK_STREAM,
- filename: "tcp",
-}
-var kindTCP6 = netConnectionKindType{
- family: syscall.AF_INET6,
- sockType: syscall.SOCK_STREAM,
- filename: "tcp6",
-}
-var kindUDP4 = netConnectionKindType{
- family: syscall.AF_INET,
- sockType: syscall.SOCK_DGRAM,
- filename: "udp",
-}
-var kindUDP6 = netConnectionKindType{
- family: syscall.AF_INET6,
- sockType: syscall.SOCK_DGRAM,
- filename: "udp6",
-}
-var kindUNIX = netConnectionKindType{
- family: syscall.AF_UNIX,
- filename: "unix",
-}
-
-var netConnectionKindMap = map[string][]netConnectionKindType{
- "all": {kindTCP4, kindTCP6, kindUDP4, kindUDP6, kindUNIX},
- "tcp": {kindTCP4, kindTCP6},
- "tcp4": {kindTCP4},
- "tcp6": {kindTCP6},
- "udp": {kindUDP4, kindUDP6},
- "udp4": {kindUDP4},
- "udp6": {kindUDP6},
- "unix": {kindUNIX},
- "inet": {kindTCP4, kindTCP6, kindUDP4, kindUDP6},
- "inet4": {kindTCP4, kindUDP4},
- "inet6": {kindTCP6, kindUDP6},
-}
-
-type inodeMap struct {
- pid int32
- fd uint32
-}
-
-type connTmp struct {
- fd uint32
- family uint32
- sockType uint32
- laddr Addr
- raddr Addr
- status string
- pid int32
- boundPid int32
- path string
-}
-
-// Return a list of network connections opened.
-func Connections(kind string) ([]ConnectionStat, error) {
- return ConnectionsWithContext(context.Background(), kind)
-}
-
-func ConnectionsWithContext(ctx context.Context, kind string) ([]ConnectionStat, error) {
- return ConnectionsPid(kind, 0)
-}
-
-// Return a list of network connections opened returning at most `max`
-// connections for each running process.
-func ConnectionsMax(kind string, max int) ([]ConnectionStat, error) {
- return ConnectionsMaxWithContext(context.Background(), kind, max)
-}
-
-func ConnectionsMaxWithContext(ctx context.Context, kind string, max int) ([]ConnectionStat, error) {
- return ConnectionsPidMax(kind, 0, max)
-}
-
-// Return a list of network connections opened by a process.
-func ConnectionsPid(kind string, pid int32) ([]ConnectionStat, error) {
- return ConnectionsPidWithContext(context.Background(), kind, pid)
-}
-
-func ConnectionsPidWithContext(ctx context.Context, kind string, pid int32) ([]ConnectionStat, error) {
- tmap, ok := netConnectionKindMap[kind]
- if !ok {
- return nil, fmt.Errorf("invalid kind, %s", kind)
- }
- root := common.HostProc()
- var err error
- var inodes map[string][]inodeMap
- if pid == 0 {
- inodes, err = getProcInodesAll(root, 0)
- } else {
- inodes, err = getProcInodes(root, pid, 0)
- if len(inodes) == 0 {
- // no connection for the pid
- return []ConnectionStat{}, nil
- }
- }
- if err != nil {
- return nil, fmt.Errorf("cound not get pid(s), %d: %s", pid, err)
- }
- return statsFromInodes(root, pid, tmap, inodes)
-}
-
-// Return up to `max` network connections opened by a process.
-func ConnectionsPidMax(kind string, pid int32, max int) ([]ConnectionStat, error) {
- return ConnectionsPidMaxWithContext(context.Background(), kind, pid, max)
-}
-
-func ConnectionsPidMaxWithContext(ctx context.Context, kind string, pid int32, max int) ([]ConnectionStat, error) {
- tmap, ok := netConnectionKindMap[kind]
- if !ok {
- return nil, fmt.Errorf("invalid kind, %s", kind)
- }
- root := common.HostProc()
- var err error
- var inodes map[string][]inodeMap
- if pid == 0 {
- inodes, err = getProcInodesAll(root, max)
- } else {
- inodes, err = getProcInodes(root, pid, max)
- if len(inodes) == 0 {
- // no connection for the pid
- return []ConnectionStat{}, nil
- }
- }
- if err != nil {
- return nil, fmt.Errorf("cound not get pid(s), %d", pid)
- }
- return statsFromInodes(root, pid, tmap, inodes)
-}
-
-func statsFromInodes(root string, pid int32, tmap []netConnectionKindType, inodes map[string][]inodeMap) ([]ConnectionStat, error) {
- dupCheckMap := make(map[string]struct{})
- var ret []ConnectionStat
-
- var err error
- for _, t := range tmap {
- var path string
- var connKey string
- var ls []connTmp
- path = fmt.Sprintf("%s/net/%s", root, t.filename)
- switch t.family {
- case syscall.AF_INET:
- fallthrough
- case syscall.AF_INET6:
- ls, err = processInet(path, t, inodes, pid)
- case syscall.AF_UNIX:
- ls, err = processUnix(path, t, inodes, pid)
- }
- if err != nil {
- return nil, err
- }
- for _, c := range ls {
- // Build TCP key to id the connection uniquely
- // socket type, src ip, src port, dst ip, dst port and state should be enough
- // to prevent duplications.
- connKey = fmt.Sprintf("%d-%s:%d-%s:%d-%s", c.sockType, c.laddr.IP, c.laddr.Port, c.raddr.IP, c.raddr.Port, c.status)
- if _, ok := dupCheckMap[connKey]; ok {
- continue
- }
-
- conn := ConnectionStat{
- Fd: c.fd,
- Family: c.family,
- Type: c.sockType,
- Laddr: c.laddr,
- Raddr: c.raddr,
- Status: c.status,
- Pid: c.pid,
- }
- if c.pid == 0 {
- conn.Pid = c.boundPid
- } else {
- conn.Pid = c.pid
- }
-
- // fetch process owner Real, effective, saved set, and filesystem UIDs
- proc := process{Pid: conn.Pid}
- conn.Uids, _ = proc.getUids()
-
- ret = append(ret, conn)
- dupCheckMap[connKey] = struct{}{}
- }
-
- }
-
- return ret, nil
-}
-
-// getProcInodes returnes fd of the pid.
-func getProcInodes(root string, pid int32, max int) (map[string][]inodeMap, error) {
- ret := make(map[string][]inodeMap)
-
- dir := fmt.Sprintf("%s/%d/fd", root, pid)
- f, err := os.Open(dir)
- if err != nil {
- return ret, err
- }
- defer f.Close()
- files, err := f.Readdir(max)
- if err != nil {
- return ret, err
- }
- for _, fd := range files {
- inodePath := fmt.Sprintf("%s/%d/fd/%s", root, pid, fd.Name())
-
- inode, err := os.Readlink(inodePath)
- if err != nil {
- continue
- }
- if !strings.HasPrefix(inode, "socket:[") {
- continue
- }
- // the process is using a socket
- l := len(inode)
- inode = inode[8 : l-1]
- _, ok := ret[inode]
- if !ok {
- ret[inode] = make([]inodeMap, 0)
- }
- fd, err := strconv.Atoi(fd.Name())
- if err != nil {
- continue
- }
-
- i := inodeMap{
- pid: pid,
- fd: uint32(fd),
- }
- ret[inode] = append(ret[inode], i)
- }
- return ret, nil
-}
-
-// Pids retunres all pids.
-// Note: this is a copy of process_linux.Pids()
-// FIXME: Import process occures import cycle.
-// move to common made other platform breaking. Need consider.
-func Pids() ([]int32, error) {
- return PidsWithContext(context.Background())
-}
-
-func PidsWithContext(ctx context.Context) ([]int32, error) {
- var ret []int32
-
- d, err := os.Open(common.HostProc())
- if err != nil {
- return nil, err
- }
- defer d.Close()
-
- fnames, err := d.Readdirnames(-1)
- if err != nil {
- return nil, err
- }
- for _, fname := range fnames {
- pid, err := strconv.ParseInt(fname, 10, 32)
- if err != nil {
- // if not numeric name, just skip
- continue
- }
- ret = append(ret, int32(pid))
- }
-
- return ret, nil
-}
-
-// Note: the following is based off process_linux structs and methods
-// we need these to fetch the owner of a process ID
-// FIXME: Import process occures import cycle.
-// see remarks on pids()
-type process struct {
- Pid int32 `json:"pid"`
- uids []int32
-}
-
-// Uids returns user ids of the process as a slice of the int
-func (p *process) getUids() ([]int32, error) {
- err := p.fillFromStatus()
- if err != nil {
- return []int32{}, err
- }
- return p.uids, nil
-}
-
-// Get status from /proc/(pid)/status
-func (p *process) fillFromStatus() error {
- pid := p.Pid
- statPath := common.HostProc(strconv.Itoa(int(pid)), "status")
- contents, err := ioutil.ReadFile(statPath)
- if err != nil {
- return err
- }
- lines := strings.Split(string(contents), "\n")
- for _, line := range lines {
- tabParts := strings.SplitN(line, "\t", 2)
- if len(tabParts) < 2 {
- continue
- }
- value := tabParts[1]
- switch strings.TrimRight(tabParts[0], ":") {
- case "Uid":
- p.uids = make([]int32, 0, 4)
- for _, i := range strings.Split(value, "\t") {
- v, err := strconv.ParseInt(i, 10, 32)
- if err != nil {
- return err
- }
- p.uids = append(p.uids, int32(v))
- }
- }
- }
- return nil
-}
-
-func getProcInodesAll(root string, max int) (map[string][]inodeMap, error) {
- pids, err := Pids()
- if err != nil {
- return nil, err
- }
- ret := make(map[string][]inodeMap)
-
- for _, pid := range pids {
- t, err := getProcInodes(root, pid, max)
- if err != nil {
- // skip if permission error or no longer exists
- if os.IsPermission(err) || os.IsNotExist(err) {
- continue
- }
- return ret, err
- }
- if len(t) == 0 {
- continue
- }
- // TODO: update ret.
- ret = updateMap(ret, t)
- }
- return ret, nil
-}
-
-// decodeAddress decode addresse represents addr in proc/net/*
-// ex:
-// "0500000A:0016" -> "10.0.0.5", 22
-// "0085002452100113070057A13F025401:0035" -> "2400:8500:1301:1052:a157:7:154:23f", 53
-func decodeAddress(family uint32, src string) (Addr, error) {
- t := strings.Split(src, ":")
- if len(t) != 2 {
- return Addr{}, fmt.Errorf("does not contain port, %s", src)
- }
- addr := t[0]
- port, err := strconv.ParseInt("0x"+t[1], 0, 64)
- if err != nil {
- return Addr{}, fmt.Errorf("invalid port, %s", src)
- }
- decoded, err := hex.DecodeString(addr)
- if err != nil {
- return Addr{}, fmt.Errorf("decode error, %s", err)
- }
- var ip net.IP
- // Assumes this is little_endian
- if family == syscall.AF_INET {
- ip = net.IP(Reverse(decoded))
- } else { // IPv6
- ip, err = parseIPv6HexString(decoded)
- if err != nil {
- return Addr{}, err
- }
- }
- return Addr{
- IP: ip.String(),
- Port: uint32(port),
- }, nil
-}
-
-// Reverse reverses array of bytes.
-func Reverse(s []byte) []byte {
- return ReverseWithContext(context.Background(), s)
-}
-
-func ReverseWithContext(ctx context.Context, s []byte) []byte {
- for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
- s[i], s[j] = s[j], s[i]
- }
- return s
-}
-
-// parseIPv6HexString parse array of bytes to IPv6 string
-func parseIPv6HexString(src []byte) (net.IP, error) {
- if len(src) != 16 {
- return nil, fmt.Errorf("invalid IPv6 string")
- }
-
- buf := make([]byte, 0, 16)
- for i := 0; i < len(src); i += 4 {
- r := Reverse(src[i : i+4])
- buf = append(buf, r...)
- }
- return net.IP(buf), nil
-}
-
-func processInet(file string, kind netConnectionKindType, inodes map[string][]inodeMap, filterPid int32) ([]connTmp, error) {
-
- if strings.HasSuffix(file, "6") && !common.PathExists(file) {
- // IPv6 not supported, return empty.
- return []connTmp{}, nil
- }
-
- // Read the contents of the /proc file with a single read sys call.
- // This minimizes duplicates in the returned connections
- // For more info:
- // https://github.com/shirou/gopsutil/pull/361
- contents, err := ioutil.ReadFile(file)
- if err != nil {
- return nil, err
- }
-
- lines := bytes.Split(contents, []byte("\n"))
-
- var ret []connTmp
- // skip first line
- for _, line := range lines[1:] {
- l := strings.Fields(string(line))
- if len(l) < 10 {
- continue
- }
- laddr := l[1]
- raddr := l[2]
- status := l[3]
- inode := l[9]
- pid := int32(0)
- fd := uint32(0)
- i, exists := inodes[inode]
- if exists {
- pid = i[0].pid
- fd = i[0].fd
- }
- if filterPid > 0 && filterPid != pid {
- continue
- }
- if kind.sockType == syscall.SOCK_STREAM {
- status = TCPStatuses[status]
- } else {
- status = "NONE"
- }
- la, err := decodeAddress(kind.family, laddr)
- if err != nil {
- continue
- }
- ra, err := decodeAddress(kind.family, raddr)
- if err != nil {
- continue
- }
-
- ret = append(ret, connTmp{
- fd: fd,
- family: kind.family,
- sockType: kind.sockType,
- laddr: la,
- raddr: ra,
- status: status,
- pid: pid,
- })
- }
-
- return ret, nil
-}
-
-func processUnix(file string, kind netConnectionKindType, inodes map[string][]inodeMap, filterPid int32) ([]connTmp, error) {
- // Read the contents of the /proc file with a single read sys call.
- // This minimizes duplicates in the returned connections
- // For more info:
- // https://github.com/shirou/gopsutil/pull/361
- contents, err := ioutil.ReadFile(file)
- if err != nil {
- return nil, err
- }
-
- lines := bytes.Split(contents, []byte("\n"))
-
- var ret []connTmp
- // skip first line
- for _, line := range lines[1:] {
- tokens := strings.Fields(string(line))
- if len(tokens) < 6 {
- continue
- }
- st, err := strconv.Atoi(tokens[4])
- if err != nil {
- return nil, err
- }
-
- inode := tokens[6]
-
- var pairs []inodeMap
- pairs, exists := inodes[inode]
- if !exists {
- pairs = []inodeMap{
- {},
- }
- }
- for _, pair := range pairs {
- if filterPid > 0 && filterPid != pair.pid {
- continue
- }
- var path string
- if len(tokens) == 8 {
- path = tokens[len(tokens)-1]
- }
- ret = append(ret, connTmp{
- fd: pair.fd,
- family: kind.family,
- sockType: uint32(st),
- laddr: Addr{
- IP: path,
- },
- pid: pair.pid,
- status: "NONE",
- path: path,
- })
- }
- }
-
- return ret, nil
-}
-
-func updateMap(src map[string][]inodeMap, add map[string][]inodeMap) map[string][]inodeMap {
- for key, value := range add {
- a, exists := src[key]
- if !exists {
- src[key] = value
- continue
- }
- src[key] = append(a, value...)
- }
- return src
-}
diff --git a/vendor/github.com/shirou/gopsutil/net/net_openbsd.go b/vendor/github.com/shirou/gopsutil/net/net_openbsd.go
deleted file mode 100644
index 3e74e8f..0000000
--- a/vendor/github.com/shirou/gopsutil/net/net_openbsd.go
+++ /dev/null
@@ -1,312 +0,0 @@
-// +build openbsd
-
-package net
-
-import (
- "context"
- "errors"
- "fmt"
- "os/exec"
- "regexp"
- "strconv"
- "strings"
- "syscall"
-
- "github.com/shirou/gopsutil/internal/common"
-)
-
-var portMatch = regexp.MustCompile(`(.*)\.(\d+)$`)
-
-func ParseNetstat(output string, mode string,
- iocs map[string]IOCountersStat) error {
- lines := strings.Split(output, "\n")
-
- exists := make([]string, 0, len(lines)-1)
-
- columns := 6
- if mode == "ind" {
- columns = 10
- }
- for _, line := range lines {
- values := strings.Fields(line)
- if len(values) < 1 || values[0] == "Name" {
- continue
- }
- if common.StringsHas(exists, values[0]) {
- // skip if already get
- continue
- }
-
- if len(values) < columns {
- continue
- }
- base := 1
- // sometimes Address is ommitted
- if len(values) < columns {
- base = 0
- }
-
- parsed := make([]uint64, 0, 8)
- var vv []string
- if mode == "inb" {
- vv = []string{
- values[base+3], // BytesRecv
- values[base+4], // BytesSent
- }
- } else {
- vv = []string{
- values[base+3], // Ipkts
- values[base+4], // Ierrs
- values[base+5], // Opkts
- values[base+6], // Oerrs
- values[base+8], // Drops
- }
- }
- for _, target := range vv {
- if target == "-" {
- parsed = append(parsed, 0)
- continue
- }
-
- t, err := strconv.ParseUint(target, 10, 64)
- if err != nil {
- return err
- }
- parsed = append(parsed, t)
- }
- exists = append(exists, values[0])
-
- n, present := iocs[values[0]]
- if !present {
- n = IOCountersStat{Name: values[0]}
- }
- if mode == "inb" {
- n.BytesRecv = parsed[0]
- n.BytesSent = parsed[1]
- } else {
- n.PacketsRecv = parsed[0]
- n.Errin = parsed[1]
- n.PacketsSent = parsed[2]
- n.Errout = parsed[3]
- n.Dropin = parsed[4]
- n.Dropout = parsed[4]
- }
-
- iocs[n.Name] = n
- }
- return nil
-}
-
-func IOCounters(pernic bool) ([]IOCountersStat, error) {
- return IOCountersWithContext(context.Background(), pernic)
-}
-
-func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat, error) {
- netstat, err := exec.LookPath("netstat")
- if err != nil {
- return nil, err
- }
- out, err := invoke.CommandWithContext(ctx, netstat, "-inb")
- if err != nil {
- return nil, err
- }
- out2, err := invoke.CommandWithContext(ctx, netstat, "-ind")
- if err != nil {
- return nil, err
- }
- iocs := make(map[string]IOCountersStat)
-
- lines := strings.Split(string(out), "\n")
- ret := make([]IOCountersStat, 0, len(lines)-1)
-
- err = ParseNetstat(string(out), "inb", iocs)
- if err != nil {
- return nil, err
- }
- err = ParseNetstat(string(out2), "ind", iocs)
- if err != nil {
- return nil, err
- }
-
- for _, ioc := range iocs {
- ret = append(ret, ioc)
- }
-
- if pernic == false {
- return getIOCountersAll(ret)
- }
-
- return ret, nil
-}
-
-// NetIOCountersByFile is an method which is added just a compatibility for linux.
-func IOCountersByFile(pernic bool, filename string) ([]IOCountersStat, error) {
- return IOCountersByFileWithContext(context.Background(), pernic, filename)
-}
-
-func IOCountersByFileWithContext(ctx context.Context, pernic bool, filename string) ([]IOCountersStat, error) {
- return IOCounters(pernic)
-}
-
-func FilterCounters() ([]FilterStat, error) {
- return FilterCountersWithContext(context.Background())
-}
-
-func FilterCountersWithContext(ctx context.Context) ([]FilterStat, error) {
- return nil, errors.New("NetFilterCounters not implemented for openbsd")
-}
-
-// NetProtoCounters returns network statistics for the entire system
-// If protocols is empty then all protocols are returned, otherwise
-// just the protocols in the list are returned.
-// Not Implemented for OpenBSD
-func ProtoCounters(protocols []string) ([]ProtoCountersStat, error) {
- return ProtoCountersWithContext(context.Background(), protocols)
-}
-
-func ProtoCountersWithContext(ctx context.Context, protocols []string) ([]ProtoCountersStat, error) {
- return nil, errors.New("NetProtoCounters not implemented for openbsd")
-}
-
-func parseNetstatLine(line string) (ConnectionStat, error) {
- f := strings.Fields(line)
- if len(f) < 5 {
- return ConnectionStat{}, fmt.Errorf("wrong line,%s", line)
- }
-
- var netType, netFamily uint32
- switch f[0] {
- case "tcp":
- netType = syscall.SOCK_STREAM
- netFamily = syscall.AF_INET
- case "udp":
- netType = syscall.SOCK_DGRAM
- netFamily = syscall.AF_INET
- case "tcp6":
- netType = syscall.SOCK_STREAM
- netFamily = syscall.AF_INET6
- case "udp6":
- netType = syscall.SOCK_DGRAM
- netFamily = syscall.AF_INET6
- default:
- return ConnectionStat{}, fmt.Errorf("unknown type, %s", f[0])
- }
-
- laddr, raddr, err := parseNetstatAddr(f[3], f[4], netFamily)
- if err != nil {
- return ConnectionStat{}, fmt.Errorf("failed to parse netaddr, %s %s", f[3], f[4])
- }
-
- n := ConnectionStat{
- Fd: uint32(0), // not supported
- Family: uint32(netFamily),
- Type: uint32(netType),
- Laddr: laddr,
- Raddr: raddr,
- Pid: int32(0), // not supported
- }
- if len(f) == 6 {
- n.Status = f[5]
- }
-
- return n, nil
-}
-
-func parseNetstatAddr(local string, remote string, family uint32) (laddr Addr, raddr Addr, err error) {
- parse := func(l string) (Addr, error) {
- matches := portMatch.FindStringSubmatch(l)
- if matches == nil {
- return Addr{}, fmt.Errorf("wrong addr, %s", l)
- }
- host := matches[1]
- port := matches[2]
- if host == "*" {
- switch family {
- case syscall.AF_INET:
- host = "0.0.0.0"
- case syscall.AF_INET6:
- host = "::"
- default:
- return Addr{}, fmt.Errorf("unknown family, %d", family)
- }
- }
- lport, err := strconv.Atoi(port)
- if err != nil {
- return Addr{}, err
- }
- return Addr{IP: host, Port: uint32(lport)}, nil
- }
-
- laddr, err = parse(local)
- if remote != "*.*" { // remote addr exists
- raddr, err = parse(remote)
- if err != nil {
- return laddr, raddr, err
- }
- }
-
- return laddr, raddr, err
-}
-
-// Return a list of network connections opened.
-func Connections(kind string) ([]ConnectionStat, error) {
- return ConnectionsWithContext(context.Background(), kind)
-}
-
-func ConnectionsWithContext(ctx context.Context, kind string) ([]ConnectionStat, error) {
- var ret []ConnectionStat
-
- args := []string{"-na"}
- switch strings.ToLower(kind) {
- default:
- fallthrough
- case "":
- fallthrough
- case "all":
- fallthrough
- case "inet":
- // nothing to add
- case "inet4":
- args = append(args, "-finet")
- case "inet6":
- args = append(args, "-finet6")
- case "tcp":
- args = append(args, "-ptcp")
- case "tcp4":
- args = append(args, "-ptcp", "-finet")
- case "tcp6":
- args = append(args, "-ptcp", "-finet6")
- case "udp":
- args = append(args, "-pudp")
- case "udp4":
- args = append(args, "-pudp", "-finet")
- case "udp6":
- args = append(args, "-pudp", "-finet6")
- case "unix":
- return ret, common.ErrNotImplementedError
- }
-
- netstat, err := exec.LookPath("netstat")
- if err != nil {
- return nil, err
- }
- out, err := invoke.CommandWithContext(ctx, netstat, args...)
-
- if err != nil {
- return nil, err
- }
- lines := strings.Split(string(out), "\n")
- for _, line := range lines {
- if !(strings.HasPrefix(line, "tcp") || strings.HasPrefix(line, "udp")) {
- continue
- }
- n, err := parseNetstatLine(line)
- if err != nil {
- continue
- }
-
- ret = append(ret, n)
- }
-
- return ret, nil
-}
diff --git a/vendor/github.com/shirou/gopsutil/net/net_unix.go b/vendor/github.com/shirou/gopsutil/net/net_unix.go
deleted file mode 100644
index 4451b54..0000000
--- a/vendor/github.com/shirou/gopsutil/net/net_unix.go
+++ /dev/null
@@ -1,96 +0,0 @@
-// +build freebsd darwin
-
-package net
-
-import (
- "context"
- "strings"
-
- "github.com/shirou/gopsutil/internal/common"
-)
-
-// Return a list of network connections opened.
-func Connections(kind string) ([]ConnectionStat, error) {
- return ConnectionsWithContext(context.Background(), kind)
-}
-
-func ConnectionsWithContext(ctx context.Context, kind string) ([]ConnectionStat, error) {
- return ConnectionsPid(kind, 0)
-}
-
-// Return a list of network connections opened returning at most `max`
-// connections for each running process.
-func ConnectionsMax(kind string, max int) ([]ConnectionStat, error) {
- return ConnectionsMaxWithContext(context.Background(), kind, max)
-}
-
-func ConnectionsMaxWithContext(ctx context.Context, kind string, max int) ([]ConnectionStat, error) {
- return []ConnectionStat{}, common.ErrNotImplementedError
-}
-
-// Return a list of network connections opened by a process.
-func ConnectionsPid(kind string, pid int32) ([]ConnectionStat, error) {
- return ConnectionsPidWithContext(context.Background(), kind, pid)
-}
-
-func ConnectionsPidWithContext(ctx context.Context, kind string, pid int32) ([]ConnectionStat, error) {
- var ret []ConnectionStat
-
- args := []string{"-i"}
- switch strings.ToLower(kind) {
- default:
- fallthrough
- case "":
- fallthrough
- case "all":
- fallthrough
- case "inet":
- args = append(args, "tcp", "-i", "udp")
- case "inet4":
- args = append(args, "4")
- case "inet6":
- args = append(args, "6")
- case "tcp":
- args = append(args, "tcp")
- case "tcp4":
- args = append(args, "4tcp")
- case "tcp6":
- args = append(args, "6tcp")
- case "udp":
- args = append(args, "udp")
- case "udp4":
- args = append(args, "6udp")
- case "udp6":
- args = append(args, "6udp")
- case "unix":
- args = []string{"-U"}
- }
-
- r, err := common.CallLsofWithContext(ctx, invoke, pid, args...)
- if err != nil {
- return nil, err
- }
- for _, rr := range r {
- if strings.HasPrefix(rr, "COMMAND") {
- continue
- }
- n, err := parseNetLine(rr)
- if err != nil {
-
- continue
- }
-
- ret = append(ret, n)
- }
-
- return ret, nil
-}
-
-// Return up to `max` network connections opened by a process.
-func ConnectionsPidMax(kind string, pid int32, max int) ([]ConnectionStat, error) {
- return ConnectionsPidMaxWithContext(context.Background(), kind, pid, max)
-}
-
-func ConnectionsPidMaxWithContext(ctx context.Context, kind string, pid int32, max int) ([]ConnectionStat, error) {
- return []ConnectionStat{}, common.ErrNotImplementedError
-}
diff --git a/vendor/github.com/shirou/gopsutil/net/net_windows.go b/vendor/github.com/shirou/gopsutil/net/net_windows.go
deleted file mode 100644
index 7fff20e..0000000
--- a/vendor/github.com/shirou/gopsutil/net/net_windows.go
+++ /dev/null
@@ -1,120 +0,0 @@
-// +build windows
-
-package net
-
-import (
- "context"
- "errors"
- "net"
- "os"
-
- "github.com/shirou/gopsutil/internal/common"
- "golang.org/x/sys/windows"
-)
-
-var (
- modiphlpapi = windows.NewLazyDLL("iphlpapi.dll")
- procGetExtendedTCPTable = modiphlpapi.NewProc("GetExtendedTcpTable")
- procGetExtendedUDPTable = modiphlpapi.NewProc("GetExtendedUdpTable")
-)
-
-const (
- TCPTableBasicListener = iota
- TCPTableBasicConnections
- TCPTableBasicAll
- TCPTableOwnerPIDListener
- TCPTableOwnerPIDConnections
- TCPTableOwnerPIDAll
- TCPTableOwnerModuleListener
- TCPTableOwnerModuleConnections
- TCPTableOwnerModuleAll
-)
-
-func IOCounters(pernic bool) ([]IOCountersStat, error) {
- return IOCountersWithContext(context.Background(), pernic)
-}
-
-func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat, error) {
- ifs, err := net.Interfaces()
- if err != nil {
- return nil, err
- }
- var ret []IOCountersStat
-
- for _, ifi := range ifs {
- c := IOCountersStat{
- Name: ifi.Name,
- }
-
- row := windows.MibIfRow{Index: uint32(ifi.Index)}
- e := windows.GetIfEntry(&row)
- if e != nil {
- return nil, os.NewSyscallError("GetIfEntry", e)
- }
- c.BytesSent = uint64(row.OutOctets)
- c.BytesRecv = uint64(row.InOctets)
- c.PacketsSent = uint64(row.OutUcastPkts)
- c.PacketsRecv = uint64(row.InUcastPkts)
- c.Errin = uint64(row.InErrors)
- c.Errout = uint64(row.OutErrors)
- c.Dropin = uint64(row.InDiscards)
- c.Dropout = uint64(row.OutDiscards)
-
- ret = append(ret, c)
- }
-
- if pernic == false {
- return getIOCountersAll(ret)
- }
- return ret, nil
-}
-
-// NetIOCountersByFile is an method which is added just a compatibility for linux.
-func IOCountersByFile(pernic bool, filename string) ([]IOCountersStat, error) {
- return IOCountersByFileWithContext(context.Background(), pernic, filename)
-}
-
-func IOCountersByFileWithContext(ctx context.Context, pernic bool, filename string) ([]IOCountersStat, error) {
- return IOCounters(pernic)
-}
-
-// Return a list of network connections opened by a process
-func Connections(kind string) ([]ConnectionStat, error) {
- return ConnectionsWithContext(context.Background(), kind)
-}
-
-func ConnectionsWithContext(ctx context.Context, kind string) ([]ConnectionStat, error) {
- var ret []ConnectionStat
-
- return ret, common.ErrNotImplementedError
-}
-
-// Return a list of network connections opened returning at most `max`
-// connections for each running process.
-func ConnectionsMax(kind string, max int) ([]ConnectionStat, error) {
- return ConnectionsMaxWithContext(context.Background(), kind, max)
-}
-
-func ConnectionsMaxWithContext(ctx context.Context, kind string, max int) ([]ConnectionStat, error) {
- return []ConnectionStat{}, common.ErrNotImplementedError
-}
-
-func FilterCounters() ([]FilterStat, error) {
- return FilterCountersWithContext(context.Background())
-}
-
-func FilterCountersWithContext(ctx context.Context) ([]FilterStat, error) {
- return nil, errors.New("NetFilterCounters not implemented for windows")
-}
-
-// NetProtoCounters returns network statistics for the entire system
-// If protocols is empty then all protocols are returned, otherwise
-// just the protocols in the list are returned.
-// Not Implemented for Windows
-func ProtoCounters(protocols []string) ([]ProtoCountersStat, error) {
- return ProtoCountersWithContext(context.Background(), protocols)
-}
-
-func ProtoCountersWithContext(ctx context.Context, protocols []string) ([]ProtoCountersStat, error) {
- return nil, errors.New("NetProtoCounters not implemented for windows")
-}
diff --git a/vendor/github.com/shirou/gopsutil/process/process.go b/vendor/github.com/shirou/gopsutil/process/process.go
deleted file mode 100644
index a4b24f4..0000000
--- a/vendor/github.com/shirou/gopsutil/process/process.go
+++ /dev/null
@@ -1,241 +0,0 @@
-package process
-
-import (
- "context"
- "encoding/json"
- "errors"
- "runtime"
- "time"
-
- "github.com/shirou/gopsutil/cpu"
- "github.com/shirou/gopsutil/internal/common"
- "github.com/shirou/gopsutil/mem"
-)
-
-var (
- invoke common.Invoker = common.Invoke{}
- ErrorNoChildren = errors.New("process does not have children")
-)
-
-type Process struct {
- Pid int32 `json:"pid"`
- name string
- status string
- parent int32
- numCtxSwitches *NumCtxSwitchesStat
- uids []int32
- gids []int32
- numThreads int32
- memInfo *MemoryInfoStat
- sigInfo *SignalInfoStat
-
- lastCPUTimes *cpu.TimesStat
- lastCPUTime time.Time
-
- tgid int32
-}
-
-type OpenFilesStat struct {
- Path string `json:"path"`
- Fd uint64 `json:"fd"`
-}
-
-type MemoryInfoStat struct {
- RSS uint64 `json:"rss"` // bytes
- VMS uint64 `json:"vms"` // bytes
- Data uint64 `json:"data"` // bytes
- Stack uint64 `json:"stack"` // bytes
- Locked uint64 `json:"locked"` // bytes
- Swap uint64 `json:"swap"` // bytes
-}
-
-type SignalInfoStat struct {
- PendingProcess uint64 `json:"pending_process"`
- PendingThread uint64 `json:"pending_thread"`
- Blocked uint64 `json:"blocked"`
- Ignored uint64 `json:"ignored"`
- Caught uint64 `json:"caught"`
-}
-
-type RlimitStat struct {
- Resource int32 `json:"resource"`
- Soft int32 `json:"soft"` //TODO too small. needs to be uint64
- Hard int32 `json:"hard"` //TODO too small. needs to be uint64
- Used uint64 `json:"used"`
-}
-
-type IOCountersStat struct {
- ReadCount uint64 `json:"readCount"`
- WriteCount uint64 `json:"writeCount"`
- ReadBytes uint64 `json:"readBytes"`
- WriteBytes uint64 `json:"writeBytes"`
-}
-
-type NumCtxSwitchesStat struct {
- Voluntary int64 `json:"voluntary"`
- Involuntary int64 `json:"involuntary"`
-}
-
-// Resource limit constants are from /usr/include/x86_64-linux-gnu/bits/resource.h
-// from libc6-dev package in Ubuntu 16.10
-const (
- RLIMIT_CPU int32 = 0
- RLIMIT_FSIZE int32 = 1
- RLIMIT_DATA int32 = 2
- RLIMIT_STACK int32 = 3
- RLIMIT_CORE int32 = 4
- RLIMIT_RSS int32 = 5
- RLIMIT_NPROC int32 = 6
- RLIMIT_NOFILE int32 = 7
- RLIMIT_MEMLOCK int32 = 8
- RLIMIT_AS int32 = 9
- RLIMIT_LOCKS int32 = 10
- RLIMIT_SIGPENDING int32 = 11
- RLIMIT_MSGQUEUE int32 = 12
- RLIMIT_NICE int32 = 13
- RLIMIT_RTPRIO int32 = 14
- RLIMIT_RTTIME int32 = 15
-)
-
-func (p Process) String() string {
- s, _ := json.Marshal(p)
- return string(s)
-}
-
-func (o OpenFilesStat) String() string {
- s, _ := json.Marshal(o)
- return string(s)
-}
-
-func (m MemoryInfoStat) String() string {
- s, _ := json.Marshal(m)
- return string(s)
-}
-
-func (r RlimitStat) String() string {
- s, _ := json.Marshal(r)
- return string(s)
-}
-
-func (i IOCountersStat) String() string {
- s, _ := json.Marshal(i)
- return string(s)
-}
-
-func (p NumCtxSwitchesStat) String() string {
- s, _ := json.Marshal(p)
- return string(s)
-}
-
-func PidExists(pid int32) (bool, error) {
- return PidExistsWithContext(context.Background(), pid)
-}
-
-func PidExistsWithContext(ctx context.Context, pid int32) (bool, error) {
- pids, err := Pids()
- if err != nil {
- return false, err
- }
-
- for _, i := range pids {
- if i == pid {
- return true, err
- }
- }
-
- return false, err
-}
-
-// If interval is 0, return difference from last call(non-blocking).
-// If interval > 0, wait interval sec and return diffrence between start and end.
-func (p *Process) Percent(interval time.Duration) (float64, error) {
- return p.PercentWithContext(context.Background(), interval)
-}
-
-func (p *Process) PercentWithContext(ctx context.Context, interval time.Duration) (float64, error) {
- cpuTimes, err := p.Times()
- if err != nil {
- return 0, err
- }
- now := time.Now()
-
- if interval > 0 {
- p.lastCPUTimes = cpuTimes
- p.lastCPUTime = now
- time.Sleep(interval)
- cpuTimes, err = p.Times()
- now = time.Now()
- if err != nil {
- return 0, err
- }
- } else {
- if p.lastCPUTimes == nil {
- // invoked first time
- p.lastCPUTimes = cpuTimes
- p.lastCPUTime = now
- return 0, nil
- }
- }
-
- numcpu := runtime.NumCPU()
- delta := (now.Sub(p.lastCPUTime).Seconds()) * float64(numcpu)
- ret := calculatePercent(p.lastCPUTimes, cpuTimes, delta, numcpu)
- p.lastCPUTimes = cpuTimes
- p.lastCPUTime = now
- return ret, nil
-}
-
-func calculatePercent(t1, t2 *cpu.TimesStat, delta float64, numcpu int) float64 {
- if delta == 0 {
- return 0
- }
- delta_proc := t2.Total() - t1.Total()
- overall_percent := ((delta_proc / delta) * 100) * float64(numcpu)
- return overall_percent
-}
-
-// MemoryPercent returns how many percent of the total RAM this process uses
-func (p *Process) MemoryPercent() (float32, error) {
- return p.MemoryPercentWithContext(context.Background())
-}
-
-func (p *Process) MemoryPercentWithContext(ctx context.Context) (float32, error) {
- machineMemory, err := mem.VirtualMemory()
- if err != nil {
- return 0, err
- }
- total := machineMemory.Total
-
- processMemory, err := p.MemoryInfo()
- if err != nil {
- return 0, err
- }
- used := processMemory.RSS
-
- return (100 * float32(used) / float32(total)), nil
-}
-
-// CPU_Percent returns how many percent of the CPU time this process uses
-func (p *Process) CPUPercent() (float64, error) {
- return p.CPUPercentWithContext(context.Background())
-}
-
-func (p *Process) CPUPercentWithContext(ctx context.Context) (float64, error) {
- crt_time, err := p.CreateTime()
- if err != nil {
- return 0, err
- }
-
- cput, err := p.Times()
- if err != nil {
- return 0, err
- }
-
- created := time.Unix(0, crt_time*int64(time.Millisecond))
- totalTime := time.Since(created).Seconds()
- if totalTime <= 0 {
- return 0, nil
- }
-
- return 100 * cput.Total() / totalTime, nil
-}
diff --git a/vendor/github.com/shirou/gopsutil/process/process_darwin.go b/vendor/github.com/shirou/gopsutil/process/process_darwin.go
deleted file mode 100644
index c949154..0000000
--- a/vendor/github.com/shirou/gopsutil/process/process_darwin.go
+++ /dev/null
@@ -1,647 +0,0 @@
-// +build darwin
-
-package process
-
-import (
- "bytes"
- "context"
- "encoding/binary"
- "fmt"
- "os/exec"
- "strconv"
- "strings"
- "time"
- "unsafe"
-
- "github.com/shirou/gopsutil/cpu"
- "github.com/shirou/gopsutil/internal/common"
- "github.com/shirou/gopsutil/net"
- "golang.org/x/sys/unix"
-)
-
-// copied from sys/sysctl.h
-const (
- CTLKern = 1 // "high kernel": proc, limits
- KernProc = 14 // struct: process entries
- KernProcPID = 1 // by process id
- KernProcProc = 8 // only return procs
- KernProcAll = 0 // everything
- KernProcPathname = 12 // path to executable
-)
-
-const (
- ClockTicks = 100 // C.sysconf(C._SC_CLK_TCK)
-)
-
-type _Ctype_struct___0 struct {
- Pad uint64
-}
-
-// MemoryInfoExStat is different between OSes
-type MemoryInfoExStat struct {
-}
-
-type MemoryMapsStat struct {
-}
-
-func Pids() ([]int32, error) {
- return PidsWithContext(context.Background())
-}
-
-func PidsWithContext(ctx context.Context) ([]int32, error) {
- var ret []int32
-
- pids, err := callPsWithContext(ctx, "pid", 0, false)
- if err != nil {
- return ret, err
- }
-
- for _, pid := range pids {
- v, err := strconv.Atoi(pid[0])
- if err != nil {
- return ret, err
- }
- ret = append(ret, int32(v))
- }
-
- return ret, nil
-}
-
-func (p *Process) Ppid() (int32, error) {
- return p.PpidWithContext(context.Background())
-}
-
-func (p *Process) PpidWithContext(ctx context.Context) (int32, error) {
- r, err := callPsWithContext(ctx, "ppid", p.Pid, false)
- if err != nil {
- return 0, err
- }
-
- v, err := strconv.Atoi(r[0][0])
- if err != nil {
- return 0, err
- }
-
- return int32(v), err
-}
-func (p *Process) Name() (string, error) {
- return p.NameWithContext(context.Background())
-}
-
-func (p *Process) NameWithContext(ctx context.Context) (string, error) {
- k, err := p.getKProc()
- if err != nil {
- return "", err
- }
-
- return common.IntToString(k.Proc.P_comm[:]), nil
-}
-func (p *Process) Tgid() (int32, error) {
- return 0, common.ErrNotImplementedError
-}
-func (p *Process) Exe() (string, error) {
- return p.ExeWithContext(context.Background())
-}
-
-func (p *Process) ExeWithContext(ctx context.Context) (string, error) {
- lsof_bin, err := exec.LookPath("lsof")
- if err != nil {
- return "", err
- }
-
- awk_bin, err := exec.LookPath("awk")
- if err != nil {
- return "", err
- }
-
- sed_bin, err := exec.LookPath("sed")
- if err != nil {
- return "", err
- }
-
- lsof := exec.CommandContext(ctx, lsof_bin, "-p", strconv.Itoa(int(p.Pid)), "-Fpfn")
- awk := exec.CommandContext(ctx, awk_bin, "NR==5{print}")
- sed := exec.CommandContext(ctx, sed_bin, "s/n\\//\\//")
-
- output, _, err := common.Pipeline(lsof, awk, sed)
-
- if err != nil {
- return "", err
- }
-
- ret := strings.TrimSpace(string(output))
-
- return ret, nil
-}
-
-// Cmdline returns the command line arguments of the process as a string with
-// each argument separated by 0x20 ascii character.
-func (p *Process) Cmdline() (string, error) {
- return p.CmdlineWithContext(context.Background())
-}
-
-func (p *Process) CmdlineWithContext(ctx context.Context) (string, error) {
- r, err := callPsWithContext(ctx, "command", p.Pid, false)
- if err != nil {
- return "", err
- }
- return strings.Join(r[0], " "), err
-}
-
-// CmdlineSlice returns the command line arguments of the process as a slice with each
-// element being an argument. Because of current deficiencies in the way that the command
-// line arguments are found, single arguments that have spaces in the will actually be
-// reported as two separate items. In order to do something better CGO would be needed
-// to use the native darwin functions.
-func (p *Process) CmdlineSlice() ([]string, error) {
- return p.CmdlineSliceWithContext(context.Background())
-}
-
-func (p *Process) CmdlineSliceWithContext(ctx context.Context) ([]string, error) {
- r, err := callPsWithContext(ctx, "command", p.Pid, false)
- if err != nil {
- return nil, err
- }
- return r[0], err
-}
-func (p *Process) CreateTime() (int64, error) {
- return p.CreateTimeWithContext(context.Background())
-}
-
-func (p *Process) CreateTimeWithContext(ctx context.Context) (int64, error) {
- r, err := callPsWithContext(ctx, "etime", p.Pid, false)
- if err != nil {
- return 0, err
- }
-
- elapsedSegments := strings.Split(strings.Replace(r[0][0], "-", ":", 1), ":")
- var elapsedDurations []time.Duration
- for i := len(elapsedSegments) - 1; i >= 0; i-- {
- p, err := strconv.ParseInt(elapsedSegments[i], 10, 0)
- if err != nil {
- return 0, err
- }
- elapsedDurations = append(elapsedDurations, time.Duration(p))
- }
-
- var elapsed = time.Duration(elapsedDurations[0]) * time.Second
- if len(elapsedDurations) > 1 {
- elapsed += time.Duration(elapsedDurations[1]) * time.Minute
- }
- if len(elapsedDurations) > 2 {
- elapsed += time.Duration(elapsedDurations[2]) * time.Hour
- }
- if len(elapsedDurations) > 3 {
- elapsed += time.Duration(elapsedDurations[3]) * time.Hour * 24
- }
-
- start := time.Now().Add(-elapsed)
- return start.Unix() * 1000, nil
-}
-func (p *Process) Cwd() (string, error) {
- return p.CwdWithContext(context.Background())
-}
-
-func (p *Process) CwdWithContext(ctx context.Context) (string, error) {
- return "", common.ErrNotImplementedError
-}
-func (p *Process) Parent() (*Process, error) {
- return p.ParentWithContext(context.Background())
-}
-
-func (p *Process) ParentWithContext(ctx context.Context) (*Process, error) {
- rr, err := common.CallLsofWithContext(ctx, invoke, p.Pid, "-FR")
- if err != nil {
- return nil, err
- }
- for _, r := range rr {
- if strings.HasPrefix(r, "p") { // skip if process
- continue
- }
- l := string(r)
- v, err := strconv.Atoi(strings.Replace(l, "R", "", 1))
- if err != nil {
- return nil, err
- }
- return NewProcess(int32(v))
- }
- return nil, fmt.Errorf("could not find parent line")
-}
-func (p *Process) Status() (string, error) {
- return p.StatusWithContext(context.Background())
-}
-
-func (p *Process) StatusWithContext(ctx context.Context) (string, error) {
- r, err := callPsWithContext(ctx, "state", p.Pid, false)
- if err != nil {
- return "", err
- }
-
- return r[0][0], err
-}
-func (p *Process) Uids() ([]int32, error) {
- return p.UidsWithContext(context.Background())
-}
-
-func (p *Process) UidsWithContext(ctx context.Context) ([]int32, error) {
- k, err := p.getKProc()
- if err != nil {
- return nil, err
- }
-
- // See: http://unix.superglobalmegacorp.com/Net2/newsrc/sys/ucred.h.html
- userEffectiveUID := int32(k.Eproc.Ucred.UID)
-
- return []int32{userEffectiveUID}, nil
-}
-func (p *Process) Gids() ([]int32, error) {
- return p.GidsWithContext(context.Background())
-}
-
-func (p *Process) GidsWithContext(ctx context.Context) ([]int32, error) {
- k, err := p.getKProc()
- if err != nil {
- return nil, err
- }
-
- gids := make([]int32, 0, 3)
- gids = append(gids, int32(k.Eproc.Pcred.P_rgid), int32(k.Eproc.Ucred.Ngroups), int32(k.Eproc.Pcred.P_svgid))
-
- return gids, nil
-}
-func (p *Process) Terminal() (string, error) {
- return p.TerminalWithContext(context.Background())
-}
-
-func (p *Process) TerminalWithContext(ctx context.Context) (string, error) {
- return "", common.ErrNotImplementedError
- /*
- k, err := p.getKProc()
- if err != nil {
- return "", err
- }
-
- ttyNr := uint64(k.Eproc.Tdev)
- termmap, err := getTerminalMap()
- if err != nil {
- return "", err
- }
-
- return termmap[ttyNr], nil
- */
-}
-func (p *Process) Nice() (int32, error) {
- return p.NiceWithContext(context.Background())
-}
-
-func (p *Process) NiceWithContext(ctx context.Context) (int32, error) {
- k, err := p.getKProc()
- if err != nil {
- return 0, err
- }
- return int32(k.Proc.P_nice), nil
-}
-func (p *Process) IOnice() (int32, error) {
- return p.IOniceWithContext(context.Background())
-}
-
-func (p *Process) IOniceWithContext(ctx context.Context) (int32, error) {
- return 0, common.ErrNotImplementedError
-}
-func (p *Process) Rlimit() ([]RlimitStat, error) {
- return p.RlimitWithContext(context.Background())
-}
-
-func (p *Process) RlimitWithContext(ctx context.Context) ([]RlimitStat, error) {
- var rlimit []RlimitStat
- return rlimit, common.ErrNotImplementedError
-}
-func (p *Process) RlimitUsage(gatherUsed bool) ([]RlimitStat, error) {
- return p.RlimitUsageWithContext(context.Background(), gatherUsed)
-}
-
-func (p *Process) RlimitUsageWithContext(ctx context.Context, gatherUsed bool) ([]RlimitStat, error) {
- var rlimit []RlimitStat
- return rlimit, common.ErrNotImplementedError
-}
-func (p *Process) IOCounters() (*IOCountersStat, error) {
- return p.IOCountersWithContext(context.Background())
-}
-
-func (p *Process) IOCountersWithContext(ctx context.Context) (*IOCountersStat, error) {
- return nil, common.ErrNotImplementedError
-}
-func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error) {
- return p.NumCtxSwitchesWithContext(context.Background())
-}
-
-func (p *Process) NumCtxSwitchesWithContext(ctx context.Context) (*NumCtxSwitchesStat, error) {
- return nil, common.ErrNotImplementedError
-}
-func (p *Process) NumFDs() (int32, error) {
- return p.NumFDsWithContext(context.Background())
-}
-
-func (p *Process) NumFDsWithContext(ctx context.Context) (int32, error) {
- return 0, common.ErrNotImplementedError
-}
-func (p *Process) NumThreads() (int32, error) {
- return p.NumThreadsWithContext(context.Background())
-}
-
-func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) {
- r, err := callPsWithContext(ctx, "utime,stime", p.Pid, true)
- if err != nil {
- return 0, err
- }
- return int32(len(r)), nil
-}
-func (p *Process) Threads() (map[int32]*cpu.TimesStat, error) {
- return p.ThreadsWithContext(context.Background())
-}
-
-func (p *Process) ThreadsWithContext(ctx context.Context) (map[int32]*cpu.TimesStat, error) {
- ret := make(map[int32]*cpu.TimesStat)
- return ret, common.ErrNotImplementedError
-}
-
-func convertCPUTimes(s string) (ret float64, err error) {
- var t int
- var _tmp string
- if strings.Contains(s, ":") {
- _t := strings.Split(s, ":")
- hour, err := strconv.Atoi(_t[0])
- if err != nil {
- return ret, err
- }
- t += hour * 60 * 100
- _tmp = _t[1]
- } else {
- _tmp = s
- }
-
- _t := strings.Split(_tmp, ".")
- if err != nil {
- return ret, err
- }
- h, err := strconv.Atoi(_t[0])
- t += h * 100
- h, err = strconv.Atoi(_t[1])
- t += h
- return float64(t) / ClockTicks, nil
-}
-func (p *Process) Times() (*cpu.TimesStat, error) {
- return p.TimesWithContext(context.Background())
-}
-
-func (p *Process) TimesWithContext(ctx context.Context) (*cpu.TimesStat, error) {
- r, err := callPsWithContext(ctx, "utime,stime", p.Pid, false)
-
- if err != nil {
- return nil, err
- }
-
- utime, err := convertCPUTimes(r[0][0])
- if err != nil {
- return nil, err
- }
- stime, err := convertCPUTimes(r[0][1])
- if err != nil {
- return nil, err
- }
-
- ret := &cpu.TimesStat{
- CPU: "cpu",
- User: utime,
- System: stime,
- }
- return ret, nil
-}
-func (p *Process) CPUAffinity() ([]int32, error) {
- return p.CPUAffinityWithContext(context.Background())
-}
-
-func (p *Process) CPUAffinityWithContext(ctx context.Context) ([]int32, error) {
- return nil, common.ErrNotImplementedError
-}
-func (p *Process) MemoryInfo() (*MemoryInfoStat, error) {
- return p.MemoryInfoWithContext(context.Background())
-}
-
-func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, error) {
- r, err := callPsWithContext(ctx, "rss,vsize,pagein", p.Pid, false)
- if err != nil {
- return nil, err
- }
- rss, err := strconv.Atoi(r[0][0])
- if err != nil {
- return nil, err
- }
- vms, err := strconv.Atoi(r[0][1])
- if err != nil {
- return nil, err
- }
- pagein, err := strconv.Atoi(r[0][2])
- if err != nil {
- return nil, err
- }
-
- ret := &MemoryInfoStat{
- RSS: uint64(rss) * 1024,
- VMS: uint64(vms) * 1024,
- Swap: uint64(pagein),
- }
-
- return ret, nil
-}
-func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error) {
- return p.MemoryInfoExWithContext(context.Background())
-}
-
-func (p *Process) MemoryInfoExWithContext(ctx context.Context) (*MemoryInfoExStat, error) {
- return nil, common.ErrNotImplementedError
-}
-
-func (p *Process) Children() ([]*Process, error) {
- return p.ChildrenWithContext(context.Background())
-}
-
-func (p *Process) ChildrenWithContext(ctx context.Context) ([]*Process, error) {
- pids, err := common.CallPgrepWithContext(ctx, invoke, p.Pid)
- if err != nil {
- return nil, err
- }
- ret := make([]*Process, 0, len(pids))
- for _, pid := range pids {
- np, err := NewProcess(pid)
- if err != nil {
- return nil, err
- }
- ret = append(ret, np)
- }
- return ret, nil
-}
-
-func (p *Process) OpenFiles() ([]OpenFilesStat, error) {
- return p.OpenFilesWithContext(context.Background())
-}
-
-func (p *Process) OpenFilesWithContext(ctx context.Context) ([]OpenFilesStat, error) {
- return nil, common.ErrNotImplementedError
-}
-
-func (p *Process) Connections() ([]net.ConnectionStat, error) {
- return p.ConnectionsWithContext(context.Background())
-}
-
-func (p *Process) ConnectionsWithContext(ctx context.Context) ([]net.ConnectionStat, error) {
- return net.ConnectionsPid("all", p.Pid)
-}
-
-func (p *Process) NetIOCounters(pernic bool) ([]net.IOCountersStat, error) {
- return p.NetIOCountersWithContext(context.Background(), pernic)
-}
-
-func (p *Process) NetIOCountersWithContext(ctx context.Context, pernic bool) ([]net.IOCountersStat, error) {
- return nil, common.ErrNotImplementedError
-}
-
-func (p *Process) IsRunning() (bool, error) {
- return p.IsRunningWithContext(context.Background())
-}
-
-func (p *Process) IsRunningWithContext(ctx context.Context) (bool, error) {
- return true, common.ErrNotImplementedError
-}
-func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error) {
- return p.MemoryMapsWithContext(context.Background(), grouped)
-}
-
-func (p *Process) MemoryMapsWithContext(ctx context.Context, grouped bool) (*[]MemoryMapsStat, error) {
- var ret []MemoryMapsStat
- return &ret, common.ErrNotImplementedError
-}
-
-func Processes() ([]*Process, error) {
- return ProcessesWithContext(context.Background())
-}
-
-func ProcessesWithContext(ctx context.Context) ([]*Process, error) {
- results := []*Process{}
-
- mib := []int32{CTLKern, KernProc, KernProcAll, 0}
- buf, length, err := common.CallSyscall(mib)
- if err != nil {
- return results, err
- }
-
- // get kinfo_proc size
- k := KinfoProc{}
- procinfoLen := int(unsafe.Sizeof(k))
- count := int(length / uint64(procinfoLen))
-
- // parse buf to procs
- for i := 0; i < count; i++ {
- b := buf[i*procinfoLen : i*procinfoLen+procinfoLen]
- k, err := parseKinfoProc(b)
- if err != nil {
- continue
- }
- p, err := NewProcess(int32(k.Proc.P_pid))
- if err != nil {
- continue
- }
- results = append(results, p)
- }
-
- return results, nil
-}
-
-func parseKinfoProc(buf []byte) (KinfoProc, error) {
- var k KinfoProc
- br := bytes.NewReader(buf)
-
- err := common.Read(br, binary.LittleEndian, &k)
- if err != nil {
- return k, err
- }
-
- return k, nil
-}
-
-// Returns a proc as defined here:
-// http://unix.superglobalmegacorp.com/Net2/newsrc/sys/kinfo_proc.h.html
-func (p *Process) getKProc() (*KinfoProc, error) {
- return p.getKProcWithContext(context.Background())
-}
-
-func (p *Process) getKProcWithContext(ctx context.Context) (*KinfoProc, error) {
- mib := []int32{CTLKern, KernProc, KernProcPID, p.Pid}
- procK := KinfoProc{}
- length := uint64(unsafe.Sizeof(procK))
- buf := make([]byte, length)
- _, _, syserr := unix.Syscall6(
- unix.SYS___SYSCTL,
- uintptr(unsafe.Pointer(&mib[0])),
- uintptr(len(mib)),
- uintptr(unsafe.Pointer(&buf[0])),
- uintptr(unsafe.Pointer(&length)),
- 0,
- 0)
- if syserr != 0 {
- return nil, syserr
- }
- k, err := parseKinfoProc(buf)
- if err != nil {
- return nil, err
- }
-
- return &k, nil
-}
-
-func NewProcess(pid int32) (*Process, error) {
- p := &Process{Pid: pid}
-
- return p, nil
-}
-
-// call ps command.
-// Return value deletes Header line(you must not input wrong arg).
-// And splited by Space. Caller have responsibility to manage.
-// If passed arg pid is 0, get information from all process.
-func callPsWithContext(ctx context.Context, arg string, pid int32, threadOption bool) ([][]string, error) {
- bin, err := exec.LookPath("ps")
- if err != nil {
- return [][]string{}, err
- }
-
- var cmd []string
- if pid == 0 { // will get from all processes.
- cmd = []string{"-ax", "-o", arg}
- } else if threadOption {
- cmd = []string{"-x", "-o", arg, "-M", "-p", strconv.Itoa(int(pid))}
- } else {
- cmd = []string{"-x", "-o", arg, "-p", strconv.Itoa(int(pid))}
- }
- out, err := invoke.CommandWithContext(ctx, bin, cmd...)
- if err != nil {
- return [][]string{}, err
- }
- lines := strings.Split(string(out), "\n")
-
- var ret [][]string
- for _, l := range lines[1:] {
- var lr []string
- for _, r := range strings.Split(l, " ") {
- if r == "" {
- continue
- }
- lr = append(lr, strings.TrimSpace(r))
- }
- if len(lr) != 0 {
- ret = append(ret, lr)
- }
- }
-
- return ret, nil
-}
diff --git a/vendor/github.com/shirou/gopsutil/process/process_darwin_386.go b/vendor/github.com/shirou/gopsutil/process/process_darwin_386.go
deleted file mode 100644
index f8e9223..0000000
--- a/vendor/github.com/shirou/gopsutil/process/process_darwin_386.go
+++ /dev/null
@@ -1,234 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_darwin.go
-
-package process
-
-const (
- sizeofPtr = 0x8
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x8
- sizeofLongLong = 0x8
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int64
- _C_long_long int64
-)
-
-type Timespec struct {
- Sec int64
- Nsec int64
-}
-
-type Timeval struct {
- Sec int64
- Usec int32
- Pad_cgo_0 [4]byte
-}
-
-type Rusage struct {
- Utime Timeval
- Stime Timeval
- Maxrss int64
- Ixrss int64
- Idrss int64
- Isrss int64
- Minflt int64
- Majflt int64
- Nswap int64
- Inblock int64
- Oublock int64
- Msgsnd int64
- Msgrcv int64
- Nsignals int64
- Nvcsw int64
- Nivcsw int64
-}
-
-type Rlimit struct {
- Cur uint64
- Max uint64
-}
-
-type UGid_t uint32
-
-type KinfoProc struct {
- Proc ExternProc
- Eproc Eproc
-}
-
-type Eproc struct {
- Paddr *uint64
- Sess *Session
- Pcred Upcred
- Ucred Uucred
- Pad_cgo_0 [4]byte
- Vm Vmspace
- Ppid int32
- Pgid int32
- Jobc int16
- Pad_cgo_1 [2]byte
- Tdev int32
- Tpgid int32
- Pad_cgo_2 [4]byte
- Tsess *Session
- Wmesg [8]int8
- Xsize int32
- Xrssize int16
- Xccount int16
- Xswrss int16
- Pad_cgo_3 [2]byte
- Flag int32
- Login [12]int8
- Spare [4]int32
- Pad_cgo_4 [4]byte
-}
-
-type Proc struct{}
-
-type Session struct{}
-
-type ucred struct {
- Link _Ctype_struct___0
- Ref uint64
- Posix Posix_cred
- Label *Label
- Audit Au_session
-}
-
-type Uucred struct {
- Ref int32
- UID uint32
- Ngroups int16
- Pad_cgo_0 [2]byte
- Groups [16]uint32
-}
-
-type Upcred struct {
- Pc_lock [72]int8
- Pc_ucred *ucred
- P_ruid uint32
- P_svuid uint32
- P_rgid uint32
- P_svgid uint32
- P_refcnt int32
- Pad_cgo_0 [4]byte
-}
-
-type Vmspace struct {
- Dummy int32
- Pad_cgo_0 [4]byte
- Dummy2 *int8
- Dummy3 [5]int32
- Pad_cgo_1 [4]byte
- Dummy4 [3]*int8
-}
-
-type Sigacts struct{}
-
-type ExternProc struct {
- P_un [16]byte
- P_vmspace uint64
- P_sigacts uint64
- Pad_cgo_0 [3]byte
- P_flag int32
- P_stat int8
- P_pid int32
- P_oppid int32
- P_dupfd int32
- Pad_cgo_1 [4]byte
- User_stack uint64
- Exit_thread uint64
- P_debugger int32
- Sigwait int32
- P_estcpu uint32
- P_cpticks int32
- P_pctcpu uint32
- Pad_cgo_2 [4]byte
- P_wchan uint64
- P_wmesg uint64
- P_swtime uint32
- P_slptime uint32
- P_realtimer Itimerval
- P_rtime Timeval
- P_uticks uint64
- P_sticks uint64
- P_iticks uint64
- P_traceflag int32
- Pad_cgo_3 [4]byte
- P_tracep uint64
- P_siglist int32
- Pad_cgo_4 [4]byte
- P_textvp uint64
- P_holdcnt int32
- P_sigmask uint32
- P_sigignore uint32
- P_sigcatch uint32
- P_priority uint8
- P_usrpri uint8
- P_nice int8
- P_comm [17]int8
- Pad_cgo_5 [4]byte
- P_pgrp uint64
- P_addr uint64
- P_xstat uint16
- P_acflag uint16
- Pad_cgo_6 [4]byte
- P_ru uint64
-}
-
-type Itimerval struct {
- Interval Timeval
- Value Timeval
-}
-
-type Vnode struct{}
-
-type Pgrp struct{}
-
-type UserStruct struct{}
-
-type Au_session struct {
- Aia_p *AuditinfoAddr
- Mask AuMask
-}
-
-type Posix_cred struct {
- UID uint32
- Ruid uint32
- Svuid uint32
- Ngroups int16
- Pad_cgo_0 [2]byte
- Groups [16]uint32
- Rgid uint32
- Svgid uint32
- Gmuid uint32
- Flags int32
-}
-
-type Label struct{}
-
-type AuditinfoAddr struct {
- Auid uint32
- Mask AuMask
- Termid AuTidAddr
- Asid int32
- Flags uint64
-}
-type AuMask struct {
- Success uint32
- Failure uint32
-}
-type AuTidAddr struct {
- Port int32
- Type uint32
- Addr [4]uint32
-}
-
-type UcredQueue struct {
- Next *ucred
- Prev **ucred
-}
diff --git a/vendor/github.com/shirou/gopsutil/process/process_darwin_amd64.go b/vendor/github.com/shirou/gopsutil/process/process_darwin_amd64.go
deleted file mode 100644
index f8e9223..0000000
--- a/vendor/github.com/shirou/gopsutil/process/process_darwin_amd64.go
+++ /dev/null
@@ -1,234 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_darwin.go
-
-package process
-
-const (
- sizeofPtr = 0x8
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x8
- sizeofLongLong = 0x8
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int64
- _C_long_long int64
-)
-
-type Timespec struct {
- Sec int64
- Nsec int64
-}
-
-type Timeval struct {
- Sec int64
- Usec int32
- Pad_cgo_0 [4]byte
-}
-
-type Rusage struct {
- Utime Timeval
- Stime Timeval
- Maxrss int64
- Ixrss int64
- Idrss int64
- Isrss int64
- Minflt int64
- Majflt int64
- Nswap int64
- Inblock int64
- Oublock int64
- Msgsnd int64
- Msgrcv int64
- Nsignals int64
- Nvcsw int64
- Nivcsw int64
-}
-
-type Rlimit struct {
- Cur uint64
- Max uint64
-}
-
-type UGid_t uint32
-
-type KinfoProc struct {
- Proc ExternProc
- Eproc Eproc
-}
-
-type Eproc struct {
- Paddr *uint64
- Sess *Session
- Pcred Upcred
- Ucred Uucred
- Pad_cgo_0 [4]byte
- Vm Vmspace
- Ppid int32
- Pgid int32
- Jobc int16
- Pad_cgo_1 [2]byte
- Tdev int32
- Tpgid int32
- Pad_cgo_2 [4]byte
- Tsess *Session
- Wmesg [8]int8
- Xsize int32
- Xrssize int16
- Xccount int16
- Xswrss int16
- Pad_cgo_3 [2]byte
- Flag int32
- Login [12]int8
- Spare [4]int32
- Pad_cgo_4 [4]byte
-}
-
-type Proc struct{}
-
-type Session struct{}
-
-type ucred struct {
- Link _Ctype_struct___0
- Ref uint64
- Posix Posix_cred
- Label *Label
- Audit Au_session
-}
-
-type Uucred struct {
- Ref int32
- UID uint32
- Ngroups int16
- Pad_cgo_0 [2]byte
- Groups [16]uint32
-}
-
-type Upcred struct {
- Pc_lock [72]int8
- Pc_ucred *ucred
- P_ruid uint32
- P_svuid uint32
- P_rgid uint32
- P_svgid uint32
- P_refcnt int32
- Pad_cgo_0 [4]byte
-}
-
-type Vmspace struct {
- Dummy int32
- Pad_cgo_0 [4]byte
- Dummy2 *int8
- Dummy3 [5]int32
- Pad_cgo_1 [4]byte
- Dummy4 [3]*int8
-}
-
-type Sigacts struct{}
-
-type ExternProc struct {
- P_un [16]byte
- P_vmspace uint64
- P_sigacts uint64
- Pad_cgo_0 [3]byte
- P_flag int32
- P_stat int8
- P_pid int32
- P_oppid int32
- P_dupfd int32
- Pad_cgo_1 [4]byte
- User_stack uint64
- Exit_thread uint64
- P_debugger int32
- Sigwait int32
- P_estcpu uint32
- P_cpticks int32
- P_pctcpu uint32
- Pad_cgo_2 [4]byte
- P_wchan uint64
- P_wmesg uint64
- P_swtime uint32
- P_slptime uint32
- P_realtimer Itimerval
- P_rtime Timeval
- P_uticks uint64
- P_sticks uint64
- P_iticks uint64
- P_traceflag int32
- Pad_cgo_3 [4]byte
- P_tracep uint64
- P_siglist int32
- Pad_cgo_4 [4]byte
- P_textvp uint64
- P_holdcnt int32
- P_sigmask uint32
- P_sigignore uint32
- P_sigcatch uint32
- P_priority uint8
- P_usrpri uint8
- P_nice int8
- P_comm [17]int8
- Pad_cgo_5 [4]byte
- P_pgrp uint64
- P_addr uint64
- P_xstat uint16
- P_acflag uint16
- Pad_cgo_6 [4]byte
- P_ru uint64
-}
-
-type Itimerval struct {
- Interval Timeval
- Value Timeval
-}
-
-type Vnode struct{}
-
-type Pgrp struct{}
-
-type UserStruct struct{}
-
-type Au_session struct {
- Aia_p *AuditinfoAddr
- Mask AuMask
-}
-
-type Posix_cred struct {
- UID uint32
- Ruid uint32
- Svuid uint32
- Ngroups int16
- Pad_cgo_0 [2]byte
- Groups [16]uint32
- Rgid uint32
- Svgid uint32
- Gmuid uint32
- Flags int32
-}
-
-type Label struct{}
-
-type AuditinfoAddr struct {
- Auid uint32
- Mask AuMask
- Termid AuTidAddr
- Asid int32
- Flags uint64
-}
-type AuMask struct {
- Success uint32
- Failure uint32
-}
-type AuTidAddr struct {
- Port int32
- Type uint32
- Addr [4]uint32
-}
-
-type UcredQueue struct {
- Next *ucred
- Prev **ucred
-}
diff --git a/vendor/github.com/shirou/gopsutil/process/process_fallback.go b/vendor/github.com/shirou/gopsutil/process/process_fallback.go
deleted file mode 100644
index ca8b72f..0000000
--- a/vendor/github.com/shirou/gopsutil/process/process_fallback.go
+++ /dev/null
@@ -1,312 +0,0 @@
-// +build !darwin,!linux,!freebsd,!openbsd,!windows
-
-package process
-
-import (
- "context"
- "syscall"
-
- "github.com/shirou/gopsutil/cpu"
- "github.com/shirou/gopsutil/internal/common"
- "github.com/shirou/gopsutil/net"
-)
-
-type MemoryMapsStat struct {
- Path string `json:"path"`
- Rss uint64 `json:"rss"`
- Size uint64 `json:"size"`
- Pss uint64 `json:"pss"`
- SharedClean uint64 `json:"sharedClean"`
- SharedDirty uint64 `json:"sharedDirty"`
- PrivateClean uint64 `json:"privateClean"`
- PrivateDirty uint64 `json:"privateDirty"`
- Referenced uint64 `json:"referenced"`
- Anonymous uint64 `json:"anonymous"`
- Swap uint64 `json:"swap"`
-}
-
-type MemoryInfoExStat struct {
-}
-
-func Pids() ([]int32, error) {
- return PidsWithContext(context.Background())
-}
-
-func PidsWithContext(ctx context.Context) ([]int32, error) {
- return []int32{}, common.ErrNotImplementedError
-}
-
-func Processes() ([]*Process, error) {
- return nil, common.ErrNotImplementedError
-}
-
-func ProcessesWithContext(ctx context.Context) ([]*Process, error) {
- return nil, common.ErrNotImplementedError
-}
-
-func NewProcess(pid int32) (*Process, error) {
- return nil, common.ErrNotImplementedError
-}
-
-func (p *Process) Ppid() (int32, error) {
- return p.PpidWithContext(context.Background())
-}
-
-func (p *Process) PpidWithContext(ctx context.Context) (int32, error) {
- return 0, common.ErrNotImplementedError
-}
-func (p *Process) Name() (string, error) {
- return p.NameWithContext(context.Background())
-}
-
-func (p *Process) NameWithContext(ctx context.Context) (string, error) {
- return "", common.ErrNotImplementedError
-}
-func (p *Process) Tgid() (int32, error) {
- return 0, common.ErrNotImplementedError
-}
-func (p *Process) Exe() (string, error) {
- return p.ExeWithContext(context.Background())
-}
-
-func (p *Process) ExeWithContext(ctx context.Context) (string, error) {
- return "", common.ErrNotImplementedError
-}
-func (p *Process) Cmdline() (string, error) {
- return p.CmdlineWithContext(context.Background())
-}
-
-func (p *Process) CmdlineWithContext(ctx context.Context) (string, error) {
- return "", common.ErrNotImplementedError
-}
-func (p *Process) CmdlineSlice() ([]string, error) {
- return p.CmdlineSliceWithContext(context.Background())
-}
-
-func (p *Process) CmdlineSliceWithContext(ctx context.Context) ([]string, error) {
- return []string{}, common.ErrNotImplementedError
-}
-func (p *Process) CreateTime() (int64, error) {
- return p.CreateTimeWithContext(context.Background())
-}
-
-func (p *Process) CreateTimeWithContext(ctx context.Context) (int64, error) {
- return 0, common.ErrNotImplementedError
-}
-func (p *Process) Cwd() (string, error) {
- return p.CwdWithContext(context.Background())
-}
-
-func (p *Process) CwdWithContext(ctx context.Context) (string, error) {
- return "", common.ErrNotImplementedError
-}
-func (p *Process) Parent() (*Process, error) {
- return p.ParentWithContext(context.Background())
-}
-
-func (p *Process) ParentWithContext(ctx context.Context) (*Process, error) {
- return nil, common.ErrNotImplementedError
-}
-func (p *Process) Status() (string, error) {
- return p.StatusWithContext(context.Background())
-}
-
-func (p *Process) StatusWithContext(ctx context.Context) (string, error) {
- return "", common.ErrNotImplementedError
-}
-func (p *Process) Uids() ([]int32, error) {
- return p.UidsWithContext(context.Background())
-}
-
-func (p *Process) UidsWithContext(ctx context.Context) ([]int32, error) {
- return []int32{}, common.ErrNotImplementedError
-}
-func (p *Process) Gids() ([]int32, error) {
- return p.GidsWithContext(context.Background())
-}
-
-func (p *Process) GidsWithContext(ctx context.Context) ([]int32, error) {
- return []int32{}, common.ErrNotImplementedError
-}
-func (p *Process) Terminal() (string, error) {
- return p.TerminalWithContext(context.Background())
-}
-
-func (p *Process) TerminalWithContext(ctx context.Context) (string, error) {
- return "", common.ErrNotImplementedError
-}
-func (p *Process) Nice() (int32, error) {
- return p.NiceWithContext(context.Background())
-}
-
-func (p *Process) NiceWithContext(ctx context.Context) (int32, error) {
- return 0, common.ErrNotImplementedError
-}
-func (p *Process) IOnice() (int32, error) {
- return p.IOniceWithContext(context.Background())
-}
-
-func (p *Process) IOniceWithContext(ctx context.Context) (int32, error) {
- return 0, common.ErrNotImplementedError
-}
-func (p *Process) Rlimit() ([]RlimitStat, error) {
- return p.RlimitWithContext(context.Background())
-}
-
-func (p *Process) RlimitWithContext(ctx context.Context) ([]RlimitStat, error) {
- return nil, common.ErrNotImplementedError
-}
-func (p *Process) RlimitUsage(gatherUsed bool) ([]RlimitStat, error) {
- return p.RlimitUsageWithContext(context.Background(), gatherUsed)
-}
-
-func (p *Process) RlimitUsageWithContext(ctx context.Context, gatherUsed bool) ([]RlimitStat, error) {
- return nil, common.ErrNotImplementedError
-}
-func (p *Process) IOCounters() (*IOCountersStat, error) {
- return p.IOCountersWithContext(context.Background())
-}
-
-func (p *Process) IOCountersWithContext(ctx context.Context) (*IOCountersStat, error) {
- return nil, common.ErrNotImplementedError
-}
-func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error) {
- return p.NumCtxSwitchesWithContext(context.Background())
-}
-
-func (p *Process) NumCtxSwitchesWithContext(ctx context.Context) (*NumCtxSwitchesStat, error) {
- return nil, common.ErrNotImplementedError
-}
-func (p *Process) NumFDs() (int32, error) {
- return p.NumFDsWithContext(context.Background())
-}
-
-func (p *Process) NumFDsWithContext(ctx context.Context) (int32, error) {
- return 0, common.ErrNotImplementedError
-}
-func (p *Process) NumThreads() (int32, error) {
- return p.NumThreadsWithContext(context.Background())
-}
-
-func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) {
- return 0, common.ErrNotImplementedError
-}
-func (p *Process) Threads() (map[int32]*cpu.TimesStat, error) {
- return p.ThreadsWithContext(context.Background())
-}
-
-func (p *Process) ThreadsWithContext(ctx context.Context) (map[int32]*cpu.TimesStat, error) {
- return nil, common.ErrNotImplementedError
-}
-func (p *Process) Times() (*cpu.TimesStat, error) {
- return p.TimesWithContext(context.Background())
-}
-
-func (p *Process) TimesWithContext(ctx context.Context) (*cpu.TimesStat, error) {
- return nil, common.ErrNotImplementedError
-}
-func (p *Process) CPUAffinity() ([]int32, error) {
- return p.CPUAffinityWithContext(context.Background())
-}
-
-func (p *Process) CPUAffinityWithContext(ctx context.Context) ([]int32, error) {
- return nil, common.ErrNotImplementedError
-}
-func (p *Process) MemoryInfo() (*MemoryInfoStat, error) {
- return p.MemoryInfoWithContext(context.Background())
-}
-
-func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, error) {
- return nil, common.ErrNotImplementedError
-}
-func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error) {
- return p.MemoryInfoExWithContext(context.Background())
-}
-
-func (p *Process) MemoryInfoExWithContext(ctx context.Context) (*MemoryInfoExStat, error) {
- return nil, common.ErrNotImplementedError
-}
-func (p *Process) Children() ([]*Process, error) {
- return p.ChildrenWithContext(context.Background())
-}
-
-func (p *Process) ChildrenWithContext(ctx context.Context) ([]*Process, error) {
- return nil, common.ErrNotImplementedError
-}
-func (p *Process) OpenFiles() ([]OpenFilesStat, error) {
- return p.OpenFilesWithContext(context.Background())
-}
-
-func (p *Process) OpenFilesWithContext(ctx context.Context) ([]OpenFilesStat, error) {
- return []OpenFilesStat{}, common.ErrNotImplementedError
-}
-func (p *Process) Connections() ([]net.ConnectionStat, error) {
- return p.ConnectionsWithContext(context.Background())
-}
-
-func (p *Process) ConnectionsWithContext(ctx context.Context) ([]net.ConnectionStat, error) {
- return []net.ConnectionStat{}, common.ErrNotImplementedError
-}
-func (p *Process) NetIOCounters(pernic bool) ([]net.IOCountersStat, error) {
- return p.NetIOCountersWithContext(context.Background(), pernic)
-}
-
-func (p *Process) NetIOCountersWithContext(ctx context.Context, pernic bool) ([]net.IOCountersStat, error) {
- return []net.IOCountersStat{}, common.ErrNotImplementedError
-}
-func (p *Process) IsRunning() (bool, error) {
- return p.IsRunningWithContext(context.Background())
-}
-
-func (p *Process) IsRunningWithContext(ctx context.Context) (bool, error) {
- return true, common.ErrNotImplementedError
-}
-func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error) {
- return p.MemoryMapsWithContext(context.Background(), grouped)
-}
-
-func (p *Process) MemoryMapsWithContext(ctx context.Context, grouped bool) (*[]MemoryMapsStat, error) {
- return nil, common.ErrNotImplementedError
-}
-func (p *Process) SendSignal(sig syscall.Signal) error {
- return p.SendSignalWithContext(context.Background(), sig)
-}
-
-func (p *Process) SendSignalWithContext(ctx context.Context, sig syscall.Signal) error {
- return common.ErrNotImplementedError
-}
-func (p *Process) Suspend() error {
- return p.SuspendWithContext(context.Background())
-}
-
-func (p *Process) SuspendWithContext(ctx context.Context) error {
- return common.ErrNotImplementedError
-}
-func (p *Process) Resume() error {
- return p.ResumeWithContext(context.Background())
-}
-
-func (p *Process) ResumeWithContext(ctx context.Context) error {
- return common.ErrNotImplementedError
-}
-func (p *Process) Terminate() error {
- return p.TerminateWithContext(context.Background())
-}
-
-func (p *Process) TerminateWithContext(ctx context.Context) error {
- return common.ErrNotImplementedError
-}
-func (p *Process) Kill() error {
- return p.KillWithContext(context.Background())
-}
-
-func (p *Process) KillWithContext(ctx context.Context) error {
- return common.ErrNotImplementedError
-}
-func (p *Process) Username() (string, error) {
- return p.UsernameWithContext(context.Background())
-}
-
-func (p *Process) UsernameWithContext(ctx context.Context) (string, error) {
- return "", common.ErrNotImplementedError
-}
diff --git a/vendor/github.com/shirou/gopsutil/process/process_freebsd.go b/vendor/github.com/shirou/gopsutil/process/process_freebsd.go
deleted file mode 100644
index af2b3b1..0000000
--- a/vendor/github.com/shirou/gopsutil/process/process_freebsd.go
+++ /dev/null
@@ -1,480 +0,0 @@
-// +build freebsd
-
-package process
-
-import (
- "bytes"
- "context"
- "encoding/binary"
- "strings"
-
- cpu "github.com/shirou/gopsutil/cpu"
- "github.com/shirou/gopsutil/internal/common"
- net "github.com/shirou/gopsutil/net"
- "golang.org/x/sys/unix"
-)
-
-// MemoryInfoExStat is different between OSes
-type MemoryInfoExStat struct {
-}
-
-type MemoryMapsStat struct {
-}
-
-func Pids() ([]int32, error) {
- return PidsWithContext(context.Background())
-}
-
-func PidsWithContext(ctx context.Context) ([]int32, error) {
- var ret []int32
- procs, err := Processes()
- if err != nil {
- return ret, nil
- }
-
- for _, p := range procs {
- ret = append(ret, p.Pid)
- }
-
- return ret, nil
-}
-
-func (p *Process) Ppid() (int32, error) {
- return p.PpidWithContext(context.Background())
-}
-
-func (p *Process) PpidWithContext(ctx context.Context) (int32, error) {
- k, err := p.getKProc()
- if err != nil {
- return 0, err
- }
-
- return k.Ppid, nil
-}
-func (p *Process) Name() (string, error) {
- return p.NameWithContext(context.Background())
-}
-
-func (p *Process) NameWithContext(ctx context.Context) (string, error) {
- k, err := p.getKProc()
- if err != nil {
- return "", err
- }
-
- return common.IntToString(k.Comm[:]), nil
-}
-func (p *Process) Tgid() (int32, error) {
- return 0, common.ErrNotImplementedError
-}
-func (p *Process) Exe() (string, error) {
- return p.ExeWithContext(context.Background())
-}
-
-func (p *Process) ExeWithContext(ctx context.Context) (string, error) {
- return "", common.ErrNotImplementedError
-}
-
-func (p *Process) Cmdline() (string, error) {
- return p.CmdlineWithContext(context.Background())
-}
-
-func (p *Process) CmdlineWithContext(ctx context.Context) (string, error) {
- mib := []int32{CTLKern, KernProc, KernProcArgs, p.Pid}
- buf, _, err := common.CallSyscall(mib)
- if err != nil {
- return "", err
- }
- ret := strings.FieldsFunc(string(buf), func(r rune) bool {
- if r == '\u0000' {
- return true
- }
- return false
- })
-
- return strings.Join(ret, " "), nil
-}
-
-func (p *Process) CmdlineSlice() ([]string, error) {
- return p.CmdlineSliceWithContext(context.Background())
-}
-
-func (p *Process) CmdlineSliceWithContext(ctx context.Context) ([]string, error) {
- mib := []int32{CTLKern, KernProc, KernProcArgs, p.Pid}
- buf, _, err := common.CallSyscall(mib)
- if err != nil {
- return nil, err
- }
- if len(buf) == 0 {
- return nil, nil
- }
- if buf[len(buf)-1] == 0 {
- buf = buf[:len(buf)-1]
- }
- parts := bytes.Split(buf, []byte{0})
- var strParts []string
- for _, p := range parts {
- strParts = append(strParts, string(p))
- }
-
- return strParts, nil
-}
-func (p *Process) CreateTime() (int64, error) {
- return p.CreateTimeWithContext(context.Background())
-}
-
-func (p *Process) CreateTimeWithContext(ctx context.Context) (int64, error) {
- return 0, common.ErrNotImplementedError
-}
-func (p *Process) Cwd() (string, error) {
- return p.CwdWithContext(context.Background())
-}
-
-func (p *Process) CwdWithContext(ctx context.Context) (string, error) {
- return "", common.ErrNotImplementedError
-}
-func (p *Process) Parent() (*Process, error) {
- return p.ParentWithContext(context.Background())
-}
-
-func (p *Process) ParentWithContext(ctx context.Context) (*Process, error) {
- return p, common.ErrNotImplementedError
-}
-func (p *Process) Status() (string, error) {
- return p.StatusWithContext(context.Background())
-}
-
-func (p *Process) StatusWithContext(ctx context.Context) (string, error) {
- k, err := p.getKProc()
- if err != nil {
- return "", err
- }
- var s string
- switch k.Stat {
- case SIDL:
- s = "I"
- case SRUN:
- s = "R"
- case SSLEEP:
- s = "S"
- case SSTOP:
- s = "T"
- case SZOMB:
- s = "Z"
- case SWAIT:
- s = "W"
- case SLOCK:
- s = "L"
- }
-
- return s, nil
-}
-func (p *Process) Uids() ([]int32, error) {
- return p.UidsWithContext(context.Background())
-}
-
-func (p *Process) UidsWithContext(ctx context.Context) ([]int32, error) {
- k, err := p.getKProc()
- if err != nil {
- return nil, err
- }
-
- uids := make([]int32, 0, 3)
-
- uids = append(uids, int32(k.Ruid), int32(k.Uid), int32(k.Svuid))
-
- return uids, nil
-}
-func (p *Process) Gids() ([]int32, error) {
- return p.GidsWithContext(context.Background())
-}
-
-func (p *Process) GidsWithContext(ctx context.Context) ([]int32, error) {
- k, err := p.getKProc()
- if err != nil {
- return nil, err
- }
-
- gids := make([]int32, 0, 3)
- gids = append(gids, int32(k.Rgid), int32(k.Ngroups), int32(k.Svgid))
-
- return gids, nil
-}
-func (p *Process) Terminal() (string, error) {
- return p.TerminalWithContext(context.Background())
-}
-
-func (p *Process) TerminalWithContext(ctx context.Context) (string, error) {
- k, err := p.getKProc()
- if err != nil {
- return "", err
- }
-
- ttyNr := uint64(k.Tdev)
-
- termmap, err := getTerminalMap()
- if err != nil {
- return "", err
- }
-
- return termmap[ttyNr], nil
-}
-func (p *Process) Nice() (int32, error) {
- return p.NiceWithContext(context.Background())
-}
-
-func (p *Process) NiceWithContext(ctx context.Context) (int32, error) {
- k, err := p.getKProc()
- if err != nil {
- return 0, err
- }
- return int32(k.Nice), nil
-}
-func (p *Process) IOnice() (int32, error) {
- return p.IOniceWithContext(context.Background())
-}
-
-func (p *Process) IOniceWithContext(ctx context.Context) (int32, error) {
- return 0, common.ErrNotImplementedError
-}
-func (p *Process) Rlimit() ([]RlimitStat, error) {
- return p.RlimitWithContext(context.Background())
-}
-
-func (p *Process) RlimitWithContext(ctx context.Context) ([]RlimitStat, error) {
- var rlimit []RlimitStat
- return rlimit, common.ErrNotImplementedError
-}
-func (p *Process) RlimitUsage(gatherUsed bool) ([]RlimitStat, error) {
- return p.RlimitUsageWithContext(context.Background(), gatherUsed)
-}
-
-func (p *Process) RlimitUsageWithContext(ctx context.Context, gatherUsed bool) ([]RlimitStat, error) {
- var rlimit []RlimitStat
- return rlimit, common.ErrNotImplementedError
-}
-func (p *Process) IOCounters() (*IOCountersStat, error) {
- return p.IOCountersWithContext(context.Background())
-}
-
-func (p *Process) IOCountersWithContext(ctx context.Context) (*IOCountersStat, error) {
- k, err := p.getKProc()
- if err != nil {
- return nil, err
- }
- return &IOCountersStat{
- ReadCount: uint64(k.Rusage.Inblock),
- WriteCount: uint64(k.Rusage.Oublock),
- }, nil
-}
-func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error) {
- return p.NumCtxSwitchesWithContext(context.Background())
-}
-
-func (p *Process) NumCtxSwitchesWithContext(ctx context.Context) (*NumCtxSwitchesStat, error) {
- return nil, common.ErrNotImplementedError
-}
-func (p *Process) NumFDs() (int32, error) {
- return p.NumFDsWithContext(context.Background())
-}
-
-func (p *Process) NumFDsWithContext(ctx context.Context) (int32, error) {
- return 0, common.ErrNotImplementedError
-}
-func (p *Process) NumThreads() (int32, error) {
- return p.NumThreadsWithContext(context.Background())
-}
-
-func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) {
- k, err := p.getKProc()
- if err != nil {
- return 0, err
- }
-
- return k.Numthreads, nil
-}
-func (p *Process) Threads() (map[int32]*cpu.TimesStat, error) {
- return p.ThreadsWithContext(context.Background())
-}
-
-func (p *Process) ThreadsWithContext(ctx context.Context) (map[int32]*cpu.TimesStat, error) {
- ret := make(map[int32]*cpu.TimesStat)
- return ret, common.ErrNotImplementedError
-}
-func (p *Process) Times() (*cpu.TimesStat, error) {
- return p.TimesWithContext(context.Background())
-}
-
-func (p *Process) TimesWithContext(ctx context.Context) (*cpu.TimesStat, error) {
- k, err := p.getKProc()
- if err != nil {
- return nil, err
- }
- return &cpu.TimesStat{
- CPU: "cpu",
- User: float64(k.Rusage.Utime.Sec) + float64(k.Rusage.Utime.Usec)/1000000,
- System: float64(k.Rusage.Stime.Sec) + float64(k.Rusage.Stime.Usec)/1000000,
- }, nil
-}
-func (p *Process) CPUAffinity() ([]int32, error) {
- return p.CPUAffinityWithContext(context.Background())
-}
-
-func (p *Process) CPUAffinityWithContext(ctx context.Context) ([]int32, error) {
- return nil, common.ErrNotImplementedError
-}
-func (p *Process) MemoryInfo() (*MemoryInfoStat, error) {
- return p.MemoryInfoWithContext(context.Background())
-}
-
-func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, error) {
- k, err := p.getKProc()
- if err != nil {
- return nil, err
- }
- v, err := unix.Sysctl("vm.stats.vm.v_page_size")
- if err != nil {
- return nil, err
- }
- pageSize := common.LittleEndian.Uint16([]byte(v))
-
- return &MemoryInfoStat{
- RSS: uint64(k.Rssize) * uint64(pageSize),
- VMS: uint64(k.Size),
- }, nil
-}
-func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error) {
- return p.MemoryInfoExWithContext(context.Background())
-}
-
-func (p *Process) MemoryInfoExWithContext(ctx context.Context) (*MemoryInfoExStat, error) {
- return nil, common.ErrNotImplementedError
-}
-
-func (p *Process) Children() ([]*Process, error) {
- return p.ChildrenWithContext(context.Background())
-}
-
-func (p *Process) ChildrenWithContext(ctx context.Context) ([]*Process, error) {
- pids, err := common.CallPgrepWithContext(ctx, invoke, p.Pid)
- if err != nil {
- return nil, err
- }
- ret := make([]*Process, 0, len(pids))
- for _, pid := range pids {
- np, err := NewProcess(pid)
- if err != nil {
- return nil, err
- }
- ret = append(ret, np)
- }
- return ret, nil
-}
-
-func (p *Process) OpenFiles() ([]OpenFilesStat, error) {
- return p.OpenFilesWithContext(context.Background())
-}
-
-func (p *Process) OpenFilesWithContext(ctx context.Context) ([]OpenFilesStat, error) {
- return nil, common.ErrNotImplementedError
-}
-
-func (p *Process) Connections() ([]net.ConnectionStat, error) {
- return p.ConnectionsWithContext(context.Background())
-}
-
-func (p *Process) ConnectionsWithContext(ctx context.Context) ([]net.ConnectionStat, error) {
- return nil, common.ErrNotImplementedError
-}
-
-func (p *Process) NetIOCounters(pernic bool) ([]net.IOCountersStat, error) {
- return p.NetIOCountersWithContext(context.Background(), pernic)
-}
-
-func (p *Process) NetIOCountersWithContext(ctx context.Context, pernic bool) ([]net.IOCountersStat, error) {
- return nil, common.ErrNotImplementedError
-}
-
-func (p *Process) IsRunning() (bool, error) {
- return p.IsRunningWithContext(context.Background())
-}
-
-func (p *Process) IsRunningWithContext(ctx context.Context) (bool, error) {
- return true, common.ErrNotImplementedError
-}
-func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error) {
- return p.MemoryMapsWithContext(context.Background(), grouped)
-}
-
-func (p *Process) MemoryMapsWithContext(ctx context.Context, grouped bool) (*[]MemoryMapsStat, error) {
- var ret []MemoryMapsStat
- return &ret, common.ErrNotImplementedError
-}
-
-func Processes() ([]*Process, error) {
- return ProcessesWithContext(context.Background())
-}
-
-func ProcessesWithContext(ctx context.Context) ([]*Process, error) {
- results := []*Process{}
-
- mib := []int32{CTLKern, KernProc, KernProcProc, 0}
- buf, length, err := common.CallSyscall(mib)
- if err != nil {
- return results, err
- }
-
- // get kinfo_proc size
- count := int(length / uint64(sizeOfKinfoProc))
-
- // parse buf to procs
- for i := 0; i < count; i++ {
- b := buf[i*sizeOfKinfoProc : (i+1)*sizeOfKinfoProc]
- k, err := parseKinfoProc(b)
- if err != nil {
- continue
- }
- p, err := NewProcess(int32(k.Pid))
- if err != nil {
- continue
- }
-
- results = append(results, p)
- }
-
- return results, nil
-}
-
-func parseKinfoProc(buf []byte) (KinfoProc, error) {
- var k KinfoProc
- br := bytes.NewReader(buf)
- err := common.Read(br, binary.LittleEndian, &k)
- return k, err
-}
-
-func (p *Process) getKProc() (*KinfoProc, error) {
- return p.getKProcWithContext(context.Background())
-}
-
-func (p *Process) getKProcWithContext(ctx context.Context) (*KinfoProc, error) {
- mib := []int32{CTLKern, KernProc, KernProcPID, p.Pid}
-
- buf, length, err := common.CallSyscall(mib)
- if err != nil {
- return nil, err
- }
- if length != sizeOfKinfoProc {
- return nil, err
- }
-
- k, err := parseKinfoProc(buf)
- if err != nil {
- return nil, err
- }
- return &k, nil
-}
-
-func NewProcess(pid int32) (*Process, error) {
- p := &Process{Pid: pid}
-
- return p, nil
-}
diff --git a/vendor/github.com/shirou/gopsutil/process/process_freebsd_386.go b/vendor/github.com/shirou/gopsutil/process/process_freebsd_386.go
deleted file mode 100644
index 08ab333..0000000
--- a/vendor/github.com/shirou/gopsutil/process/process_freebsd_386.go
+++ /dev/null
@@ -1,192 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_freebsd.go
-
-package process
-
-const (
- CTLKern = 1
- KernProc = 14
- KernProcPID = 1
- KernProcProc = 8
- KernProcPathname = 12
- KernProcArgs = 7
-)
-
-const (
- sizeofPtr = 0x4
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x4
- sizeofLongLong = 0x8
-)
-
-const (
- sizeOfKinfoVmentry = 0x488
- sizeOfKinfoProc = 0x300
-)
-
-const (
- SIDL = 1
- SRUN = 2
- SSLEEP = 3
- SSTOP = 4
- SZOMB = 5
- SWAIT = 6
- SLOCK = 7
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int32
- _C_long_long int64
-)
-
-type Timespec struct {
- Sec int32
- Nsec int32
-}
-
-type Timeval struct {
- Sec int32
- Usec int32
-}
-
-type Rusage struct {
- Utime Timeval
- Stime Timeval
- Maxrss int32
- Ixrss int32
- Idrss int32
- Isrss int32
- Minflt int32
- Majflt int32
- Nswap int32
- Inblock int32
- Oublock int32
- Msgsnd int32
- Msgrcv int32
- Nsignals int32
- Nvcsw int32
- Nivcsw int32
-}
-
-type Rlimit struct {
- Cur int64
- Max int64
-}
-
-type KinfoProc struct {
- Structsize int32
- Layout int32
- Args int32 /* pargs */
- Paddr int32 /* proc */
- Addr int32 /* user */
- Tracep int32 /* vnode */
- Textvp int32 /* vnode */
- Fd int32 /* filedesc */
- Vmspace int32 /* vmspace */
- Wchan int32
- Pid int32
- Ppid int32
- Pgid int32
- Tpgid int32
- Sid int32
- Tsid int32
- Jobc int16
- Spare_short1 int16
- Tdev uint32
- Siglist [16]byte /* sigset */
- Sigmask [16]byte /* sigset */
- Sigignore [16]byte /* sigset */
- Sigcatch [16]byte /* sigset */
- Uid uint32
- Ruid uint32
- Svuid uint32
- Rgid uint32
- Svgid uint32
- Ngroups int16
- Spare_short2 int16
- Groups [16]uint32
- Size uint32
- Rssize int32
- Swrss int32
- Tsize int32
- Dsize int32
- Ssize int32
- Xstat uint16
- Acflag uint16
- Pctcpu uint32
- Estcpu uint32
- Slptime uint32
- Swtime uint32
- Cow uint32
- Runtime uint64
- Start Timeval
- Childtime Timeval
- Flag int32
- Kiflag int32
- Traceflag int32
- Stat int8
- Nice int8
- Lock int8
- Rqindex int8
- Oncpu uint8
- Lastcpu uint8
- Tdname [17]int8
- Wmesg [9]int8
- Login [18]int8
- Lockname [9]int8
- Comm [20]int8
- Emul [17]int8
- Loginclass [18]int8
- Sparestrings [50]int8
- Spareints [7]int32
- Flag2 int32
- Fibnum int32
- Cr_flags uint32
- Jid int32
- Numthreads int32
- Tid int32
- Pri Priority
- Rusage Rusage
- Rusage_ch Rusage
- Pcb int32 /* pcb */
- Kstack int32
- Udata int32
- Tdaddr int32 /* thread */
- Spareptrs [6]int32
- Sparelongs [12]int32
- Sflag int32
- Tdflags int32
-}
-
-type Priority struct {
- Class uint8
- Level uint8
- Native uint8
- User uint8
-}
-
-type KinfoVmentry struct {
- Structsize int32
- Type int32
- Start uint64
- End uint64
- Offset uint64
- Vn_fileid uint64
- Vn_fsid uint32
- Flags int32
- Resident int32
- Private_resident int32
- Protection int32
- Ref_count int32
- Shadow_count int32
- Vn_type int32
- Vn_size uint64
- Vn_rdev uint32
- Vn_mode uint16
- Status uint16
- X_kve_ispare [12]int32
- Path [1024]int8
-}
diff --git a/vendor/github.com/shirou/gopsutil/process/process_freebsd_amd64.go b/vendor/github.com/shirou/gopsutil/process/process_freebsd_amd64.go
deleted file mode 100644
index 560e627..0000000
--- a/vendor/github.com/shirou/gopsutil/process/process_freebsd_amd64.go
+++ /dev/null
@@ -1,192 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_freebsd.go
-
-package process
-
-const (
- CTLKern = 1
- KernProc = 14
- KernProcPID = 1
- KernProcProc = 8
- KernProcPathname = 12
- KernProcArgs = 7
-)
-
-const (
- sizeofPtr = 0x8
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x8
- sizeofLongLong = 0x8
-)
-
-const (
- sizeOfKinfoVmentry = 0x488
- sizeOfKinfoProc = 0x440
-)
-
-const (
- SIDL = 1
- SRUN = 2
- SSLEEP = 3
- SSTOP = 4
- SZOMB = 5
- SWAIT = 6
- SLOCK = 7
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int64
- _C_long_long int64
-)
-
-type Timespec struct {
- Sec int64
- Nsec int64
-}
-
-type Timeval struct {
- Sec int64
- Usec int64
-}
-
-type Rusage struct {
- Utime Timeval
- Stime Timeval
- Maxrss int64
- Ixrss int64
- Idrss int64
- Isrss int64
- Minflt int64
- Majflt int64
- Nswap int64
- Inblock int64
- Oublock int64
- Msgsnd int64
- Msgrcv int64
- Nsignals int64
- Nvcsw int64
- Nivcsw int64
-}
-
-type Rlimit struct {
- Cur int64
- Max int64
-}
-
-type KinfoProc struct {
- Structsize int32
- Layout int32
- Args int64 /* pargs */
- Paddr int64 /* proc */
- Addr int64 /* user */
- Tracep int64 /* vnode */
- Textvp int64 /* vnode */
- Fd int64 /* filedesc */
- Vmspace int64 /* vmspace */
- Wchan int64
- Pid int32
- Ppid int32
- Pgid int32
- Tpgid int32
- Sid int32
- Tsid int32
- Jobc int16
- Spare_short1 int16
- Tdev uint32
- Siglist [16]byte /* sigset */
- Sigmask [16]byte /* sigset */
- Sigignore [16]byte /* sigset */
- Sigcatch [16]byte /* sigset */
- Uid uint32
- Ruid uint32
- Svuid uint32
- Rgid uint32
- Svgid uint32
- Ngroups int16
- Spare_short2 int16
- Groups [16]uint32
- Size uint64
- Rssize int64
- Swrss int64
- Tsize int64
- Dsize int64
- Ssize int64
- Xstat uint16
- Acflag uint16
- Pctcpu uint32
- Estcpu uint32
- Slptime uint32
- Swtime uint32
- Cow uint32
- Runtime uint64
- Start Timeval
- Childtime Timeval
- Flag int64
- Kiflag int64
- Traceflag int32
- Stat int8
- Nice int8
- Lock int8
- Rqindex int8
- Oncpu uint8
- Lastcpu uint8
- Tdname [17]int8
- Wmesg [9]int8
- Login [18]int8
- Lockname [9]int8
- Comm [20]int8
- Emul [17]int8
- Loginclass [18]int8
- Sparestrings [50]int8
- Spareints [7]int32
- Flag2 int32
- Fibnum int32
- Cr_flags uint32
- Jid int32
- Numthreads int32
- Tid int32
- Pri Priority
- Rusage Rusage
- Rusage_ch Rusage
- Pcb int64 /* pcb */
- Kstack int64
- Udata int64
- Tdaddr int64 /* thread */
- Spareptrs [6]int64
- Sparelongs [12]int64
- Sflag int64
- Tdflags int64
-}
-
-type Priority struct {
- Class uint8
- Level uint8
- Native uint8
- User uint8
-}
-
-type KinfoVmentry struct {
- Structsize int32
- Type int32
- Start uint64
- End uint64
- Offset uint64
- Vn_fileid uint64
- Vn_fsid uint32
- Flags int32
- Resident int32
- Private_resident int32
- Protection int32
- Ref_count int32
- Shadow_count int32
- Vn_type int32
- Vn_size uint64
- Vn_rdev uint32
- Vn_mode uint16
- Status uint16
- X_kve_ispare [12]int32
- Path [1024]int8
-}
diff --git a/vendor/github.com/shirou/gopsutil/process/process_freebsd_arm.go b/vendor/github.com/shirou/gopsutil/process/process_freebsd_arm.go
deleted file mode 100644
index 81ae0b9..0000000
--- a/vendor/github.com/shirou/gopsutil/process/process_freebsd_arm.go
+++ /dev/null
@@ -1,192 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_freebsd.go
-
-package process
-
-const (
- CTLKern = 1
- KernProc = 14
- KernProcPID = 1
- KernProcProc = 8
- KernProcPathname = 12
- KernProcArgs = 7
-)
-
-const (
- sizeofPtr = 0x4
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x4
- sizeofLongLong = 0x8
-)
-
-const (
- sizeOfKinfoVmentry = 0x488
- sizeOfKinfoProc = 0x440
-)
-
-const (
- SIDL = 1
- SRUN = 2
- SSLEEP = 3
- SSTOP = 4
- SZOMB = 5
- SWAIT = 6
- SLOCK = 7
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int32
- _C_long_long int64
-)
-
-type Timespec struct {
- Sec int64
- Nsec int64
-}
-
-type Timeval struct {
- Sec int64
- Usec int64
-}
-
-type Rusage struct {
- Utime Timeval
- Stime Timeval
- Maxrss int32
- Ixrss int32
- Idrss int32
- Isrss int32
- Minflt int32
- Majflt int32
- Nswap int32
- Inblock int32
- Oublock int32
- Msgsnd int32
- Msgrcv int32
- Nsignals int32
- Nvcsw int32
- Nivcsw int32
-}
-
-type Rlimit struct {
- Cur int32
- Max int32
-}
-
-type KinfoProc struct {
- Structsize int32
- Layout int32
- Args int32 /* pargs */
- Paddr int32 /* proc */
- Addr int32 /* user */
- Tracep int32 /* vnode */
- Textvp int32 /* vnode */
- Fd int32 /* filedesc */
- Vmspace int32 /* vmspace */
- Wchan int32
- Pid int32
- Ppid int32
- Pgid int32
- Tpgid int32
- Sid int32
- Tsid int32
- Jobc int16
- Spare_short1 int16
- Tdev uint32
- Siglist [16]byte /* sigset */
- Sigmask [16]byte /* sigset */
- Sigignore [16]byte /* sigset */
- Sigcatch [16]byte /* sigset */
- Uid uint32
- Ruid uint32
- Svuid uint32
- Rgid uint32
- Svgid uint32
- Ngroups int16
- Spare_short2 int16
- Groups [16]uint32
- Size uint32
- Rssize int32
- Swrss int32
- Tsize int32
- Dsize int32
- Ssize int32
- Xstat uint16
- Acflag uint16
- Pctcpu uint32
- Estcpu uint32
- Slptime uint32
- Swtime uint32
- Cow uint32
- Runtime uint64
- Start Timeval
- Childtime Timeval
- Flag int32
- Kiflag int32
- Traceflag int32
- Stat int8
- Nice int8
- Lock int8
- Rqindex int8
- Oncpu uint8
- Lastcpu uint8
- Tdname [17]int8
- Wmesg [9]int8
- Login [18]int8
- Lockname [9]int8
- Comm [20]int8
- Emul [17]int8
- Loginclass [18]int8
- Sparestrings [50]int8
- Spareints [4]int32
- Flag2 int32
- Fibnum int32
- Cr_flags uint32
- Jid int32
- Numthreads int32
- Tid int32
- Pri Priority
- Rusage Rusage
- Rusage_ch Rusage
- Pcb int32 /* pcb */
- Kstack int32
- Udata int32
- Tdaddr int32 /* thread */
- Spareptrs [6]int64
- Sparelongs [12]int64
- Sflag int64
- Tdflags int64
-}
-
-type Priority struct {
- Class uint8
- Level uint8
- Native uint8
- User uint8
-}
-
-type KinfoVmentry struct {
- Structsize int32
- Type int32
- Start uint64
- End uint64
- Offset uint64
- Vn_fileid uint64
- Vn_fsid uint32
- Flags int32
- Resident int32
- Private_resident int32
- Protection int32
- Ref_count int32
- Shadow_count int32
- Vn_type int32
- Vn_size uint64
- Vn_rdev uint32
- Vn_mode uint16
- Status uint16
- X_kve_ispare [12]int32
- Path [1024]int8
-}
diff --git a/vendor/github.com/shirou/gopsutil/process/process_linux.go b/vendor/github.com/shirou/gopsutil/process/process_linux.go
deleted file mode 100644
index 6708173..0000000
--- a/vendor/github.com/shirou/gopsutil/process/process_linux.go
+++ /dev/null
@@ -1,1262 +0,0 @@
-// +build linux
-
-package process
-
-import (
- "bufio"
- "bytes"
- "context"
- "encoding/json"
- "fmt"
- "io/ioutil"
- "math"
- "os"
- "path/filepath"
- "strconv"
- "strings"
-
- "github.com/shirou/gopsutil/cpu"
- "github.com/shirou/gopsutil/host"
- "github.com/shirou/gopsutil/internal/common"
- "github.com/shirou/gopsutil/net"
- "golang.org/x/sys/unix"
-)
-
-var PageSize = uint64(os.Getpagesize())
-
-const (
- PrioProcess = 0 // linux/resource.h
- ClockTicks = 100 // C.sysconf(C._SC_CLK_TCK)
-)
-
-// MemoryInfoExStat is different between OSes
-type MemoryInfoExStat struct {
- RSS uint64 `json:"rss"` // bytes
- VMS uint64 `json:"vms"` // bytes
- Shared uint64 `json:"shared"` // bytes
- Text uint64 `json:"text"` // bytes
- Lib uint64 `json:"lib"` // bytes
- Data uint64 `json:"data"` // bytes
- Dirty uint64 `json:"dirty"` // bytes
-}
-
-func (m MemoryInfoExStat) String() string {
- s, _ := json.Marshal(m)
- return string(s)
-}
-
-type MemoryMapsStat struct {
- Path string `json:"path"`
- Rss uint64 `json:"rss"`
- Size uint64 `json:"size"`
- Pss uint64 `json:"pss"`
- SharedClean uint64 `json:"sharedClean"`
- SharedDirty uint64 `json:"sharedDirty"`
- PrivateClean uint64 `json:"privateClean"`
- PrivateDirty uint64 `json:"privateDirty"`
- Referenced uint64 `json:"referenced"`
- Anonymous uint64 `json:"anonymous"`
- Swap uint64 `json:"swap"`
-}
-
-// String returns JSON value of the process.
-func (m MemoryMapsStat) String() string {
- s, _ := json.Marshal(m)
- return string(s)
-}
-
-// NewProcess creates a new Process instance, it only stores the pid and
-// checks that the process exists. Other method on Process can be used
-// to get more information about the process. An error will be returned
-// if the process does not exist.
-func NewProcess(pid int32) (*Process, error) {
- p := &Process{
- Pid: int32(pid),
- }
- file, err := os.Open(common.HostProc(strconv.Itoa(int(p.Pid))))
- defer file.Close()
- return p, err
-}
-
-// Ppid returns Parent Process ID of the process.
-func (p *Process) Ppid() (int32, error) {
- return p.PpidWithContext(context.Background())
-}
-
-func (p *Process) PpidWithContext(ctx context.Context) (int32, error) {
- _, ppid, _, _, _, _, err := p.fillFromStat()
- if err != nil {
- return -1, err
- }
- return ppid, nil
-}
-
-// Name returns name of the process.
-func (p *Process) Name() (string, error) {
- return p.NameWithContext(context.Background())
-}
-
-func (p *Process) NameWithContext(ctx context.Context) (string, error) {
- if p.name == "" {
- if err := p.fillFromStatus(); err != nil {
- return "", err
- }
- }
- return p.name, nil
-}
-
-// Tgid returns tgid, a Linux-synonym for user-space Pid
-func (p *Process) Tgid() (int32, error) {
- if p.tgid == 0 {
- if err := p.fillFromStatus(); err != nil {
- return 0, err
- }
- }
- return p.tgid, nil
-}
-
-// Exe returns executable path of the process.
-func (p *Process) Exe() (string, error) {
- return p.ExeWithContext(context.Background())
-}
-
-func (p *Process) ExeWithContext(ctx context.Context) (string, error) {
- return p.fillFromExe()
-}
-
-// Cmdline returns the command line arguments of the process as a string with
-// each argument separated by 0x20 ascii character.
-func (p *Process) Cmdline() (string, error) {
- return p.CmdlineWithContext(context.Background())
-}
-
-func (p *Process) CmdlineWithContext(ctx context.Context) (string, error) {
- return p.fillFromCmdline()
-}
-
-// CmdlineSlice returns the command line arguments of the process as a slice with each
-// element being an argument.
-func (p *Process) CmdlineSlice() ([]string, error) {
- return p.CmdlineSliceWithContext(context.Background())
-}
-
-func (p *Process) CmdlineSliceWithContext(ctx context.Context) ([]string, error) {
- return p.fillSliceFromCmdline()
-}
-
-// CreateTime returns created time of the process in milliseconds since the epoch, in UTC.
-func (p *Process) CreateTime() (int64, error) {
- return p.CreateTimeWithContext(context.Background())
-}
-
-func (p *Process) CreateTimeWithContext(ctx context.Context) (int64, error) {
- _, _, _, createTime, _, _, err := p.fillFromStat()
- if err != nil {
- return 0, err
- }
- return createTime, nil
-}
-
-// Cwd returns current working directory of the process.
-func (p *Process) Cwd() (string, error) {
- return p.CwdWithContext(context.Background())
-}
-
-func (p *Process) CwdWithContext(ctx context.Context) (string, error) {
- return p.fillFromCwd()
-}
-
-// Parent returns parent Process of the process.
-func (p *Process) Parent() (*Process, error) {
- return p.ParentWithContext(context.Background())
-}
-
-func (p *Process) ParentWithContext(ctx context.Context) (*Process, error) {
- err := p.fillFromStatus()
- if err != nil {
- return nil, err
- }
- if p.parent == 0 {
- return nil, fmt.Errorf("wrong number of parents")
- }
- return NewProcess(p.parent)
-}
-
-// Status returns the process status.
-// Return value could be one of these.
-// R: Running S: Sleep T: Stop I: Idle
-// Z: Zombie W: Wait L: Lock
-// The charactor is same within all supported platforms.
-func (p *Process) Status() (string, error) {
- return p.StatusWithContext(context.Background())
-}
-
-func (p *Process) StatusWithContext(ctx context.Context) (string, error) {
- err := p.fillFromStatus()
- if err != nil {
- return "", err
- }
- return p.status, nil
-}
-
-// Uids returns user ids of the process as a slice of the int
-func (p *Process) Uids() ([]int32, error) {
- return p.UidsWithContext(context.Background())
-}
-
-func (p *Process) UidsWithContext(ctx context.Context) ([]int32, error) {
- err := p.fillFromStatus()
- if err != nil {
- return []int32{}, err
- }
- return p.uids, nil
-}
-
-// Gids returns group ids of the process as a slice of the int
-func (p *Process) Gids() ([]int32, error) {
- return p.GidsWithContext(context.Background())
-}
-
-func (p *Process) GidsWithContext(ctx context.Context) ([]int32, error) {
- err := p.fillFromStatus()
- if err != nil {
- return []int32{}, err
- }
- return p.gids, nil
-}
-
-// Terminal returns a terminal which is associated with the process.
-func (p *Process) Terminal() (string, error) {
- return p.TerminalWithContext(context.Background())
-}
-
-func (p *Process) TerminalWithContext(ctx context.Context) (string, error) {
- t, _, _, _, _, _, err := p.fillFromStat()
- if err != nil {
- return "", err
- }
- termmap, err := getTerminalMap()
- if err != nil {
- return "", err
- }
- terminal := termmap[t]
- return terminal, nil
-}
-
-// Nice returns a nice value (priority).
-// Notice: gopsutil can not set nice value.
-func (p *Process) Nice() (int32, error) {
- return p.NiceWithContext(context.Background())
-}
-
-func (p *Process) NiceWithContext(ctx context.Context) (int32, error) {
- _, _, _, _, _, nice, err := p.fillFromStat()
- if err != nil {
- return 0, err
- }
- return nice, nil
-}
-
-// IOnice returns process I/O nice value (priority).
-func (p *Process) IOnice() (int32, error) {
- return p.IOniceWithContext(context.Background())
-}
-
-func (p *Process) IOniceWithContext(ctx context.Context) (int32, error) {
- return 0, common.ErrNotImplementedError
-}
-
-// Rlimit returns Resource Limits.
-func (p *Process) Rlimit() ([]RlimitStat, error) {
- return p.RlimitWithContext(context.Background())
-}
-
-func (p *Process) RlimitWithContext(ctx context.Context) ([]RlimitStat, error) {
- return p.RlimitUsage(false)
-}
-
-// RlimitUsage returns Resource Limits.
-// If gatherUsed is true, the currently used value will be gathered and added
-// to the resulting RlimitStat.
-func (p *Process) RlimitUsage(gatherUsed bool) ([]RlimitStat, error) {
- return p.RlimitUsageWithContext(context.Background(), gatherUsed)
-}
-
-func (p *Process) RlimitUsageWithContext(ctx context.Context, gatherUsed bool) ([]RlimitStat, error) {
- rlimits, err := p.fillFromLimits()
- if !gatherUsed || err != nil {
- return rlimits, err
- }
-
- _, _, _, _, rtprio, nice, err := p.fillFromStat()
- if err != nil {
- return nil, err
- }
- if err := p.fillFromStatus(); err != nil {
- return nil, err
- }
-
- for i := range rlimits {
- rs := &rlimits[i]
- switch rs.Resource {
- case RLIMIT_CPU:
- times, err := p.Times()
- if err != nil {
- return nil, err
- }
- rs.Used = uint64(times.User + times.System)
- case RLIMIT_DATA:
- rs.Used = uint64(p.memInfo.Data)
- case RLIMIT_STACK:
- rs.Used = uint64(p.memInfo.Stack)
- case RLIMIT_RSS:
- rs.Used = uint64(p.memInfo.RSS)
- case RLIMIT_NOFILE:
- n, err := p.NumFDs()
- if err != nil {
- return nil, err
- }
- rs.Used = uint64(n)
- case RLIMIT_MEMLOCK:
- rs.Used = uint64(p.memInfo.Locked)
- case RLIMIT_AS:
- rs.Used = uint64(p.memInfo.VMS)
- case RLIMIT_LOCKS:
- //TODO we can get the used value from /proc/$pid/locks. But linux doesn't enforce it, so not a high priority.
- case RLIMIT_SIGPENDING:
- rs.Used = p.sigInfo.PendingProcess
- case RLIMIT_NICE:
- // The rlimit for nice is a little unusual, in that 0 means the niceness cannot be decreased beyond the current value, but it can be increased.
- // So effectively: if rs.Soft == 0 { rs.Soft = rs.Used }
- rs.Used = uint64(nice)
- case RLIMIT_RTPRIO:
- rs.Used = uint64(rtprio)
- }
- }
-
- return rlimits, err
-}
-
-// IOCounters returns IO Counters.
-func (p *Process) IOCounters() (*IOCountersStat, error) {
- return p.IOCountersWithContext(context.Background())
-}
-
-func (p *Process) IOCountersWithContext(ctx context.Context) (*IOCountersStat, error) {
- return p.fillFromIO()
-}
-
-// NumCtxSwitches returns the number of the context switches of the process.
-func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error) {
- return p.NumCtxSwitchesWithContext(context.Background())
-}
-
-func (p *Process) NumCtxSwitchesWithContext(ctx context.Context) (*NumCtxSwitchesStat, error) {
- err := p.fillFromStatus()
- if err != nil {
- return nil, err
- }
- return p.numCtxSwitches, nil
-}
-
-// NumFDs returns the number of File Descriptors used by the process.
-func (p *Process) NumFDs() (int32, error) {
- return p.NumFDsWithContext(context.Background())
-}
-
-func (p *Process) NumFDsWithContext(ctx context.Context) (int32, error) {
- _, fnames, err := p.fillFromfdList()
- return int32(len(fnames)), err
-}
-
-// NumThreads returns the number of threads used by the process.
-func (p *Process) NumThreads() (int32, error) {
- return p.NumThreadsWithContext(context.Background())
-}
-
-func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) {
- err := p.fillFromStatus()
- if err != nil {
- return 0, err
- }
- return p.numThreads, nil
-}
-
-func (p *Process) Threads() (map[int32]*cpu.TimesStat, error) {
- return p.ThreadsWithContext(context.Background())
-}
-
-func (p *Process) ThreadsWithContext(ctx context.Context) (map[int32]*cpu.TimesStat, error) {
- ret := make(map[int32]*cpu.TimesStat)
- taskPath := common.HostProc(strconv.Itoa(int(p.Pid)), "task")
-
- tids, err := readPidsFromDir(taskPath)
- if err != nil {
- return nil, err
- }
-
- for _, tid := range tids {
- _, _, cpuTimes, _, _, _, err := p.fillFromTIDStat(tid)
- if err != nil {
- return nil, err
- }
- ret[tid] = cpuTimes
- }
-
- return ret, nil
-}
-
-// Times returns CPU times of the process.
-func (p *Process) Times() (*cpu.TimesStat, error) {
- return p.TimesWithContext(context.Background())
-}
-
-func (p *Process) TimesWithContext(ctx context.Context) (*cpu.TimesStat, error) {
- _, _, cpuTimes, _, _, _, err := p.fillFromStat()
- if err != nil {
- return nil, err
- }
- return cpuTimes, nil
-}
-
-// CPUAffinity returns CPU affinity of the process.
-//
-// Notice: Not implemented yet.
-func (p *Process) CPUAffinity() ([]int32, error) {
- return p.CPUAffinityWithContext(context.Background())
-}
-
-func (p *Process) CPUAffinityWithContext(ctx context.Context) ([]int32, error) {
- return nil, common.ErrNotImplementedError
-}
-
-// MemoryInfo returns platform in-dependend memory information, such as RSS, VMS and Swap
-func (p *Process) MemoryInfo() (*MemoryInfoStat, error) {
- return p.MemoryInfoWithContext(context.Background())
-}
-
-func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, error) {
- meminfo, _, err := p.fillFromStatm()
- if err != nil {
- return nil, err
- }
- return meminfo, nil
-}
-
-// MemoryInfoEx returns platform dependend memory information.
-func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error) {
- return p.MemoryInfoExWithContext(context.Background())
-}
-
-func (p *Process) MemoryInfoExWithContext(ctx context.Context) (*MemoryInfoExStat, error) {
- _, memInfoEx, err := p.fillFromStatm()
- if err != nil {
- return nil, err
- }
- return memInfoEx, nil
-}
-
-// Children returns a slice of Process of the process.
-func (p *Process) Children() ([]*Process, error) {
- return p.ChildrenWithContext(context.Background())
-}
-
-func (p *Process) ChildrenWithContext(ctx context.Context) ([]*Process, error) {
- pids, err := common.CallPgrepWithContext(ctx, invoke, p.Pid)
- if err != nil {
- if pids == nil || len(pids) == 0 {
- return nil, ErrorNoChildren
- }
- return nil, err
- }
- ret := make([]*Process, 0, len(pids))
- for _, pid := range pids {
- np, err := NewProcess(pid)
- if err != nil {
- return nil, err
- }
- ret = append(ret, np)
- }
- return ret, nil
-}
-
-// OpenFiles returns a slice of OpenFilesStat opend by the process.
-// OpenFilesStat includes a file path and file descriptor.
-func (p *Process) OpenFiles() ([]OpenFilesStat, error) {
- return p.OpenFilesWithContext(context.Background())
-}
-
-func (p *Process) OpenFilesWithContext(ctx context.Context) ([]OpenFilesStat, error) {
- _, ofs, err := p.fillFromfd()
- if err != nil {
- return nil, err
- }
- ret := make([]OpenFilesStat, len(ofs))
- for i, o := range ofs {
- ret[i] = *o
- }
-
- return ret, nil
-}
-
-// Connections returns a slice of net.ConnectionStat used by the process.
-// This returns all kind of the connection. This measn TCP, UDP or UNIX.
-func (p *Process) Connections() ([]net.ConnectionStat, error) {
- return p.ConnectionsWithContext(context.Background())
-}
-
-func (p *Process) ConnectionsWithContext(ctx context.Context) ([]net.ConnectionStat, error) {
- return net.ConnectionsPid("all", p.Pid)
-}
-
-// NetIOCounters returns NetIOCounters of the process.
-func (p *Process) NetIOCounters(pernic bool) ([]net.IOCountersStat, error) {
- return p.NetIOCountersWithContext(context.Background(), pernic)
-}
-
-func (p *Process) NetIOCountersWithContext(ctx context.Context, pernic bool) ([]net.IOCountersStat, error) {
- filename := common.HostProc(strconv.Itoa(int(p.Pid)), "net/dev")
- return net.IOCountersByFile(pernic, filename)
-}
-
-// IsRunning returns whether the process is running or not.
-// Not implemented yet.
-func (p *Process) IsRunning() (bool, error) {
- return p.IsRunningWithContext(context.Background())
-}
-
-func (p *Process) IsRunningWithContext(ctx context.Context) (bool, error) {
- return true, common.ErrNotImplementedError
-}
-
-// MemoryMaps get memory maps from /proc/(pid)/smaps
-func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error) {
- return p.MemoryMapsWithContext(context.Background(), grouped)
-}
-
-func (p *Process) MemoryMapsWithContext(ctx context.Context, grouped bool) (*[]MemoryMapsStat, error) {
- pid := p.Pid
- var ret []MemoryMapsStat
- smapsPath := common.HostProc(strconv.Itoa(int(pid)), "smaps")
- contents, err := ioutil.ReadFile(smapsPath)
- if err != nil {
- return nil, err
- }
- lines := strings.Split(string(contents), "\n")
-
- // function of parsing a block
- getBlock := func(first_line []string, block []string) (MemoryMapsStat, error) {
- m := MemoryMapsStat{}
- m.Path = first_line[len(first_line)-1]
-
- for _, line := range block {
- if strings.Contains(line, "VmFlags") {
- continue
- }
- field := strings.Split(line, ":")
- if len(field) < 2 {
- continue
- }
- v := strings.Trim(field[1], " kB") // remove last "kB"
- t, err := strconv.ParseUint(v, 10, 64)
- if err != nil {
- return m, err
- }
-
- switch field[0] {
- case "Size":
- m.Size = t
- case "Rss":
- m.Rss = t
- case "Pss":
- m.Pss = t
- case "Shared_Clean":
- m.SharedClean = t
- case "Shared_Dirty":
- m.SharedDirty = t
- case "Private_Clean":
- m.PrivateClean = t
- case "Private_Dirty":
- m.PrivateDirty = t
- case "Referenced":
- m.Referenced = t
- case "Anonymous":
- m.Anonymous = t
- case "Swap":
- m.Swap = t
- }
- }
- return m, nil
- }
-
- blocks := make([]string, 16)
- for _, line := range lines {
- field := strings.Split(line, " ")
- if strings.HasSuffix(field[0], ":") == false {
- // new block section
- if len(blocks) > 0 {
- g, err := getBlock(field, blocks)
- if err != nil {
- return &ret, err
- }
- ret = append(ret, g)
- }
- // starts new block
- blocks = make([]string, 16)
- } else {
- blocks = append(blocks, line)
- }
- }
-
- return &ret, nil
-}
-
-/**
-** Internal functions
-**/
-
-func limitToInt(val string) (int32, error) {
- if val == "unlimited" {
- return math.MaxInt32, nil
- } else {
- res, err := strconv.ParseInt(val, 10, 32)
- if err != nil {
- return 0, err
- }
- return int32(res), nil
- }
-}
-
-// Get num_fds from /proc/(pid)/limits
-func (p *Process) fillFromLimits() ([]RlimitStat, error) {
- return p.fillFromLimitsWithContext(context.Background())
-}
-
-func (p *Process) fillFromLimitsWithContext(ctx context.Context) ([]RlimitStat, error) {
- pid := p.Pid
- limitsFile := common.HostProc(strconv.Itoa(int(pid)), "limits")
- d, err := os.Open(limitsFile)
- if err != nil {
- return nil, err
- }
- defer d.Close()
-
- var limitStats []RlimitStat
-
- limitsScanner := bufio.NewScanner(d)
- for limitsScanner.Scan() {
- var statItem RlimitStat
-
- str := strings.Fields(limitsScanner.Text())
-
- // Remove the header line
- if strings.Contains(str[len(str)-1], "Units") {
- continue
- }
-
- // Assert that last item is a Hard limit
- statItem.Hard, err = limitToInt(str[len(str)-1])
- if err != nil {
- // On error remove last item an try once again since it can be unit or header line
- str = str[:len(str)-1]
- statItem.Hard, err = limitToInt(str[len(str)-1])
- if err != nil {
- return nil, err
- }
- }
- // Remove last item from string
- str = str[:len(str)-1]
-
- //Now last item is a Soft limit
- statItem.Soft, err = limitToInt(str[len(str)-1])
- if err != nil {
- return nil, err
- }
- // Remove last item from string
- str = str[:len(str)-1]
-
- //The rest is a stats name
- resourceName := strings.Join(str, " ")
- switch resourceName {
- case "Max cpu time":
- statItem.Resource = RLIMIT_CPU
- case "Max file size":
- statItem.Resource = RLIMIT_FSIZE
- case "Max data size":
- statItem.Resource = RLIMIT_DATA
- case "Max stack size":
- statItem.Resource = RLIMIT_STACK
- case "Max core file size":
- statItem.Resource = RLIMIT_CORE
- case "Max resident set":
- statItem.Resource = RLIMIT_RSS
- case "Max processes":
- statItem.Resource = RLIMIT_NPROC
- case "Max open files":
- statItem.Resource = RLIMIT_NOFILE
- case "Max locked memory":
- statItem.Resource = RLIMIT_MEMLOCK
- case "Max address space":
- statItem.Resource = RLIMIT_AS
- case "Max file locks":
- statItem.Resource = RLIMIT_LOCKS
- case "Max pending signals":
- statItem.Resource = RLIMIT_SIGPENDING
- case "Max msgqueue size":
- statItem.Resource = RLIMIT_MSGQUEUE
- case "Max nice priority":
- statItem.Resource = RLIMIT_NICE
- case "Max realtime priority":
- statItem.Resource = RLIMIT_RTPRIO
- case "Max realtime timeout":
- statItem.Resource = RLIMIT_RTTIME
- default:
- continue
- }
-
- limitStats = append(limitStats, statItem)
- }
-
- if err := limitsScanner.Err(); err != nil {
- return nil, err
- }
-
- return limitStats, nil
-}
-
-// Get list of /proc/(pid)/fd files
-func (p *Process) fillFromfdList() (string, []string, error) {
- return p.fillFromfdListWithContext(context.Background())
-}
-
-func (p *Process) fillFromfdListWithContext(ctx context.Context) (string, []string, error) {
- pid := p.Pid
- statPath := common.HostProc(strconv.Itoa(int(pid)), "fd")
- d, err := os.Open(statPath)
- if err != nil {
- return statPath, []string{}, err
- }
- defer d.Close()
- fnames, err := d.Readdirnames(-1)
- return statPath, fnames, err
-}
-
-// Get num_fds from /proc/(pid)/fd
-func (p *Process) fillFromfd() (int32, []*OpenFilesStat, error) {
- return p.fillFromfdWithContext(context.Background())
-}
-
-func (p *Process) fillFromfdWithContext(ctx context.Context) (int32, []*OpenFilesStat, error) {
- statPath, fnames, err := p.fillFromfdList()
- if err != nil {
- return 0, nil, err
- }
- numFDs := int32(len(fnames))
-
- var openfiles []*OpenFilesStat
- for _, fd := range fnames {
- fpath := filepath.Join(statPath, fd)
- filepath, err := os.Readlink(fpath)
- if err != nil {
- continue
- }
- t, err := strconv.ParseUint(fd, 10, 64)
- if err != nil {
- return numFDs, openfiles, err
- }
- o := &OpenFilesStat{
- Path: filepath,
- Fd: t,
- }
- openfiles = append(openfiles, o)
- }
-
- return numFDs, openfiles, nil
-}
-
-// Get cwd from /proc/(pid)/cwd
-func (p *Process) fillFromCwd() (string, error) {
- return p.fillFromCwdWithContext(context.Background())
-}
-
-func (p *Process) fillFromCwdWithContext(ctx context.Context) (string, error) {
- pid := p.Pid
- cwdPath := common.HostProc(strconv.Itoa(int(pid)), "cwd")
- cwd, err := os.Readlink(cwdPath)
- if err != nil {
- return "", err
- }
- return string(cwd), nil
-}
-
-// Get exe from /proc/(pid)/exe
-func (p *Process) fillFromExe() (string, error) {
- return p.fillFromExeWithContext(context.Background())
-}
-
-func (p *Process) fillFromExeWithContext(ctx context.Context) (string, error) {
- pid := p.Pid
- exePath := common.HostProc(strconv.Itoa(int(pid)), "exe")
- exe, err := os.Readlink(exePath)
- if err != nil {
- return "", err
- }
- return string(exe), nil
-}
-
-// Get cmdline from /proc/(pid)/cmdline
-func (p *Process) fillFromCmdline() (string, error) {
- return p.fillFromCmdlineWithContext(context.Background())
-}
-
-func (p *Process) fillFromCmdlineWithContext(ctx context.Context) (string, error) {
- pid := p.Pid
- cmdPath := common.HostProc(strconv.Itoa(int(pid)), "cmdline")
- cmdline, err := ioutil.ReadFile(cmdPath)
- if err != nil {
- return "", err
- }
- ret := strings.FieldsFunc(string(cmdline), func(r rune) bool {
- if r == '\u0000' {
- return true
- }
- return false
- })
-
- return strings.Join(ret, " "), nil
-}
-
-func (p *Process) fillSliceFromCmdline() ([]string, error) {
- return p.fillSliceFromCmdlineWithContext(context.Background())
-}
-
-func (p *Process) fillSliceFromCmdlineWithContext(ctx context.Context) ([]string, error) {
- pid := p.Pid
- cmdPath := common.HostProc(strconv.Itoa(int(pid)), "cmdline")
- cmdline, err := ioutil.ReadFile(cmdPath)
- if err != nil {
- return nil, err
- }
- if len(cmdline) == 0 {
- return nil, nil
- }
- if cmdline[len(cmdline)-1] == 0 {
- cmdline = cmdline[:len(cmdline)-1]
- }
- parts := bytes.Split(cmdline, []byte{0})
- var strParts []string
- for _, p := range parts {
- strParts = append(strParts, string(p))
- }
-
- return strParts, nil
-}
-
-// Get IO status from /proc/(pid)/io
-func (p *Process) fillFromIO() (*IOCountersStat, error) {
- return p.fillFromIOWithContext(context.Background())
-}
-
-func (p *Process) fillFromIOWithContext(ctx context.Context) (*IOCountersStat, error) {
- pid := p.Pid
- ioPath := common.HostProc(strconv.Itoa(int(pid)), "io")
- ioline, err := ioutil.ReadFile(ioPath)
- if err != nil {
- return nil, err
- }
- lines := strings.Split(string(ioline), "\n")
- ret := &IOCountersStat{}
-
- for _, line := range lines {
- field := strings.Fields(line)
- if len(field) < 2 {
- continue
- }
- t, err := strconv.ParseUint(field[1], 10, 64)
- if err != nil {
- return nil, err
- }
- param := field[0]
- if strings.HasSuffix(param, ":") {
- param = param[:len(param)-1]
- }
- switch param {
- case "syscr":
- ret.ReadCount = t
- case "syscw":
- ret.WriteCount = t
- case "read_bytes":
- ret.ReadBytes = t
- case "write_bytes":
- ret.WriteBytes = t
- }
- }
-
- return ret, nil
-}
-
-// Get memory info from /proc/(pid)/statm
-func (p *Process) fillFromStatm() (*MemoryInfoStat, *MemoryInfoExStat, error) {
- return p.fillFromStatmWithContext(context.Background())
-}
-
-func (p *Process) fillFromStatmWithContext(ctx context.Context) (*MemoryInfoStat, *MemoryInfoExStat, error) {
- pid := p.Pid
- memPath := common.HostProc(strconv.Itoa(int(pid)), "statm")
- contents, err := ioutil.ReadFile(memPath)
- if err != nil {
- return nil, nil, err
- }
- fields := strings.Split(string(contents), " ")
-
- vms, err := strconv.ParseUint(fields[0], 10, 64)
- if err != nil {
- return nil, nil, err
- }
- rss, err := strconv.ParseUint(fields[1], 10, 64)
- if err != nil {
- return nil, nil, err
- }
- memInfo := &MemoryInfoStat{
- RSS: rss * PageSize,
- VMS: vms * PageSize,
- }
-
- shared, err := strconv.ParseUint(fields[2], 10, 64)
- if err != nil {
- return nil, nil, err
- }
- text, err := strconv.ParseUint(fields[3], 10, 64)
- if err != nil {
- return nil, nil, err
- }
- lib, err := strconv.ParseUint(fields[4], 10, 64)
- if err != nil {
- return nil, nil, err
- }
- dirty, err := strconv.ParseUint(fields[5], 10, 64)
- if err != nil {
- return nil, nil, err
- }
-
- memInfoEx := &MemoryInfoExStat{
- RSS: rss * PageSize,
- VMS: vms * PageSize,
- Shared: shared * PageSize,
- Text: text * PageSize,
- Lib: lib * PageSize,
- Dirty: dirty * PageSize,
- }
-
- return memInfo, memInfoEx, nil
-}
-
-// Get various status from /proc/(pid)/status
-func (p *Process) fillFromStatus() error {
- return p.fillFromStatusWithContext(context.Background())
-}
-
-func (p *Process) fillFromStatusWithContext(ctx context.Context) error {
- pid := p.Pid
- statPath := common.HostProc(strconv.Itoa(int(pid)), "status")
- contents, err := ioutil.ReadFile(statPath)
- if err != nil {
- return err
- }
- lines := strings.Split(string(contents), "\n")
- p.numCtxSwitches = &NumCtxSwitchesStat{}
- p.memInfo = &MemoryInfoStat{}
- p.sigInfo = &SignalInfoStat{}
- for _, line := range lines {
- tabParts := strings.SplitN(line, "\t", 2)
- if len(tabParts) < 2 {
- continue
- }
- value := tabParts[1]
- switch strings.TrimRight(tabParts[0], ":") {
- case "Name":
- p.name = strings.Trim(value, " \t")
- if len(p.name) >= 15 {
- cmdlineSlice, err := p.CmdlineSlice()
- if err != nil {
- return err
- }
- if len(cmdlineSlice) > 0 {
- extendedName := filepath.Base(cmdlineSlice[0])
- if strings.HasPrefix(extendedName, p.name) {
- p.name = extendedName
- } else {
- p.name = cmdlineSlice[0]
- }
- }
- }
- case "State":
- p.status = value[0:1]
- case "PPid", "Ppid":
- pval, err := strconv.ParseInt(value, 10, 32)
- if err != nil {
- return err
- }
- p.parent = int32(pval)
- case "Tgid":
- pval, err := strconv.ParseInt(value, 10, 32)
- if err != nil {
- return err
- }
- p.tgid = int32(pval)
- case "Uid":
- p.uids = make([]int32, 0, 4)
- for _, i := range strings.Split(value, "\t") {
- v, err := strconv.ParseInt(i, 10, 32)
- if err != nil {
- return err
- }
- p.uids = append(p.uids, int32(v))
- }
- case "Gid":
- p.gids = make([]int32, 0, 4)
- for _, i := range strings.Split(value, "\t") {
- v, err := strconv.ParseInt(i, 10, 32)
- if err != nil {
- return err
- }
- p.gids = append(p.gids, int32(v))
- }
- case "Threads":
- v, err := strconv.ParseInt(value, 10, 32)
- if err != nil {
- return err
- }
- p.numThreads = int32(v)
- case "voluntary_ctxt_switches":
- v, err := strconv.ParseInt(value, 10, 64)
- if err != nil {
- return err
- }
- p.numCtxSwitches.Voluntary = v
- case "nonvoluntary_ctxt_switches":
- v, err := strconv.ParseInt(value, 10, 64)
- if err != nil {
- return err
- }
- p.numCtxSwitches.Involuntary = v
- case "VmRSS":
- value := strings.Trim(value, " kB") // remove last "kB"
- v, err := strconv.ParseUint(value, 10, 64)
- if err != nil {
- return err
- }
- p.memInfo.RSS = v * 1024
- case "VmSize":
- value := strings.Trim(value, " kB") // remove last "kB"
- v, err := strconv.ParseUint(value, 10, 64)
- if err != nil {
- return err
- }
- p.memInfo.VMS = v * 1024
- case "VmSwap":
- value := strings.Trim(value, " kB") // remove last "kB"
- v, err := strconv.ParseUint(value, 10, 64)
- if err != nil {
- return err
- }
- p.memInfo.Swap = v * 1024
- case "VmData":
- value := strings.Trim(value, " kB") // remove last "kB"
- v, err := strconv.ParseUint(value, 10, 64)
- if err != nil {
- return err
- }
- p.memInfo.Data = v * 1024
- case "VmStk":
- value := strings.Trim(value, " kB") // remove last "kB"
- v, err := strconv.ParseUint(value, 10, 64)
- if err != nil {
- return err
- }
- p.memInfo.Stack = v * 1024
- case "VmLck":
- value := strings.Trim(value, " kB") // remove last "kB"
- v, err := strconv.ParseUint(value, 10, 64)
- if err != nil {
- return err
- }
- p.memInfo.Locked = v * 1024
- case "SigPnd":
- v, err := strconv.ParseUint(value, 16, 64)
- if err != nil {
- return err
- }
- p.sigInfo.PendingThread = v
- case "ShdPnd":
- v, err := strconv.ParseUint(value, 16, 64)
- if err != nil {
- return err
- }
- p.sigInfo.PendingProcess = v
- case "SigBlk":
- v, err := strconv.ParseUint(value, 16, 64)
- if err != nil {
- return err
- }
- p.sigInfo.Blocked = v
- case "SigIgn":
- v, err := strconv.ParseUint(value, 16, 64)
- if err != nil {
- return err
- }
- p.sigInfo.Ignored = v
- case "SigCgt":
- v, err := strconv.ParseUint(value, 16, 64)
- if err != nil {
- return err
- }
- p.sigInfo.Caught = v
- }
-
- }
- return nil
-}
-
-func (p *Process) fillFromTIDStat(tid int32) (uint64, int32, *cpu.TimesStat, int64, uint32, int32, error) {
- return p.fillFromTIDStatWithContext(context.Background(), tid)
-}
-
-func (p *Process) fillFromTIDStatWithContext(ctx context.Context, tid int32) (uint64, int32, *cpu.TimesStat, int64, uint32, int32, error) {
- pid := p.Pid
- var statPath string
-
- if tid == -1 {
- statPath = common.HostProc(strconv.Itoa(int(pid)), "stat")
- } else {
- statPath = common.HostProc(strconv.Itoa(int(pid)), "task", strconv.Itoa(int(tid)), "stat")
- }
-
- contents, err := ioutil.ReadFile(statPath)
- if err != nil {
- return 0, 0, nil, 0, 0, 0, err
- }
- fields := strings.Fields(string(contents))
-
- i := 1
- for !strings.HasSuffix(fields[i], ")") {
- i++
- }
-
- terminal, err := strconv.ParseUint(fields[i+5], 10, 64)
- if err != nil {
- return 0, 0, nil, 0, 0, 0, err
- }
-
- ppid, err := strconv.ParseInt(fields[i+2], 10, 32)
- if err != nil {
- return 0, 0, nil, 0, 0, 0, err
- }
- utime, err := strconv.ParseFloat(fields[i+12], 64)
- if err != nil {
- return 0, 0, nil, 0, 0, 0, err
- }
-
- stime, err := strconv.ParseFloat(fields[i+13], 64)
- if err != nil {
- return 0, 0, nil, 0, 0, 0, err
- }
-
- cpuTimes := &cpu.TimesStat{
- CPU: "cpu",
- User: float64(utime / ClockTicks),
- System: float64(stime / ClockTicks),
- }
-
- bootTime, _ := host.BootTime()
- t, err := strconv.ParseUint(fields[i+20], 10, 64)
- if err != nil {
- return 0, 0, nil, 0, 0, 0, err
- }
- ctime := (t / uint64(ClockTicks)) + uint64(bootTime)
- createTime := int64(ctime * 1000)
-
- rtpriority, err := strconv.ParseInt(fields[i+16], 10, 32)
- if err != nil {
- return 0, 0, nil, 0, 0, 0, err
- }
- if rtpriority < 0 {
- rtpriority = rtpriority*-1 - 1
- } else {
- rtpriority = 0
- }
-
- // p.Nice = mustParseInt32(fields[18])
- // use syscall instead of parse Stat file
- snice, _ := unix.Getpriority(PrioProcess, int(pid))
- nice := int32(snice) // FIXME: is this true?
-
- return terminal, int32(ppid), cpuTimes, createTime, uint32(rtpriority), nice, nil
-}
-
-func (p *Process) fillFromStat() (uint64, int32, *cpu.TimesStat, int64, uint32, int32, error) {
- return p.fillFromStatWithContext(context.Background())
-}
-
-func (p *Process) fillFromStatWithContext(ctx context.Context) (uint64, int32, *cpu.TimesStat, int64, uint32, int32, error) {
- return p.fillFromTIDStat(-1)
-}
-
-// Pids returns a slice of process ID list which are running now.
-func Pids() ([]int32, error) {
- return PidsWithContext(context.Background())
-}
-
-func PidsWithContext(ctx context.Context) ([]int32, error) {
- return readPidsFromDir(common.HostProc())
-}
-
-// Process returns a slice of pointers to Process structs for all
-// currently running processes.
-func Processes() ([]*Process, error) {
- return ProcessesWithContext(context.Background())
-}
-
-func ProcessesWithContext(ctx context.Context) ([]*Process, error) {
- out := []*Process{}
-
- pids, err := Pids()
- if err != nil {
- return out, err
- }
-
- for _, pid := range pids {
- p, err := NewProcess(pid)
- if err != nil {
- continue
- }
- out = append(out, p)
- }
-
- return out, nil
-}
-
-func readPidsFromDir(path string) ([]int32, error) {
- var ret []int32
-
- d, err := os.Open(path)
- if err != nil {
- return nil, err
- }
- defer d.Close()
-
- fnames, err := d.Readdirnames(-1)
- if err != nil {
- return nil, err
- }
- for _, fname := range fnames {
- pid, err := strconv.ParseInt(fname, 10, 32)
- if err != nil {
- // if not numeric name, just skip
- continue
- }
- ret = append(ret, int32(pid))
- }
-
- return ret, nil
-}
diff --git a/vendor/github.com/shirou/gopsutil/process/process_openbsd.go b/vendor/github.com/shirou/gopsutil/process/process_openbsd.go
deleted file mode 100644
index b7b2cba..0000000
--- a/vendor/github.com/shirou/gopsutil/process/process_openbsd.go
+++ /dev/null
@@ -1,510 +0,0 @@
-// +build openbsd
-
-package process
-
-import (
- "C"
- "bytes"
- "context"
- "encoding/binary"
- "strings"
- "unsafe"
-
- cpu "github.com/shirou/gopsutil/cpu"
- "github.com/shirou/gopsutil/internal/common"
- mem "github.com/shirou/gopsutil/mem"
- net "github.com/shirou/gopsutil/net"
- "golang.org/x/sys/unix"
-)
-
-// MemoryInfoExStat is different between OSes
-type MemoryInfoExStat struct {
-}
-
-type MemoryMapsStat struct {
-}
-
-func Pids() ([]int32, error) {
- return PidsWithContext(context.Background())
-}
-
-func PidsWithContext(ctx context.Context) ([]int32, error) {
- var ret []int32
- procs, err := Processes()
- if err != nil {
- return ret, nil
- }
-
- for _, p := range procs {
- ret = append(ret, p.Pid)
- }
-
- return ret, nil
-}
-
-func (p *Process) Ppid() (int32, error) {
- return p.PpidWithContext(context.Background())
-}
-
-func (p *Process) PpidWithContext(ctx context.Context) (int32, error) {
- k, err := p.getKProc()
- if err != nil {
- return 0, err
- }
-
- return k.Ppid, nil
-}
-func (p *Process) Name() (string, error) {
- return p.NameWithContext(context.Background())
-}
-
-func (p *Process) NameWithContext(ctx context.Context) (string, error) {
- k, err := p.getKProc()
- if err != nil {
- return "", err
- }
-
- return common.IntToString(k.Comm[:]), nil
-}
-func (p *Process) Tgid() (int32, error) {
- return 0, common.ErrNotImplementedError
-}
-func (p *Process) Exe() (string, error) {
- return p.ExeWithContext(context.Background())
-}
-
-func (p *Process) ExeWithContext(ctx context.Context) (string, error) {
- return "", common.ErrNotImplementedError
-}
-
-func (p *Process) CmdlineSlice() ([]string, error) {
- return p.CmdlineSliceWithContext(context.Background())
-}
-
-func (p *Process) CmdlineSliceWithContext(ctx context.Context) ([]string, error) {
- mib := []int32{CTLKern, KernProcArgs, p.Pid, KernProcArgv}
- buf, _, err := common.CallSyscall(mib)
-
- if err != nil {
- return nil, err
- }
-
- argc := 0
- argvp := unsafe.Pointer(&buf[0])
- argv := *(**C.char)(unsafe.Pointer(argvp))
- size := unsafe.Sizeof(argv)
- var strParts []string
-
- for argv != nil {
- strParts = append(strParts, C.GoString(argv))
-
- argc++
- argv = *(**C.char)(unsafe.Pointer(uintptr(argvp) + uintptr(argc)*size))
- }
- return strParts, nil
-}
-
-func (p *Process) Cmdline() (string, error) {
- return p.CmdlineWithContext(context.Background())
-}
-
-func (p *Process) CmdlineWithContext(ctx context.Context) (string, error) {
- argv, err := p.CmdlineSlice()
- if err != nil {
- return "", err
- }
- return strings.Join(argv, " "), nil
-}
-
-func (p *Process) CreateTime() (int64, error) {
- return p.CreateTimeWithContext(context.Background())
-}
-
-func (p *Process) CreateTimeWithContext(ctx context.Context) (int64, error) {
- return 0, common.ErrNotImplementedError
-}
-func (p *Process) Cwd() (string, error) {
- return p.CwdWithContext(context.Background())
-}
-
-func (p *Process) CwdWithContext(ctx context.Context) (string, error) {
- return "", common.ErrNotImplementedError
-}
-func (p *Process) Parent() (*Process, error) {
- return p.ParentWithContext(context.Background())
-}
-
-func (p *Process) ParentWithContext(ctx context.Context) (*Process, error) {
- return p, common.ErrNotImplementedError
-}
-func (p *Process) Status() (string, error) {
- return p.StatusWithContext(context.Background())
-}
-
-func (p *Process) StatusWithContext(ctx context.Context) (string, error) {
- k, err := p.getKProc()
- if err != nil {
- return "", err
- }
- var s string
- switch k.Stat {
- case SIDL:
- case SRUN:
- case SONPROC:
- s = "R"
- case SSLEEP:
- s = "S"
- case SSTOP:
- s = "T"
- case SDEAD:
- s = "Z"
- }
-
- return s, nil
-}
-func (p *Process) Uids() ([]int32, error) {
- return p.UidsWithContext(context.Background())
-}
-
-func (p *Process) UidsWithContext(ctx context.Context) ([]int32, error) {
- k, err := p.getKProc()
- if err != nil {
- return nil, err
- }
-
- uids := make([]int32, 0, 3)
-
- uids = append(uids, int32(k.Ruid), int32(k.Uid), int32(k.Svuid))
-
- return uids, nil
-}
-func (p *Process) Gids() ([]int32, error) {
- return p.GidsWithContext(context.Background())
-}
-
-func (p *Process) GidsWithContext(ctx context.Context) ([]int32, error) {
- k, err := p.getKProc()
- if err != nil {
- return nil, err
- }
-
- gids := make([]int32, 0, 3)
- gids = append(gids, int32(k.Rgid), int32(k.Ngroups), int32(k.Svgid))
-
- return gids, nil
-}
-func (p *Process) Terminal() (string, error) {
- return p.TerminalWithContext(context.Background())
-}
-
-func (p *Process) TerminalWithContext(ctx context.Context) (string, error) {
- k, err := p.getKProc()
- if err != nil {
- return "", err
- }
-
- ttyNr := uint64(k.Tdev)
-
- termmap, err := getTerminalMap()
- if err != nil {
- return "", err
- }
-
- return termmap[ttyNr], nil
-}
-func (p *Process) Nice() (int32, error) {
- return p.NiceWithContext(context.Background())
-}
-
-func (p *Process) NiceWithContext(ctx context.Context) (int32, error) {
- k, err := p.getKProc()
- if err != nil {
- return 0, err
- }
- return int32(k.Nice), nil
-}
-func (p *Process) IOnice() (int32, error) {
- return p.IOniceWithContext(context.Background())
-}
-
-func (p *Process) IOniceWithContext(ctx context.Context) (int32, error) {
- return 0, common.ErrNotImplementedError
-}
-func (p *Process) Rlimit() ([]RlimitStat, error) {
- return p.RlimitWithContext(context.Background())
-}
-
-func (p *Process) RlimitWithContext(ctx context.Context) ([]RlimitStat, error) {
- var rlimit []RlimitStat
- return rlimit, common.ErrNotImplementedError
-}
-func (p *Process) RlimitUsage(gatherUsed bool) ([]RlimitStat, error) {
- return p.RlimitUsageWithContext(context.Background(), gatherUsed)
-}
-
-func (p *Process) RlimitUsageWithContext(ctx context.Context, gatherUsed bool) ([]RlimitStat, error) {
- var rlimit []RlimitStat
- return rlimit, common.ErrNotImplementedError
-}
-func (p *Process) IOCounters() (*IOCountersStat, error) {
- return p.IOCountersWithContext(context.Background())
-}
-
-func (p *Process) IOCountersWithContext(ctx context.Context) (*IOCountersStat, error) {
- k, err := p.getKProc()
- if err != nil {
- return nil, err
- }
- return &IOCountersStat{
- ReadCount: uint64(k.Uru_inblock),
- WriteCount: uint64(k.Uru_oublock),
- }, nil
-}
-func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error) {
- return p.NumCtxSwitchesWithContext(context.Background())
-}
-
-func (p *Process) NumCtxSwitchesWithContext(ctx context.Context) (*NumCtxSwitchesStat, error) {
- return nil, common.ErrNotImplementedError
-}
-func (p *Process) NumFDs() (int32, error) {
- return p.NumFDsWithContext(context.Background())
-}
-
-func (p *Process) NumFDsWithContext(ctx context.Context) (int32, error) {
- return 0, common.ErrNotImplementedError
-}
-func (p *Process) NumThreads() (int32, error) {
- return p.NumThreadsWithContext(context.Background())
-}
-
-func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) {
- /* not supported, just return 1 */
- return 1, nil
-}
-func (p *Process) Threads() (map[int32]*cpu.TimesStat, error) {
- return p.ThreadsWithContext(context.Background())
-}
-
-func (p *Process) ThreadsWithContext(ctx context.Context) (map[int32]*cpu.TimesStat, error) {
- ret := make(map[int32]*cpu.TimesStat)
- return ret, common.ErrNotImplementedError
-}
-func (p *Process) Times() (*cpu.TimesStat, error) {
- return p.TimesWithContext(context.Background())
-}
-
-func (p *Process) TimesWithContext(ctx context.Context) (*cpu.TimesStat, error) {
- k, err := p.getKProc()
- if err != nil {
- return nil, err
- }
- return &cpu.TimesStat{
- CPU: "cpu",
- User: float64(k.Uutime_sec) + float64(k.Uutime_usec)/1000000,
- System: float64(k.Ustime_sec) + float64(k.Ustime_usec)/1000000,
- }, nil
-}
-func (p *Process) CPUAffinity() ([]int32, error) {
- return p.CPUAffinityWithContext(context.Background())
-}
-
-func (p *Process) CPUAffinityWithContext(ctx context.Context) ([]int32, error) {
- return nil, common.ErrNotImplementedError
-}
-func (p *Process) MemoryInfo() (*MemoryInfoStat, error) {
- return p.MemoryInfoWithContext(context.Background())
-}
-
-func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, error) {
- k, err := p.getKProc()
- if err != nil {
- return nil, err
- }
- pageSize, err := mem.GetPageSize()
- if err != nil {
- return nil, err
- }
-
- return &MemoryInfoStat{
- RSS: uint64(k.Vm_rssize) * pageSize,
- VMS: uint64(k.Vm_tsize) + uint64(k.Vm_dsize) +
- uint64(k.Vm_ssize),
- }, nil
-}
-func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error) {
- return p.MemoryInfoExWithContext(context.Background())
-}
-
-func (p *Process) MemoryInfoExWithContext(ctx context.Context) (*MemoryInfoExStat, error) {
- return nil, common.ErrNotImplementedError
-}
-
-func (p *Process) Children() ([]*Process, error) {
- return p.ChildrenWithContext(context.Background())
-}
-
-func (p *Process) ChildrenWithContext(ctx context.Context) ([]*Process, error) {
- pids, err := common.CallPgrepWithContext(ctx, invoke, p.Pid)
- if err != nil {
- return nil, err
- }
- ret := make([]*Process, 0, len(pids))
- for _, pid := range pids {
- np, err := NewProcess(pid)
- if err != nil {
- return nil, err
- }
- ret = append(ret, np)
- }
- return ret, nil
-}
-
-func (p *Process) OpenFiles() ([]OpenFilesStat, error) {
- return p.OpenFilesWithContext(context.Background())
-}
-
-func (p *Process) OpenFilesWithContext(ctx context.Context) ([]OpenFilesStat, error) {
- return nil, common.ErrNotImplementedError
-}
-
-func (p *Process) Connections() ([]net.ConnectionStat, error) {
- return p.ConnectionsWithContext(context.Background())
-}
-
-func (p *Process) ConnectionsWithContext(ctx context.Context) ([]net.ConnectionStat, error) {
- return nil, common.ErrNotImplementedError
-}
-
-func (p *Process) NetIOCounters(pernic bool) ([]net.IOCountersStat, error) {
- return p.NetIOCountersWithContext(context.Background(), pernic)
-}
-
-func (p *Process) NetIOCountersWithContext(ctx context.Context, pernic bool) ([]net.IOCountersStat, error) {
- return nil, common.ErrNotImplementedError
-}
-
-func (p *Process) IsRunning() (bool, error) {
- return p.IsRunningWithContext(context.Background())
-}
-
-func (p *Process) IsRunningWithContext(ctx context.Context) (bool, error) {
- return true, common.ErrNotImplementedError
-}
-func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error) {
- return p.MemoryMapsWithContext(context.Background(), grouped)
-}
-
-func (p *Process) MemoryMapsWithContext(ctx context.Context, grouped bool) (*[]MemoryMapsStat, error) {
- var ret []MemoryMapsStat
- return &ret, common.ErrNotImplementedError
-}
-
-func Processes() ([]*Process, error) {
- return ProcessesWithContext(context.Background())
-}
-
-func ProcessesWithContext(ctx context.Context) ([]*Process, error) {
- results := []*Process{}
-
- buf, length, err := CallKernProcSyscall(KernProcAll, 0)
-
- if err != nil {
- return results, err
- }
-
- // get kinfo_proc size
- count := int(length / uint64(sizeOfKinfoProc))
-
- // parse buf to procs
- for i := 0; i < count; i++ {
- b := buf[i*sizeOfKinfoProc : (i+1)*sizeOfKinfoProc]
- k, err := parseKinfoProc(b)
- if err != nil {
- continue
- }
- p, err := NewProcess(int32(k.Pid))
- if err != nil {
- continue
- }
-
- results = append(results, p)
- }
-
- return results, nil
-}
-
-func parseKinfoProc(buf []byte) (KinfoProc, error) {
- var k KinfoProc
- br := bytes.NewReader(buf)
- err := common.Read(br, binary.LittleEndian, &k)
- return k, err
-}
-
-func (p *Process) getKProc() (*KinfoProc, error) {
- return p.getKProcWithContext(context.Background())
-}
-
-func (p *Process) getKProcWithContext(ctx context.Context) (*KinfoProc, error) {
- buf, length, err := CallKernProcSyscall(KernProcPID, p.Pid)
- if err != nil {
- return nil, err
- }
- if length != sizeOfKinfoProc {
- return nil, err
- }
-
- k, err := parseKinfoProc(buf)
- if err != nil {
- return nil, err
- }
- return &k, nil
-}
-
-func NewProcess(pid int32) (*Process, error) {
- p := &Process{Pid: pid}
-
- return p, nil
-}
-
-func CallKernProcSyscall(op int32, arg int32) ([]byte, uint64, error) {
- return CallKernProcSyscallWithContext(context.Background(), op, arg)
-}
-
-func CallKernProcSyscallWithContext(ctx context.Context, op int32, arg int32) ([]byte, uint64, error) {
- mib := []int32{CTLKern, KernProc, op, arg, sizeOfKinfoProc, 0}
- mibptr := unsafe.Pointer(&mib[0])
- miblen := uint64(len(mib))
- length := uint64(0)
- _, _, err := unix.Syscall6(
- unix.SYS___SYSCTL,
- uintptr(mibptr),
- uintptr(miblen),
- 0,
- uintptr(unsafe.Pointer(&length)),
- 0,
- 0)
- if err != 0 {
- return nil, length, err
- }
-
- count := int32(length / uint64(sizeOfKinfoProc))
- mib = []int32{CTLKern, KernProc, op, arg, sizeOfKinfoProc, count}
- mibptr = unsafe.Pointer(&mib[0])
- miblen = uint64(len(mib))
- // get proc info itself
- buf := make([]byte, length)
- _, _, err = unix.Syscall6(
- unix.SYS___SYSCTL,
- uintptr(mibptr),
- uintptr(miblen),
- uintptr(unsafe.Pointer(&buf[0])),
- uintptr(unsafe.Pointer(&length)),
- 0,
- 0)
- if err != 0 {
- return buf, length, err
- }
-
- return buf, length, nil
-}
diff --git a/vendor/github.com/shirou/gopsutil/process/process_openbsd_amd64.go b/vendor/github.com/shirou/gopsutil/process/process_openbsd_amd64.go
deleted file mode 100644
index 8607422..0000000
--- a/vendor/github.com/shirou/gopsutil/process/process_openbsd_amd64.go
+++ /dev/null
@@ -1,200 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_openbsd.go
-
-package process
-
-const (
- CTLKern = 1
- KernProc = 66
- KernProcAll = 0
- KernProcPID = 1
- KernProcProc = 8
- KernProcPathname = 12
- KernProcArgs = 55
- KernProcArgv = 1
- KernProcEnv = 3
-)
-
-const (
- ArgMax = 256 * 1024
-)
-
-const (
- sizeofPtr = 0x8
- sizeofShort = 0x2
- sizeofInt = 0x4
- sizeofLong = 0x8
- sizeofLongLong = 0x8
-)
-
-const (
- sizeOfKinfoVmentry = 0x50
- sizeOfKinfoProc = 0x268
-)
-
-const (
- SIDL = 1
- SRUN = 2
- SSLEEP = 3
- SSTOP = 4
- SZOMB = 5
- SDEAD = 6
- SONPROC = 7
-)
-
-type (
- _C_short int16
- _C_int int32
- _C_long int64
- _C_long_long int64
-)
-
-type Timespec struct {
- Sec int64
- Nsec int64
-}
-
-type Timeval struct {
- Sec int64
- Usec int64
-}
-
-type Rusage struct {
- Utime Timeval
- Stime Timeval
- Maxrss int64
- Ixrss int64
- Idrss int64
- Isrss int64
- Minflt int64
- Majflt int64
- Nswap int64
- Inblock int64
- Oublock int64
- Msgsnd int64
- Msgrcv int64
- Nsignals int64
- Nvcsw int64
- Nivcsw int64
-}
-
-type Rlimit struct {
- Cur uint64
- Max uint64
-}
-
-type KinfoProc struct {
- Forw uint64
- Back uint64
- Paddr uint64
- Addr uint64
- Fd uint64
- Stats uint64
- Limit uint64
- Vmspace uint64
- Sigacts uint64
- Sess uint64
- Tsess uint64
- Ru uint64
- Eflag int32
- Exitsig int32
- Flag int32
- Pid int32
- Ppid int32
- Sid int32
- X_pgid int32
- Tpgid int32
- Uid uint32
- Ruid uint32
- Gid uint32
- Rgid uint32
- Groups [16]uint32
- Ngroups int16
- Jobc int16
- Tdev uint32
- Estcpu uint32
- Rtime_sec uint32
- Rtime_usec uint32
- Cpticks int32
- Pctcpu uint32
- Swtime uint32
- Slptime uint32
- Schedflags int32
- Uticks uint64
- Sticks uint64
- Iticks uint64
- Tracep uint64
- Traceflag int32
- Holdcnt int32
- Siglist int32
- Sigmask uint32
- Sigignore uint32
- Sigcatch uint32
- Stat int8
- Priority uint8
- Usrpri uint8
- Nice uint8
- Xstat uint16
- Acflag uint16
- Comm [24]int8
- Wmesg [8]int8
- Wchan uint64
- Login [32]int8
- Vm_rssize int32
- Vm_tsize int32
- Vm_dsize int32
- Vm_ssize int32
- Uvalid int64
- Ustart_sec uint64
- Ustart_usec uint32
- Uutime_sec uint32
- Uutime_usec uint32
- Ustime_sec uint32
- Ustime_usec uint32
- Pad_cgo_0 [4]byte
- Uru_maxrss uint64
- Uru_ixrss uint64
- Uru_idrss uint64
- Uru_isrss uint64
- Uru_minflt uint64
- Uru_majflt uint64
- Uru_nswap uint64
- Uru_inblock uint64
- Uru_oublock uint64
- Uru_msgsnd uint64
- Uru_msgrcv uint64
- Uru_nsignals uint64
- Uru_nvcsw uint64
- Uru_nivcsw uint64
- Uctime_sec uint32
- Uctime_usec uint32
- Psflags int32
- Spare int32
- Svuid uint32
- Svgid uint32
- Emul [8]int8
- Rlim_rss_cur uint64
- Cpuid uint64
- Vm_map_size uint64
- Tid int32
- Rtableid uint32
-}
-
-type Priority struct{}
-
-type KinfoVmentry struct {
- Start uint64
- End uint64
- Guard uint64
- Fspace uint64
- Fspace_augment uint64
- Offset uint64
- Wired_count int32
- Etype int32
- Protection int32
- Max_protection int32
- Advice int32
- Inheritance int32
- Flags uint8
- Pad_cgo_0 [7]byte
-}
diff --git a/vendor/github.com/shirou/gopsutil/process/process_posix.go b/vendor/github.com/shirou/gopsutil/process/process_posix.go
deleted file mode 100644
index 8ffb6b7..0000000
--- a/vendor/github.com/shirou/gopsutil/process/process_posix.go
+++ /dev/null
@@ -1,146 +0,0 @@
-// +build linux freebsd openbsd darwin
-
-package process
-
-import (
- "context"
- "os"
- "os/user"
- "path/filepath"
- "strconv"
- "strings"
- "syscall"
-
- "golang.org/x/sys/unix"
-)
-
-// POSIX
-func getTerminalMap() (map[uint64]string, error) {
- ret := make(map[uint64]string)
- var termfiles []string
-
- d, err := os.Open("/dev")
- if err != nil {
- return nil, err
- }
- defer d.Close()
-
- devnames, err := d.Readdirnames(-1)
- if err != nil {
- return nil, err
- }
- for _, devname := range devnames {
- if strings.HasPrefix(devname, "/dev/tty") {
- termfiles = append(termfiles, "/dev/tty/"+devname)
- }
- }
-
- var ptsnames []string
- ptsd, err := os.Open("/dev/pts")
- if err != nil {
- ptsnames, _ = filepath.Glob("/dev/ttyp*")
- if ptsnames == nil {
- return nil, err
- }
- }
- defer ptsd.Close()
-
- if ptsnames == nil {
- defer ptsd.Close()
- ptsnames, err = ptsd.Readdirnames(-1)
- if err != nil {
- return nil, err
- }
- for _, ptsname := range ptsnames {
- termfiles = append(termfiles, "/dev/pts/"+ptsname)
- }
- } else {
- termfiles = ptsnames
- }
-
- for _, name := range termfiles {
- stat := unix.Stat_t{}
- if err = unix.Stat(name, &stat); err != nil {
- return nil, err
- }
- rdev := uint64(stat.Rdev)
- ret[rdev] = strings.Replace(name, "/dev", "", -1)
- }
- return ret, nil
-}
-
-// SendSignal sends a unix.Signal to the process.
-// Currently, SIGSTOP, SIGCONT, SIGTERM and SIGKILL are supported.
-func (p *Process) SendSignal(sig syscall.Signal) error {
- return p.SendSignalWithContext(context.Background(), sig)
-}
-
-func (p *Process) SendSignalWithContext(ctx context.Context, sig syscall.Signal) error {
- process, err := os.FindProcess(int(p.Pid))
- if err != nil {
- return err
- }
-
- err = process.Signal(sig)
- if err != nil {
- return err
- }
-
- return nil
-}
-
-// Suspend sends SIGSTOP to the process.
-func (p *Process) Suspend() error {
- return p.SuspendWithContext(context.Background())
-}
-
-func (p *Process) SuspendWithContext(ctx context.Context) error {
- return p.SendSignal(unix.SIGSTOP)
-}
-
-// Resume sends SIGCONT to the process.
-func (p *Process) Resume() error {
- return p.ResumeWithContext(context.Background())
-}
-
-func (p *Process) ResumeWithContext(ctx context.Context) error {
- return p.SendSignal(unix.SIGCONT)
-}
-
-// Terminate sends SIGTERM to the process.
-func (p *Process) Terminate() error {
- return p.TerminateWithContext(context.Background())
-}
-
-func (p *Process) TerminateWithContext(ctx context.Context) error {
- return p.SendSignal(unix.SIGTERM)
-}
-
-// Kill sends SIGKILL to the process.
-func (p *Process) Kill() error {
- return p.KillWithContext(context.Background())
-}
-
-func (p *Process) KillWithContext(ctx context.Context) error {
- return p.SendSignal(unix.SIGKILL)
-}
-
-// Username returns a username of the process.
-func (p *Process) Username() (string, error) {
- return p.UsernameWithContext(context.Background())
-}
-
-func (p *Process) UsernameWithContext(ctx context.Context) (string, error) {
- uids, err := p.Uids()
- if err != nil {
- return "", err
- }
- if len(uids) > 0 {
- u, err := user.LookupId(strconv.Itoa(int(uids[0])))
- if err != nil {
- return "", err
- }
- return u.Username, nil
- }
- return "", nil
-}
diff --git a/vendor/github.com/shirou/gopsutil/process/process_windows.go b/vendor/github.com/shirou/gopsutil/process/process_windows.go
deleted file mode 100644
index 613b2b4..0000000
--- a/vendor/github.com/shirou/gopsutil/process/process_windows.go
+++ /dev/null
@@ -1,710 +0,0 @@
-// +build windows
-
-package process
-
-import (
- "context"
- "fmt"
- "os"
- "strings"
- "syscall"
- "time"
- "unsafe"
-
- "github.com/StackExchange/wmi"
- cpu "github.com/shirou/gopsutil/cpu"
- "github.com/shirou/gopsutil/internal/common"
- net "github.com/shirou/gopsutil/net"
- "github.com/shirou/w32"
- "golang.org/x/sys/windows"
-)
-
-const (
- NoMoreFiles = 0x12
- MaxPathLength = 260
-)
-
-var (
- modpsapi = windows.NewLazyDLL("psapi.dll")
- procGetProcessMemoryInfo = modpsapi.NewProc("GetProcessMemoryInfo")
-)
-
-type SystemProcessInformation struct {
- NextEntryOffset uint64
- NumberOfThreads uint64
- Reserved1 [48]byte
- Reserved2 [3]byte
- UniqueProcessID uintptr
- Reserved3 uintptr
- HandleCount uint64
- Reserved4 [4]byte
- Reserved5 [11]byte
- PeakPagefileUsage uint64
- PrivatePageCount uint64
- Reserved6 [6]uint64
-}
-
-// Memory_info_ex is different between OSes
-type MemoryInfoExStat struct {
-}
-
-type MemoryMapsStat struct {
-}
-
-type Win32_Process struct {
- Name string
- ExecutablePath *string
- CommandLine *string
- Priority uint32
- CreationDate *time.Time
- ProcessID uint32
- ThreadCount uint32
- Status *string
- ReadOperationCount uint64
- ReadTransferCount uint64
- WriteOperationCount uint64
- WriteTransferCount uint64
- CSCreationClassName string
- CSName string
- Caption *string
- CreationClassName string
- Description *string
- ExecutionState *uint16
- HandleCount uint32
- KernelModeTime uint64
- MaximumWorkingSetSize *uint32
- MinimumWorkingSetSize *uint32
- OSCreationClassName string
- OSName string
- OtherOperationCount uint64
- OtherTransferCount uint64
- PageFaults uint32
- PageFileUsage uint32
- ParentProcessID uint32
- PeakPageFileUsage uint32
- PeakVirtualSize uint64
- PeakWorkingSetSize uint32
- PrivatePageCount uint64
- TerminationDate *time.Time
- UserModeTime uint64
- WorkingSetSize uint64
-}
-
-func init() {
- wmi.DefaultClient.AllowMissingFields = true
-}
-
-func Pids() ([]int32, error) {
- return PidsWithContext(context.Background())
-}
-
-func PidsWithContext(ctx context.Context) ([]int32, error) {
- // inspired by https://gist.github.com/henkman/3083408
- // and https://github.com/giampaolo/psutil/blob/1c3a15f637521ba5c0031283da39c733fda53e4c/psutil/arch/windows/process_info.c#L315-L329
- var ret []int32
- var read uint32 = 0
- var psSize uint32 = 1024
- const dwordSize uint32 = 4
-
- for {
- ps := make([]uint32, psSize)
- if !w32.EnumProcesses(ps, uint32(len(ps)), &read) {
- return nil, fmt.Errorf("could not get w32.EnumProcesses")
- }
- if uint32(len(ps)) == read { // ps buffer was too small to host every results, retry with a bigger one
- psSize += 1024
- continue
- }
- for _, pid := range ps[:read/dwordSize] {
- ret = append(ret, int32(pid))
- }
- return ret, nil
-
- }
-
-}
-
-func (p *Process) Ppid() (int32, error) {
- return p.PpidWithContext(context.Background())
-}
-
-func (p *Process) PpidWithContext(ctx context.Context) (int32, error) {
- ppid, _, _, err := getFromSnapProcess(p.Pid)
- if err != nil {
- return 0, err
- }
- return ppid, nil
-}
-
-func GetWin32Proc(pid int32) ([]Win32_Process, error) {
- return GetWin32ProcWithContext(context.Background(), pid)
-}
-
-func GetWin32ProcWithContext(ctx context.Context, pid int32) ([]Win32_Process, error) {
- var dst []Win32_Process
- query := fmt.Sprintf("WHERE ProcessId = %d", pid)
- q := wmi.CreateQuery(&dst, query)
- err := common.WMIQueryWithContext(ctx, q, &dst)
- if err != nil {
- return []Win32_Process{}, fmt.Errorf("could not get win32Proc: %s", err)
- }
-
- if len(dst) == 0 {
- return []Win32_Process{}, fmt.Errorf("could not get win32Proc: empty")
- }
-
- return dst, nil
-}
-
-func (p *Process) Name() (string, error) {
- return p.NameWithContext(context.Background())
-}
-
-func (p *Process) NameWithContext(ctx context.Context) (string, error) {
- _, _, name, err := getFromSnapProcess(p.Pid)
- if err != nil {
- return "", fmt.Errorf("could not get Name: %s", err)
- }
- return name, nil
-}
-
-func (p *Process) Tgid() (int32, error) {
- return 0, common.ErrNotImplementedError
-}
-
-func (p *Process) Exe() (string, error) {
- return p.ExeWithContext(context.Background())
-}
-
-func (p *Process) ExeWithContext(ctx context.Context) (string, error) {
- dst, err := GetWin32Proc(p.Pid)
- if err != nil {
- return "", fmt.Errorf("could not get ExecutablePath: %s", err)
- }
- return *dst[0].ExecutablePath, nil
-}
-
-func (p *Process) Cmdline() (string, error) {
- return p.CmdlineWithContext(context.Background())
-}
-
-func (p *Process) CmdlineWithContext(ctx context.Context) (string, error) {
- dst, err := GetWin32Proc(p.Pid)
- if err != nil {
- return "", fmt.Errorf("could not get CommandLine: %s", err)
- }
- return *dst[0].CommandLine, nil
-}
-
-// CmdlineSlice returns the command line arguments of the process as a slice with each
-// element being an argument. This merely returns the CommandLine informations passed
-// to the process split on the 0x20 ASCII character.
-func (p *Process) CmdlineSlice() ([]string, error) {
- return p.CmdlineSliceWithContext(context.Background())
-}
-
-func (p *Process) CmdlineSliceWithContext(ctx context.Context) ([]string, error) {
- cmdline, err := p.Cmdline()
- if err != nil {
- return nil, err
- }
- return strings.Split(cmdline, " "), nil
-}
-
-func (p *Process) CreateTime() (int64, error) {
- return p.CreateTimeWithContext(context.Background())
-}
-
-func (p *Process) CreateTimeWithContext(ctx context.Context) (int64, error) {
- ru, err := getRusage(p.Pid)
- if err != nil {
- return 0, fmt.Errorf("could not get CreationDate: %s", err)
- }
-
- return ru.CreationTime.Nanoseconds() / 1000000, nil
-}
-
-func (p *Process) Cwd() (string, error) {
- return p.CwdWithContext(context.Background())
-}
-
-func (p *Process) CwdWithContext(ctx context.Context) (string, error) {
- return "", common.ErrNotImplementedError
-}
-func (p *Process) Parent() (*Process, error) {
- return p.ParentWithContext(context.Background())
-}
-
-func (p *Process) ParentWithContext(ctx context.Context) (*Process, error) {
- ppid, err := p.PpidWithContext(ctx)
- if err != nil {
- return nil, fmt.Errorf("could not get ParentProcessID: %s", err)
- }
-
- return NewProcess(ppid)
-}
-func (p *Process) Status() (string, error) {
- return p.StatusWithContext(context.Background())
-}
-
-func (p *Process) StatusWithContext(ctx context.Context) (string, error) {
- return "", common.ErrNotImplementedError
-}
-func (p *Process) Username() (string, error) {
- return p.UsernameWithContext(context.Background())
-}
-
-func (p *Process) UsernameWithContext(ctx context.Context) (string, error) {
- pid := p.Pid
- // 0x1000 is PROCESS_QUERY_LIMITED_INFORMATION
- c, err := syscall.OpenProcess(0x1000, false, uint32(pid))
- if err != nil {
- return "", err
- }
- defer syscall.CloseHandle(c)
-
- var token syscall.Token
- err = syscall.OpenProcessToken(c, syscall.TOKEN_QUERY, &token)
- if err != nil {
- return "", err
- }
- defer token.Close()
- tokenUser, err := token.GetTokenUser()
- if err != nil {
- return "", err
- }
-
- user, domain, _, err := tokenUser.User.Sid.LookupAccount("")
- return domain + "\\" + user, err
-}
-
-func (p *Process) Uids() ([]int32, error) {
- return p.UidsWithContext(context.Background())
-}
-
-func (p *Process) UidsWithContext(ctx context.Context) ([]int32, error) {
- var uids []int32
-
- return uids, common.ErrNotImplementedError
-}
-func (p *Process) Gids() ([]int32, error) {
- return p.GidsWithContext(context.Background())
-}
-
-func (p *Process) GidsWithContext(ctx context.Context) ([]int32, error) {
- var gids []int32
- return gids, common.ErrNotImplementedError
-}
-func (p *Process) Terminal() (string, error) {
- return p.TerminalWithContext(context.Background())
-}
-
-func (p *Process) TerminalWithContext(ctx context.Context) (string, error) {
- return "", common.ErrNotImplementedError
-}
-
-// Nice returns priority in Windows
-func (p *Process) Nice() (int32, error) {
- return p.NiceWithContext(context.Background())
-}
-
-func (p *Process) NiceWithContext(ctx context.Context) (int32, error) {
- dst, err := GetWin32Proc(p.Pid)
- if err != nil {
- return 0, fmt.Errorf("could not get Priority: %s", err)
- }
- return int32(dst[0].Priority), nil
-}
-func (p *Process) IOnice() (int32, error) {
- return p.IOniceWithContext(context.Background())
-}
-
-func (p *Process) IOniceWithContext(ctx context.Context) (int32, error) {
- return 0, common.ErrNotImplementedError
-}
-func (p *Process) Rlimit() ([]RlimitStat, error) {
- return p.RlimitWithContext(context.Background())
-}
-
-func (p *Process) RlimitWithContext(ctx context.Context) ([]RlimitStat, error) {
- var rlimit []RlimitStat
-
- return rlimit, common.ErrNotImplementedError
-}
-func (p *Process) RlimitUsage(gatherUsed bool) ([]RlimitStat, error) {
- return p.RlimitUsageWithContext(context.Background(), gatherUsed)
-}
-
-func (p *Process) RlimitUsageWithContext(ctx context.Context, gatherUsed bool) ([]RlimitStat, error) {
- var rlimit []RlimitStat
-
- return rlimit, common.ErrNotImplementedError
-}
-
-func (p *Process) IOCounters() (*IOCountersStat, error) {
- return p.IOCountersWithContext(context.Background())
-}
-
-func (p *Process) IOCountersWithContext(ctx context.Context) (*IOCountersStat, error) {
- dst, err := GetWin32Proc(p.Pid)
- if err != nil || len(dst) == 0 {
- return nil, fmt.Errorf("could not get Win32Proc: %s", err)
- }
- ret := &IOCountersStat{
- ReadCount: uint64(dst[0].ReadOperationCount),
- ReadBytes: uint64(dst[0].ReadTransferCount),
- WriteCount: uint64(dst[0].WriteOperationCount),
- WriteBytes: uint64(dst[0].WriteTransferCount),
- }
-
- return ret, nil
-}
-func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error) {
- return p.NumCtxSwitchesWithContext(context.Background())
-}
-
-func (p *Process) NumCtxSwitchesWithContext(ctx context.Context) (*NumCtxSwitchesStat, error) {
- return nil, common.ErrNotImplementedError
-}
-func (p *Process) NumFDs() (int32, error) {
- return p.NumFDsWithContext(context.Background())
-}
-
-func (p *Process) NumFDsWithContext(ctx context.Context) (int32, error) {
- return 0, common.ErrNotImplementedError
-}
-func (p *Process) NumThreads() (int32, error) {
- return p.NumThreadsWithContext(context.Background())
-}
-
-func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) {
- dst, err := GetWin32Proc(p.Pid)
- if err != nil {
- return 0, fmt.Errorf("could not get ThreadCount: %s", err)
- }
- return int32(dst[0].ThreadCount), nil
-}
-func (p *Process) Threads() (map[int32]*cpu.TimesStat, error) {
- return p.ThreadsWithContext(context.Background())
-}
-
-func (p *Process) ThreadsWithContext(ctx context.Context) (map[int32]*cpu.TimesStat, error) {
- ret := make(map[int32]*cpu.TimesStat)
- return ret, common.ErrNotImplementedError
-}
-func (p *Process) Times() (*cpu.TimesStat, error) {
- return p.TimesWithContext(context.Background())
-}
-
-func (p *Process) TimesWithContext(ctx context.Context) (*cpu.TimesStat, error) {
- sysTimes, err := getProcessCPUTimes(p.Pid)
- if err != nil {
- return nil, err
- }
-
- // User and kernel times are represented as a FILETIME structure
- // which contains a 64-bit value representing the number of
- // 100-nanosecond intervals since January 1, 1601 (UTC):
- // http://msdn.microsoft.com/en-us/library/ms724284(VS.85).aspx
- // To convert it into a float representing the seconds that the
- // process has executed in user/kernel mode I borrowed the code
- // below from psutil's _psutil_windows.c, and in turn from Python's
- // Modules/posixmodule.c
-
- user := float64(sysTimes.UserTime.HighDateTime)*429.4967296 + float64(sysTimes.UserTime.LowDateTime)*1e-7
- kernel := float64(sysTimes.KernelTime.HighDateTime)*429.4967296 + float64(sysTimes.KernelTime.LowDateTime)*1e-7
-
- return &cpu.TimesStat{
- User: user,
- System: kernel,
- }, nil
-}
-func (p *Process) CPUAffinity() ([]int32, error) {
- return p.CPUAffinityWithContext(context.Background())
-}
-
-func (p *Process) CPUAffinityWithContext(ctx context.Context) ([]int32, error) {
- return nil, common.ErrNotImplementedError
-}
-func (p *Process) MemoryInfo() (*MemoryInfoStat, error) {
- return p.MemoryInfoWithContext(context.Background())
-}
-
-func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, error) {
- mem, err := getMemoryInfo(p.Pid)
- if err != nil {
- return nil, err
- }
-
- ret := &MemoryInfoStat{
- RSS: uint64(mem.WorkingSetSize),
- VMS: uint64(mem.PagefileUsage),
- }
-
- return ret, nil
-}
-func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error) {
- return p.MemoryInfoExWithContext(context.Background())
-}
-
-func (p *Process) MemoryInfoExWithContext(ctx context.Context) (*MemoryInfoExStat, error) {
- return nil, common.ErrNotImplementedError
-}
-
-func (p *Process) Children() ([]*Process, error) {
- return p.ChildrenWithContext(context.Background())
-}
-
-func (p *Process) ChildrenWithContext(ctx context.Context) ([]*Process, error) {
- var dst []Win32_Process
- query := wmi.CreateQuery(&dst, fmt.Sprintf("Where ParentProcessId = %d", p.Pid))
- err := common.WMIQueryWithContext(ctx, query, &dst)
- if err != nil {
- return nil, err
- }
-
- out := []*Process{}
- for _, proc := range dst {
- p, err := NewProcess(int32(proc.ProcessID))
- if err != nil {
- continue
- }
- out = append(out, p)
- }
-
- return out, nil
-}
-
-func (p *Process) OpenFiles() ([]OpenFilesStat, error) {
- return p.OpenFilesWithContext(context.Background())
-}
-
-func (p *Process) OpenFilesWithContext(ctx context.Context) ([]OpenFilesStat, error) {
- return nil, common.ErrNotImplementedError
-}
-
-func (p *Process) Connections() ([]net.ConnectionStat, error) {
- return p.ConnectionsWithContext(context.Background())
-}
-
-func (p *Process) ConnectionsWithContext(ctx context.Context) ([]net.ConnectionStat, error) {
- return nil, common.ErrNotImplementedError
-}
-
-func (p *Process) NetIOCounters(pernic bool) ([]net.IOCountersStat, error) {
- return p.NetIOCountersWithContext(context.Background(), pernic)
-}
-
-func (p *Process) NetIOCountersWithContext(ctx context.Context, pernic bool) ([]net.IOCountersStat, error) {
- return nil, common.ErrNotImplementedError
-}
-
-func (p *Process) IsRunning() (bool, error) {
- return p.IsRunningWithContext(context.Background())
-}
-
-func (p *Process) IsRunningWithContext(ctx context.Context) (bool, error) {
- return true, common.ErrNotImplementedError
-}
-
-func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error) {
- return p.MemoryMapsWithContext(context.Background(), grouped)
-}
-
-func (p *Process) MemoryMapsWithContext(ctx context.Context, grouped bool) (*[]MemoryMapsStat, error) {
- var ret []MemoryMapsStat
- return &ret, common.ErrNotImplementedError
-}
-
-func NewProcess(pid int32) (*Process, error) {
- p := &Process{Pid: pid}
-
- return p, nil
-}
-
-func (p *Process) SendSignal(sig windows.Signal) error {
- return p.SendSignalWithContext(context.Background(), sig)
-}
-
-func (p *Process) SendSignalWithContext(ctx context.Context, sig windows.Signal) error {
- return common.ErrNotImplementedError
-}
-
-func (p *Process) Suspend() error {
- return p.SuspendWithContext(context.Background())
-}
-
-func (p *Process) SuspendWithContext(ctx context.Context) error {
- return common.ErrNotImplementedError
-}
-func (p *Process) Resume() error {
- return p.ResumeWithContext(context.Background())
-}
-
-func (p *Process) ResumeWithContext(ctx context.Context) error {
- return common.ErrNotImplementedError
-}
-
-func (p *Process) Terminate() error {
- return p.TerminateWithContext(context.Background())
-}
-
-func (p *Process) TerminateWithContext(ctx context.Context) error {
- // PROCESS_TERMINATE = 0x0001
- proc := w32.OpenProcess(0x0001, false, uint32(p.Pid))
- ret := w32.TerminateProcess(proc, 0)
- w32.CloseHandle(proc)
-
- if ret == false {
- return windows.GetLastError()
- } else {
- return nil
- }
-}
-
-func (p *Process) Kill() error {
- return p.KillWithContext(context.Background())
-}
-
-func (p *Process) KillWithContext(ctx context.Context) error {
- process := os.Process{Pid: int(p.Pid)}
- return process.Kill()
-}
-
-func getFromSnapProcess(pid int32) (int32, int32, string, error) {
- snap := w32.CreateToolhelp32Snapshot(w32.TH32CS_SNAPPROCESS, uint32(pid))
- if snap == 0 {
- return 0, 0, "", windows.GetLastError()
- }
- defer w32.CloseHandle(snap)
- var pe32 w32.PROCESSENTRY32
- pe32.DwSize = uint32(unsafe.Sizeof(pe32))
- if w32.Process32First(snap, &pe32) == false {
- return 0, 0, "", windows.GetLastError()
- }
-
- if pe32.Th32ProcessID == uint32(pid) {
- szexe := windows.UTF16ToString(pe32.SzExeFile[:])
- return int32(pe32.Th32ParentProcessID), int32(pe32.CntThreads), szexe, nil
- }
-
- for w32.Process32Next(snap, &pe32) {
- if pe32.Th32ProcessID == uint32(pid) {
- szexe := windows.UTF16ToString(pe32.SzExeFile[:])
- return int32(pe32.Th32ParentProcessID), int32(pe32.CntThreads), szexe, nil
- }
- }
- return 0, 0, "", fmt.Errorf("Couldn't find pid: %d", pid)
-}
-
-// Get processes
-func Processes() ([]*Process, error) {
- return ProcessesWithContext(context.Background())
-}
-
-func ProcessesWithContext(ctx context.Context) ([]*Process, error) {
- pids, err := Pids()
- if err != nil {
- return []*Process{}, fmt.Errorf("could not get Processes %s", err)
- }
-
- results := []*Process{}
- for _, pid := range pids {
- p, err := NewProcess(int32(pid))
- if err != nil {
- continue
- }
- results = append(results, p)
- }
-
- return results, nil
-}
-
-func getProcInfo(pid int32) (*SystemProcessInformation, error) {
- initialBufferSize := uint64(0x4000)
- bufferSize := initialBufferSize
- buffer := make([]byte, bufferSize)
-
- var sysProcInfo SystemProcessInformation
- ret, _, _ := common.ProcNtQuerySystemInformation.Call(
- uintptr(unsafe.Pointer(&sysProcInfo)),
- uintptr(unsafe.Pointer(&buffer[0])),
- uintptr(unsafe.Pointer(&bufferSize)),
- uintptr(unsafe.Pointer(&bufferSize)))
- if ret != 0 {
- return nil, windows.GetLastError()
- }
-
- return &sysProcInfo, nil
-}
-
-func getRusage(pid int32) (*windows.Rusage, error) {
- var CPU windows.Rusage
-
- c, err := windows.OpenProcess(windows.PROCESS_QUERY_INFORMATION, false, uint32(pid))
- if err != nil {
- return nil, err
- }
- defer windows.CloseHandle(c)
-
- if err := windows.GetProcessTimes(c, &CPU.CreationTime, &CPU.ExitTime, &CPU.KernelTime, &CPU.UserTime); err != nil {
- return nil, err
- }
-
- return &CPU, nil
-}
-
-func getMemoryInfo(pid int32) (PROCESS_MEMORY_COUNTERS, error) {
- var mem PROCESS_MEMORY_COUNTERS
- // PROCESS_QUERY_LIMITED_INFORMATION is 0x1000
- c, err := windows.OpenProcess(0x1000, false, uint32(pid))
- if err != nil {
- return mem, err
- }
- defer windows.CloseHandle(c)
- if err := getProcessMemoryInfo(c, &mem); err != nil {
- return mem, err
- }
-
- return mem, err
-}
-
-func getProcessMemoryInfo(h windows.Handle, mem *PROCESS_MEMORY_COUNTERS) (err error) {
- r1, _, e1 := syscall.Syscall(procGetProcessMemoryInfo.Addr(), 3, uintptr(h), uintptr(unsafe.Pointer(mem)), uintptr(unsafe.Sizeof(*mem)))
- if r1 == 0 {
- if e1 != 0 {
- err = error(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-type SYSTEM_TIMES struct {
- CreateTime syscall.Filetime
- ExitTime syscall.Filetime
- KernelTime syscall.Filetime
- UserTime syscall.Filetime
-}
-
-func getProcessCPUTimes(pid int32) (SYSTEM_TIMES, error) {
- var times SYSTEM_TIMES
-
- // PROCESS_QUERY_LIMITED_INFORMATION is 0x1000
- h, err := windows.OpenProcess(0x1000, false, uint32(pid))
- if err != nil {
- return times, err
- }
- defer windows.CloseHandle(h)
-
- err = syscall.GetProcessTimes(
- syscall.Handle(h),
- ×.CreateTime,
- ×.ExitTime,
- ×.KernelTime,
- ×.UserTime,
- )
-
- return times, err
-}
diff --git a/vendor/github.com/shirou/gopsutil/process/process_windows_386.go b/vendor/github.com/shirou/gopsutil/process/process_windows_386.go
deleted file mode 100644
index 68f3153..0000000
--- a/vendor/github.com/shirou/gopsutil/process/process_windows_386.go
+++ /dev/null
@@ -1,16 +0,0 @@
-// +build windows
-
-package process
-
-type PROCESS_MEMORY_COUNTERS struct {
- CB uint32
- PageFaultCount uint32
- PeakWorkingSetSize uint32
- WorkingSetSize uint32
- QuotaPeakPagedPoolUsage uint32
- QuotaPagedPoolUsage uint32
- QuotaPeakNonPagedPoolUsage uint32
- QuotaNonPagedPoolUsage uint32
- PagefileUsage uint32
- PeakPagefileUsage uint32
-}
diff --git a/vendor/github.com/shirou/gopsutil/process/process_windows_amd64.go b/vendor/github.com/shirou/gopsutil/process/process_windows_amd64.go
deleted file mode 100644
index df286df..0000000
--- a/vendor/github.com/shirou/gopsutil/process/process_windows_amd64.go
+++ /dev/null
@@ -1,16 +0,0 @@
-// +build windows
-
-package process
-
-type PROCESS_MEMORY_COUNTERS struct {
- CB uint32
- PageFaultCount uint32
- PeakWorkingSetSize uint64
- WorkingSetSize uint64
- QuotaPeakPagedPoolUsage uint64
- QuotaPagedPoolUsage uint64
- QuotaPeakNonPagedPoolUsage uint64
- QuotaNonPagedPoolUsage uint64
- PagefileUsage uint64
- PeakPagefileUsage uint64
-}
diff --git a/vendor/github.com/shirou/gopsutil/process/types_darwin.go b/vendor/github.com/shirou/gopsutil/process/types_darwin.go
deleted file mode 100644
index 21216cd..0000000
--- a/vendor/github.com/shirou/gopsutil/process/types_darwin.go
+++ /dev/null
@@ -1,160 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Hand Writing
-// - all pointer in ExternProc to uint64
-
-// +build ignore
-
-/*
-Input to cgo -godefs.
-*/
-
-// +godefs map struct_in_addr [4]byte /* in_addr */
-// +godefs map struct_in6_addr [16]byte /* in6_addr */
-// +godefs map struct_ [16]byte /* in6_addr */
-
-package process
-
-/*
-#define __DARWIN_UNIX03 0
-#define KERNEL
-#define _DARWIN_USE_64_BIT_INODE
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-enum {
- sizeofPtr = sizeof(void*),
-};
-
-union sockaddr_all {
- struct sockaddr s1; // this one gets used for fields
- struct sockaddr_in s2; // these pad it out
- struct sockaddr_in6 s3;
- struct sockaddr_un s4;
- struct sockaddr_dl s5;
-};
-
-struct sockaddr_any {
- struct sockaddr addr;
- char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
-};
-
-struct ucred_queue {
- struct ucred *tqe_next;
- struct ucred **tqe_prev;
- TRACEBUF
-};
-
-*/
-import "C"
-
-// Machine characteristics; for internal use.
-
-const (
- sizeofPtr = C.sizeofPtr
- sizeofShort = C.sizeof_short
- sizeofInt = C.sizeof_int
- sizeofLong = C.sizeof_long
- sizeofLongLong = C.sizeof_longlong
-)
-
-// Basic types
-
-type (
- _C_short C.short
- _C_int C.int
- _C_long C.long
- _C_long_long C.longlong
-)
-
-// Time
-
-type Timespec C.struct_timespec
-
-type Timeval C.struct_timeval
-
-// Processes
-
-type Rusage C.struct_rusage
-
-type Rlimit C.struct_rlimit
-
-type UGid_t C.gid_t
-
-type KinfoProc C.struct_kinfo_proc
-
-type Eproc C.struct_eproc
-
-type Proc C.struct_proc
-
-type Session C.struct_session
-
-type ucred C.struct_ucred
-
-type Uucred C.struct__ucred
-
-type Upcred C.struct__pcred
-
-type Vmspace C.struct_vmspace
-
-type Sigacts C.struct_sigacts
-
-type ExternProc C.struct_extern_proc
-
-type Itimerval C.struct_itimerval
-
-type Vnode C.struct_vnode
-
-type Pgrp C.struct_pgrp
-
-type UserStruct C.struct_user
-
-type Au_session C.struct_au_session
-
-type Posix_cred C.struct_posix_cred
-
-type Label C.struct_label
-
-type AuditinfoAddr C.struct_auditinfo_addr
-type AuMask C.struct_au_mask
-type AuTidAddr C.struct_au_tid_addr
-
-// TAILQ(ucred)
-type UcredQueue C.struct_ucred_queue
diff --git a/vendor/github.com/shirou/gopsutil/process/types_freebsd.go b/vendor/github.com/shirou/gopsutil/process/types_freebsd.go
deleted file mode 100644
index aa7b346..0000000
--- a/vendor/github.com/shirou/gopsutil/process/types_freebsd.go
+++ /dev/null
@@ -1,95 +0,0 @@
-// +build ignore
-
-// We still need editing by hands.
-// go tool cgo -godefs types_freebsd.go | sed 's/\*int64/int64/' | sed 's/\*byte/int64/' > process_freebsd_amd64.go
-
-/*
-Input to cgo -godefs.
-*/
-
-// +godefs map struct_pargs int64 /* pargs */
-// +godefs map struct_proc int64 /* proc */
-// +godefs map struct_user int64 /* user */
-// +godefs map struct_vnode int64 /* vnode */
-// +godefs map struct_vnode int64 /* vnode */
-// +godefs map struct_filedesc int64 /* filedesc */
-// +godefs map struct_vmspace int64 /* vmspace */
-// +godefs map struct_pcb int64 /* pcb */
-// +godefs map struct_thread int64 /* thread */
-// +godefs map struct___sigset [16]byte /* sigset */
-
-package process
-
-/*
-#include
-#include
-
-enum {
- sizeofPtr = sizeof(void*),
-};
-
-
-*/
-import "C"
-
-// Machine characteristics; for internal use.
-
-const (
- CTLKern = 1 // "high kernel": proc, limits
- KernProc = 14 // struct: process entries
- KernProcPID = 1 // by process id
- KernProcProc = 8 // only return procs
- KernProcPathname = 12 // path to executable
- KernProcArgs = 7 // get/set arguments/proctitle
-)
-
-const (
- sizeofPtr = C.sizeofPtr
- sizeofShort = C.sizeof_short
- sizeofInt = C.sizeof_int
- sizeofLong = C.sizeof_long
- sizeofLongLong = C.sizeof_longlong
-)
-
-const (
- sizeOfKinfoVmentry = C.sizeof_struct_kinfo_vmentry
- sizeOfKinfoProc = C.sizeof_struct_kinfo_proc
-)
-
-// from sys/proc.h
-const (
- SIDL = 1 /* Process being created by fork. */
- SRUN = 2 /* Currently runnable. */
- SSLEEP = 3 /* Sleeping on an address. */
- SSTOP = 4 /* Process debugging or suspension. */
- SZOMB = 5 /* Awaiting collection by parent. */
- SWAIT = 6 /* Waiting for interrupt. */
- SLOCK = 7 /* Blocked on a lock. */
-)
-
-// Basic types
-
-type (
- _C_short C.short
- _C_int C.int
- _C_long C.long
- _C_long_long C.longlong
-)
-
-// Time
-
-type Timespec C.struct_timespec
-
-type Timeval C.struct_timeval
-
-// Processes
-
-type Rusage C.struct_rusage
-
-type Rlimit C.struct_rlimit
-
-type KinfoProc C.struct_kinfo_proc
-
-type Priority C.struct_priority
-
-type KinfoVmentry C.struct_kinfo_vmentry
diff --git a/vendor/github.com/shirou/gopsutil/process/types_openbsd.go b/vendor/github.com/shirou/gopsutil/process/types_openbsd.go
deleted file mode 100644
index 09ac590..0000000
--- a/vendor/github.com/shirou/gopsutil/process/types_openbsd.go
+++ /dev/null
@@ -1,103 +0,0 @@
-// +build ignore
-
-// We still need editing by hands.
-// go tool cgo -godefs types_openbsd.go | sed 's/\*int64/int64/' | sed 's/\*byte/int64/' > process_openbsd_amd64.go
-
-/*
-Input to cgo -godefs.
-*/
-
-// +godefs map struct_pargs int64 /* pargs */
-// +godefs map struct_proc int64 /* proc */
-// +godefs map struct_user int64 /* user */
-// +godefs map struct_vnode int64 /* vnode */
-// +godefs map struct_vnode int64 /* vnode */
-// +godefs map struct_filedesc int64 /* filedesc */
-// +godefs map struct_vmspace int64 /* vmspace */
-// +godefs map struct_pcb int64 /* pcb */
-// +godefs map struct_thread int64 /* thread */
-// +godefs map struct___sigset [16]byte /* sigset */
-
-package process
-
-/*
-#include
-#include
-#include
-
-enum {
- sizeofPtr = sizeof(void*),
-};
-
-
-*/
-import "C"
-
-// Machine characteristics; for internal use.
-
-const (
- CTLKern = 1 // "high kernel": proc, limits
- KernProc = 66 // struct: process entries
- KernProcAll = 0
- KernProcPID = 1 // by process id
- KernProcProc = 8 // only return procs
- KernProcPathname = 12 // path to executable
- KernProcArgs = 55 // get/set arguments/proctitle
- KernProcArgv = 1
- KernProcEnv = 3
-)
-
-const (
- ArgMax = 256 * 1024 // sys/syslimits.h:#define ARG_MAX
-)
-
-const (
- sizeofPtr = C.sizeofPtr
- sizeofShort = C.sizeof_short
- sizeofInt = C.sizeof_int
- sizeofLong = C.sizeof_long
- sizeofLongLong = C.sizeof_longlong
-)
-
-const (
- sizeOfKinfoVmentry = C.sizeof_struct_kinfo_vmentry
- sizeOfKinfoProc = C.sizeof_struct_kinfo_proc
-)
-
-// from sys/proc.h
-const (
- SIDL = 1 /* Process being created by fork. */
- SRUN = 2 /* Currently runnable. */
- SSLEEP = 3 /* Sleeping on an address. */
- SSTOP = 4 /* Process debugging or suspension. */
- SZOMB = 5 /* Awaiting collection by parent. */
- SDEAD = 6 /* Thread is almost gone */
- SONPROC = 7 /* Thread is currently on a CPU. */
-)
-
-// Basic types
-
-type (
- _C_short C.short
- _C_int C.int
- _C_long C.long
- _C_long_long C.longlong
-)
-
-// Time
-
-type Timespec C.struct_timespec
-
-type Timeval C.struct_timeval
-
-// Processes
-
-type Rusage C.struct_rusage
-
-type Rlimit C.struct_rlimit
-
-type KinfoProc C.struct_kinfo_proc
-
-type Priority C.struct_priority
-
-type KinfoVmentry C.struct_kinfo_vmentry
diff --git a/vendor/github.com/shirou/w32/AUTHORS b/vendor/github.com/shirou/w32/AUTHORS
deleted file mode 100644
index c0785e8..0000000
--- a/vendor/github.com/shirou/w32/AUTHORS
+++ /dev/null
@@ -1,16 +0,0 @@
-# This is the official list of 'w32' authors for copyright purposes.
-
-# Names should be added to this file as
-# Name or Organization