vendor: update all dependencies to latest versions
This commit is contained in:
parent
8e83fb6fb9
commit
7d3a17725d
4878 changed files with 1974229 additions and 201215 deletions
17
vendor/github.com/pengsrc/go-shared/check/dir.go
generated
vendored
Normal file
17
vendor/github.com/pengsrc/go-shared/check/dir.go
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
package check
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Dir checks the given path, will return error if path not exists or path
|
||||
// is not directory.
|
||||
func Dir(path string) error {
|
||||
if info, err := os.Stat(path); err != nil {
|
||||
return fmt.Errorf(`directory not exists: %s`, path)
|
||||
} else if !info.IsDir() {
|
||||
return fmt.Errorf(`path is not directory: %s`, path)
|
||||
}
|
||||
return nil
|
||||
}
|
23
vendor/github.com/pengsrc/go-shared/check/dir_test.go
generated
vendored
Normal file
23
vendor/github.com/pengsrc/go-shared/check/dir_test.go
generated
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
package check
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestCheckDir(t *testing.T) {
|
||||
// Path not exist.
|
||||
assert.Error(t, Dir("/not-exist-dir"))
|
||||
|
||||
// Path is not directory.
|
||||
f, err := ioutil.TempFile(os.TempDir(), "test-check-dir-")
|
||||
assert.NoError(t, err)
|
||||
f.Close()
|
||||
os.Remove(f.Name())
|
||||
|
||||
// OK.
|
||||
assert.NoError(t, Dir(os.TempDir()))
|
||||
}
|
16
vendor/github.com/pengsrc/go-shared/check/error.go
generated
vendored
16
vendor/github.com/pengsrc/go-shared/check/error.go
generated
vendored
|
@ -5,6 +5,22 @@ import (
|
|||
"os"
|
||||
)
|
||||
|
||||
// ReadableError is just a structure contains readable message that can be
|
||||
// returned directly to end user.
|
||||
type ReadableError struct {
|
||||
Message string
|
||||
}
|
||||
|
||||
// Error returns the description of ReadableError.
|
||||
func (e ReadableError) Error() string {
|
||||
return e.Message
|
||||
}
|
||||
|
||||
// NewReadableError creates a ReadableError{} from given message.
|
||||
func NewReadableError(message string) ReadableError {
|
||||
return ReadableError{Message: message}
|
||||
}
|
||||
|
||||
// ErrorForExit check the error.
|
||||
// If error is not nil, print the error message and exit the application.
|
||||
// If error is nil, do nothing.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue