diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..ac83baf --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,32 @@ +name: Go + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + + build: + name: Build + runs-on: ubuntu-latest + steps: + + - name: Set up Go 1.x + uses: actions/setup-go@v2 + with: + go-version: ^1.14 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Get dependencies + run: go get -v -t -d ./... + + - name: Build + run: go build -v ./... + + - name: Test + run: go test -v -race -cover ./... diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 65da59c..0000000 --- a/.travis.yml +++ /dev/null @@ -1,10 +0,0 @@ -sudo: false -language: go -go: 1.8 - -branches: - only: - - master - -install: go get -t ./... github.com/golang/lint/golint -script: make lint test diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..b020f6a --- /dev/null +++ b/go.mod @@ -0,0 +1,8 @@ +module github.com/rodaine/table + +go 1.14 + +require ( + github.com/mattn/go-runewidth v0.0.9 + github.com/stretchr/testify v1.6.1 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..594a526 --- /dev/null +++ b/go.sum @@ -0,0 +1,13 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= +github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/makefile b/makefile deleted file mode 100644 index 56a4288..0000000 --- a/makefile +++ /dev/null @@ -1,9 +0,0 @@ -.PHONY: lint -lint: - gofmt -d -s . - golint -set_exit_status ./... - go tool vet -all -shadow -shadowstrict . - -.PHONY: test -test: - go test -v -cover -race ./... diff --git a/readme.md b/readme.md index 7905aff..4ec9eff 100644 --- a/readme.md +++ b/readme.md @@ -19,7 +19,7 @@ Package table provides a convenient way to generate tabular output of any data, **Download the package:** ```sh -go get -u github.com/rodaine/table +go get github.com/rodaine/table ``` **Example:** @@ -52,10 +52,6 @@ func main() { _Consult the [documentation](https://godoc.org/github.com/rodaine/table) for further examples and usage information_ -## Contributing - -Please feel free to submit an [issue](https://github.com/rodaine/table/issues) or [PR](https://github.com/rodaine/table/pulls) to this repository for features or bugs. All submitted code must pass the scripts specified within [.travis.yml](https://github.com/rodaine/table/blob/master/.travis.yml) and should include tests to back up the changes. - ## License table is released under the MIT License (Expat). See the [full license](https://github.com/rodaine/table/blob/master/license). diff --git a/table.go b/table.go index 76f2e63..e1317c0 100644 --- a/table.go +++ b/table.go @@ -206,7 +206,7 @@ func (t *table) AddRow(vals ...interface{}) Table { func (t *table) Print() { format := strings.Repeat("%s", len(t.header)) + "\n" t.calculateWidths() - fmt.Fprintln(t.Writer) + t.printHeader(format) for _, row := range t.rows { t.printRow(format, row)