terraform/vendor/github.com/likexian/gokit/assert
Li Kexian 76e5b446ba
backend/cos: Add TencentCloud backend cos with lock (#22540)
* add TencentCloud COS backend for remote state

* add vendor of dependence

* fixed error not handle and remove default value for prefix argument

* get appid from TF_COS_APPID environment variables
2020-02-13 11:37:11 -05:00
..
README.md backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00
assert.go backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00
values.go backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00

README.md

GoKit - assert

Assert kits for Golang development.

Installation

go get -u github.com/likexian/gokit

Importing

import (
    "github.com/likexian/gokit/assert"
)

Documentation

Visit the docs on GoDoc

Example

assert panic

func willItPanic() {
    panic("failed")
}
assert.Panic(t, willItPanic)

assert err is nil

fp, err := os.Open("/data/dev/gokit/LICENSE")
assert.Nil(t, err)

assert equal

x := map[string]int{"a": 1, "b": 2}
y := map[string]int{"a": 1, "b": 2}
assert.Equal(t, x, y, "x shall equal to y")

check string in array

ok := assert.IsContains([]string{"a", "b", "c"}, "b")
if ok {
    fmt.Println("value in array")
} else {
    fmt.Println("value not in array")
}

check string in interface array

ok := assert.IsContains([]interface{}{0, "1", 2}, "1")
if ok {
    fmt.Println("value in array")
} else {
    fmt.Println("value not in array")
}

check object in struct array

ok := assert.IsContains([]A{A{0, 1}, A{1, 2}, A{1, 3}}, A{1, 2})
if ok {
    fmt.Println("value in array")
} else {
    fmt.Println("value not in array")
}

a := c ? x : y

a := 1
// b := a == 1 ? true : false
b := assert.If(a == 1, true, false)

LICENSE

Copyright 2012-2019 Li Kexian

Licensed under the Apache License 2.0

About

DONATE