ci: refactor build tools and ci setup (#24)

This commit is contained in:
Robert Kaussow 2022-04-25 12:56:32 +02:00 committed by GitHub
parent 2bd123697f
commit 2404e7aeab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 176 additions and 169 deletions

2
.dockerignore Normal file
View File

@ -0,0 +1,2 @@
*
!dist/

View File

@ -1,6 +1,5 @@
local PipelineTest = {
kind: 'pipeline',
image_pull_secrets: ['docker_config'],
name: 'test',
platform: {
os: 'linux',
@ -8,14 +7,14 @@ local PipelineTest = {
},
steps: [
{
name: 'staticcheck',
name: 'deps',
image: 'golang:1.18',
commands: [
'go run honnef.co/go/tools/cmd/staticcheck ./...',
'make deps',
],
volumes: [
{
name: 'gopath',
name: 'godeps',
path: '/go',
},
],
@ -24,24 +23,11 @@ local PipelineTest = {
name: 'lint',
image: 'golang:1.18',
commands: [
'go run golang.org/x/lint/golint -set_exit_status ./...',
'make lint',
],
volumes: [
{
name: 'gopath',
path: '/go',
},
],
},
{
name: 'vet',
image: 'golang:1.18',
commands: [
'go vet ./...',
],
volumes: [
{
name: 'gopath',
name: 'godeps',
path: '/go',
},
],
@ -50,11 +36,11 @@ local PipelineTest = {
name: 'test',
image: 'golang:1.18',
commands: [
'go test -race -coverprofile=coverage.txt -covermode=atomic ./...',
'make test',
],
volumes: [
{
name: 'gopath',
name: 'godeps',
path: '/go',
},
],
@ -67,14 +53,14 @@ local PipelineTest = {
from_secret: 'codecov_token',
},
files: [
'coverage.txt',
'coverage.out',
],
},
},
],
volumes: [
{
name: 'gopath',
name: 'godeps',
temp: {},
},
],
@ -86,7 +72,6 @@ local PipelineTest = {
local PipelineBuildBinaries = {
kind: 'pipeline',
image_pull_secrets: ['docker_config'],
name: 'build-binaries',
platform: {
os: 'linux',
@ -97,34 +82,14 @@ local PipelineBuildBinaries = {
name: 'build',
image: 'techknowlogick/xgo:go-1.18.x',
commands: [
'[ -z "${DRONE_TAG}" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}',
'mkdir -p release/',
"cd cmd/url-parser && xgo -ldflags \"-s -w -X main.version=$BUILD_VERSION\" -tags netgo -targets 'linux/amd64,linux/arm-6,linux/arm-7,linux/arm64' -out url-parser .",
'mv /build/* /drone/src/release/',
'ls -l /drone/src/release/',
'make release',
],
},
{
name: 'executable',
image: 'alpine',
commands: [
'$(find release/ -executable -type f | grep url-parser-linux-amd64) --help',
],
},
{
name: 'compress',
image: 'alpine',
commands: [
'apk add upx',
'find release/ -maxdepth 1 -executable -type f -exec upx {} \\;',
'ls -lh release/',
],
},
{
name: 'checksum',
image: 'alpine',
commands: [
'cd release/ && sha256sum * > sha256sum.txt',
'$(find dist/ -executable -type f -iname ${DRONE_REPO_NAME}-linux-amd64) --help',
],
},
{
@ -151,7 +116,7 @@ local PipelineBuildBinaries = {
api_key: {
from_secret: 'github_token',
},
files: ['release/*'],
files: ['dist/*'],
title: '${DRONE_TAG}',
note: 'CHANGELOG.md',
},
@ -172,7 +137,6 @@ local PipelineBuildBinaries = {
local PipelineNotifications = {
kind: 'pipeline',
image_pull_secrets: ['docker_config'],
name: 'notifications',
platform: {
os: 'linux',

View File

@ -7,53 +7,42 @@ platform:
arch: amd64
steps:
- name: staticcheck
- name: deps
image: golang:1.18
commands:
- go run honnef.co/go/tools/cmd/staticcheck ./...
- make deps
volumes:
- name: gopath
- name: godeps
path: /go
- name: lint
image: golang:1.18
commands:
- go run golang.org/x/lint/golint -set_exit_status ./...
- make lint
volumes:
- name: gopath
path: /go
- name: vet
image: golang:1.18
commands:
- go vet ./...
volumes:
- name: gopath
- name: godeps
path: /go
- name: test
image: golang:1.18
commands:
- go test -race -coverprofile=coverage.txt -covermode=atomic ./...
- make test
volumes:
- name: gopath
- name: godeps
path: /go
- name: coverage
image: plugins/codecov
settings:
files:
- coverage.txt
- coverage.out
token:
from_secret: codecov_token
volumes:
- name: gopath
- name: godeps
temp: {}
image_pull_secrets:
- docker_config
trigger:
ref:
- refs/heads/main
@ -72,28 +61,12 @@ steps:
- name: build
image: techknowlogick/xgo:go-1.18.x
commands:
- "[ -z \"${DRONE_TAG}\" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}"
- mkdir -p release/
- cd cmd/url-parser && xgo -ldflags "-s -w -X main.version=$BUILD_VERSION" -tags netgo -targets 'linux/amd64,linux/arm-6,linux/arm-7,linux/arm64' -out url-parser .
- mv /build/* /drone/src/release/
- ls -l /drone/src/release/
- make release
- name: executable
image: alpine
commands:
- $(find release/ -executable -type f | grep url-parser-linux-amd64) --help
- name: compress
image: alpine
commands:
- apk add upx
- find release/ -maxdepth 1 -executable -type f -exec upx {} \;
- ls -lh release/
- name: checksum
image: alpine
commands:
- cd release/ && sha256sum * > sha256sum.txt
- $(find dist/ -executable -type f -iname ${DRONE_REPO_NAME}-linux-amd64) --help
- name: changelog-generate
image: thegeeklab/git-chglog
@ -113,7 +86,7 @@ steps:
api_key:
from_secret: github_token
files:
- release/*
- dist/*
note: CHANGELOG.md
overwrite: true
title: ${DRONE_TAG}
@ -121,9 +94,6 @@ steps:
ref:
- refs/tags/**
image_pull_secrets:
- docker_config
trigger:
ref:
- refs/heads/main
@ -159,9 +129,6 @@ steps:
- success
- failure
image_pull_secrets:
- docker_config
trigger:
ref:
- refs/heads/main
@ -175,6 +142,6 @@ depends_on:
---
kind: signature
hmac: 09c7d46d1ca382b979a28ac23024bea55151074f05d9a61e03896e82145a6d04
hmac: abe0019dfa9264a9509adaaa988e75b60d344269a70b699568bf0615035ecd6a
...

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
/dist/
/release/
/url-parser*

31
.golangci.yml Normal file
View File

@ -0,0 +1,31 @@
linters:
enable:
- gosimple
- deadcode
- typecheck
- govet
- errcheck
- staticcheck
- unused
- structcheck
- varcheck
- dupl
- gofmt
- misspell
- gocritic
- bidichk
- ineffassign
- revive
- gofumpt
- depguard
enable-all: false
disable-all: true
fast: false
run:
timeout: 3m
linters-settings:
gofumpt:
extra-rules: true
lang-version: "1.18"

96
Makefile Normal file
View File

@ -0,0 +1,96 @@
# renovate: datasource=github-releases depName=mvdan/gofumpt
GOFUMPT_PACKAGE_VERSION := v0.3.1
# renovate: datasource=github-releases depName=golangci/golangci-lint
GOLANGCI_LINT_PACKAGE_VERSION := v1.45.2
EXECUTABLE := url-parser
DIST := dist
DIST_DIRS := $(DIST)
IMPORT := github.com/thegeeklab/$(EXECUTABLE)
GO ?= go
CWD ?= $(shell pwd)
PACKAGES ?= $(shell go list ./...)
SOURCES ?= $(shell find . -name "*.go" -type f)
GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@$(GOFUMPT_PACKAGE_VERSION)
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_PACKAGE_VERSION)
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
GENERATE ?=
XGO_VERSION := go-1.18.x
XGO_TARGETS ?= linux/amd64,linux/arm-6,linux/arm-7,linux/arm64
TAGS ?= netgo
ifndef VERSION
ifneq ($(DRONE_TAG),)
VERSION ?= $(subst v,,$(DRONE_TAG))
else
VERSION ?= $(shell git rev-parse --short HEAD)
endif
endif
ifndef DATE
DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%S%z")
endif
LDFLAGS += -s -w -X "main.BuildVersion=$(VERSION)" -X "main.BuildDate=$(DATE)"
.PHONY: all
all: clean build
.PHONY: clean
clean:
$(GO) clean -i ./...
rm -rf $(DIST_DIRS)
.PHONY: fmt
fmt:
$(GO) run $(GOFUMPT_PACKAGE) -extra -w $(SOURCES)
.PHONY: golangci-lint
golangci-lint:
$(GO) run $(GOLANGCI_LINT_PACKAGE) run
.PHONY: lint
lint: golangci-lint
.PHONY: generate
generate:
$(GO) generate $(GENERATE)
.PHONY: test
test:
$(GO) test -v -coverprofile coverage.out $(PACKAGES)
.PHONY: build
build: $(DIST)/$(EXECUTABLE)
$(DIST)/$(EXECUTABLE): $(SOURCES)
$(GO) build -v -tags '$(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -o $@ ./cmd/$(EXECUTABLE)
$(DIST_DIRS):
mkdir -p $(DIST_DIRS)
.PHONY: xgo
xgo: | $(DIST_DIRS)
$(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -v -ldflags '-extldflags "-static" $(LDFLAGS)' -tags '$(TAGS)' -targets '$(XGO_TARGETS)' -out $(EXECUTABLE) --pkg cmd/$(EXECUTABLE) .
cp /build/* $(CWD)/$(DIST)
ls -l $(CWD)/$(DIST)
.PHONY: checksum
checksum:
cd $(DIST); $(foreach file,$(wildcard $(DIST)/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;)
ls -l $(CWD)/$(DIST)
.PHONY: release
release: xgo checksum
.PHONY: deps
deps:
$(GO) mod download
$(GO) install $(GOFUMPT_PACKAGE)
$(GO) install $(GOLANGCI_LINT_PACKAGE)
$(GO) install $(XGO_PACKAGE)

View File

@ -28,7 +28,7 @@ export GOARCH=amd64
export CGO_ENABLED=0
export GO111MODULE=on
go build -v -a -tags netgo -o release/url-parser ./cmd/url-parser/
make build
```
## Usage

View File

@ -1,6 +1,7 @@
package main
import (
"fmt"
"os"
"github.com/sirupsen/logrus"
@ -8,14 +9,20 @@ import (
"github.com/urfave/cli/v2"
)
// Version of current build
var Version = "devel"
var (
BuildVersion = "devel"
BuildDate = "00000000"
)
func main() {
cli.VersionPrinter = func(c *cli.Context) {
fmt.Printf("%s version=%s date=%s\n", c.App.Name, c.App.Version, BuildDate)
}
app := cli.NewApp()
app.Name = "url-parser"
app.Usage = "Parse URL and shows the part of it."
app.Version = Version
app.Version = BuildVersion
app.Action = command.Run
app.Flags = globalFlags()
app.Commands = configCommands()

View File

@ -1,8 +0,0 @@
// +build tools
package tools
import (
_ "golang.org/x/lint/golint"
_ "honnef.co/go/tools/cmd/staticcheck"
)

View File

@ -1,21 +0,0 @@
codecov:
require_ci_to_pass: true
coverage:
status:
project:
default:
target: auto
threshold: 5%
branches:
- main
if_ci_failed: error
informational: false
only_pulls: false
patch:
default:
target: auto
threshold: 5%
branches:
- main
if_ci_failed: error
only_pulls: false

7
go.mod
View File

@ -6,17 +6,10 @@ require (
github.com/sirupsen/logrus v1.8.1
github.com/urfave/cli/v2 v2.4.0
github.com/zenizh/go-capturer v0.0.0-20211219060012-52ea6c8fed04
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616
honnef.co/go/tools v0.3.0
)
require (
github.com/BurntSushi/toml v1.0.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
golang.org/x/exp/typeparams v0.0.0-20220328175248-053ad81199eb // indirect
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect
golang.org/x/sys v0.0.0-20220330033206-e17cdc41300f // indirect
golang.org/x/tools v0.1.11-0.20220330174940-8e193c2ba95e // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
)

25
go.sum
View File

@ -1,6 +1,4 @@
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/toml v1.0.0 h1:dtDWrepsVPfW9H/4y7dDgFc2MBUSeJhlaDtK13CxFlU=
github.com/BurntSushi/toml v1.0.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/cpuguy83/go-md2man/v2 v2.0.1 h1:r/myEWzV9lfsM1tFLgDyu0atFtJ1fXn261LKYj/3DxU=
github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
@ -17,31 +15,8 @@ github.com/urfave/cli/v2 v2.4.0 h1:m2pxjjDFgDxSPtO8WSdbndj17Wu2y8vOT86wE/tjr+I=
github.com/urfave/cli/v2 v2.4.0/go.mod h1:NX9W0zmTvedE5oDoOMs2RTC8RvdK98NTYZE5LbaEYPg=
github.com/zenizh/go-capturer v0.0.0-20211219060012-52ea6c8fed04 h1:qXafrlZL1WsJW5OokjraLLRURHiw0OzKHD/RNdspp4w=
github.com/zenizh/go-capturer v0.0.0-20211219060012-52ea6c8fed04/go.mod h1:FiwNQxz6hGoNFBC4nIx+CxZhI3nne5RmIOlT/MXcSD4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/exp/typeparams v0.0.0-20220328175248-053ad81199eb h1:fP6C8Xutcp5AlakmT/SkQot0pMicROAsEX7OfNPuG10=
golang.org/x/exp/typeparams v0.0.0-20220328175248-053ad81199eb/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk=
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug=
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o=
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220330033206-e17cdc41300f h1:rlezHXNlxYWvBCzNses9Dlc7nGFaNMJeqLolcmQSSZY=
golang.org/x/sys v0.0.0-20220330033206-e17cdc41300f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.1.11-0.20220330174940-8e193c2ba95e h1:lVQAEpHVTmp9WjosvG0WcHRqP3JZv97KkBX4YDdaDfU=
golang.org/x/tools v0.1.11-0.20220330174940-8e193c2ba95e/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
honnef.co/go/tools v0.3.0 h1:2LdYUZ7CIxnYgskbUZfY7FPggmqnh6shBqfWa8Tn3XU=
honnef.co/go/tools v0.3.0/go.mod h1:vlRD9XErLMGT+mDuofSr0mMMquscM/1nQqtRSsh6m70=

View File

@ -30,7 +30,7 @@ func TestFragment(t *testing.T) {
set.String("url", table.urlString, "test url")
c := cli.NewContext(app, set, nil)
result := strings.TrimSpace(capturer.CaptureStdout(func() { Fragment(c) }))
result := strings.TrimSpace(capturer.CaptureStdout(func() { _ = Fragment(c) }))
if result != table.expected {
t.Fatalf("URL fragment `%v`, should be `%v`", result, table.expected)

View File

@ -30,7 +30,7 @@ func TestHost(t *testing.T) {
set.String("url", table.urlString, "test url")
c := cli.NewContext(app, set, nil)
result := strings.TrimSpace(capturer.CaptureStdout(func() { Host(c) }))
result := strings.TrimSpace(capturer.CaptureStdout(func() { _ = Host(c) }))
if result != table.expected {
t.Fatalf("URL host `%v`, should be `%v`", result, table.expected)

View File

@ -30,7 +30,7 @@ func TestPassword(t *testing.T) {
set.String("url", table.urlString, "test url")
c := cli.NewContext(app, set, nil)
result := strings.TrimSpace(capturer.CaptureStdout(func() { Password(c) }))
result := strings.TrimSpace(capturer.CaptureStdout(func() { _ = Password(c) }))
if result != table.expected {
t.Fatalf("URL password `%v`, should be `%v`", result, table.expected)

View File

@ -28,7 +28,7 @@ func Path(ctx *cli.Context) error {
if i > -1 {
path := strings.Split(parts.Path, "/")
if i = i + 1; i < len(path) {
if i++; i < len(path) {
fmt.Println(path[i])
}
} else {

View File

@ -38,7 +38,7 @@ func TestPath(t *testing.T) {
set.Int("path-index", table.pathIndex, "index")
c := cli.NewContext(app, set, nil)
result := strings.TrimSpace(capturer.CaptureStdout(func() { Path(c) }))
result := strings.TrimSpace(capturer.CaptureStdout(func() { _ = Path(c) }))
if result != table.expected {
t.Fatalf("URL path `%v`, should be `%v`", result, table.expected)

View File

@ -30,7 +30,7 @@ func TestPort(t *testing.T) {
set.String("url", table.urlString, "test url")
c := cli.NewContext(app, set, nil)
result := strings.TrimSpace(capturer.CaptureStdout(func() { Port(c) }))
result := strings.TrimSpace(capturer.CaptureStdout(func() { _ = Port(c) }))
if result != table.expected {
t.Fatalf("URL port `%v`, should be `%v`", result, table.expected)

View File

@ -37,7 +37,7 @@ func TestQuery(t *testing.T) {
set.String("query-field", table.QueryField, "index")
c := cli.NewContext(app, set, nil)
result := strings.TrimSpace(capturer.CaptureStdout(func() { Query(c) }))
result := strings.TrimSpace(capturer.CaptureStdout(func() { _ = Query(c) }))
if result != table.expected {
t.Fatalf("URL query `%v`, should be `%v`", result, table.expected)

View File

@ -30,7 +30,7 @@ func TestRun(t *testing.T) {
set.String("url", table.urlString, "test url")
c := cli.NewContext(app, set, nil)
result := strings.TrimSpace(capturer.CaptureStdout(func() { Run(c) }))
result := strings.TrimSpace(capturer.CaptureStdout(func() { _ = Run(c) }))
if result != table.expected {
t.Fatalf("URL `%v`, should be `%v`", result, table.expected)

View File

@ -30,7 +30,7 @@ func TestScheme(t *testing.T) {
set.String("url", table.urlString, "test url")
c := cli.NewContext(app, set, nil)
result := strings.TrimSpace(capturer.CaptureStdout(func() { Scheme(c) }))
result := strings.TrimSpace(capturer.CaptureStdout(func() { _ = Scheme(c) }))
if result != table.expected {
t.Fatalf("URL scheme `%v`, should be `%v`", result, table.expected)

View File

@ -30,7 +30,7 @@ func TestUser(t *testing.T) {
set.String("url", table.urlString, "test url")
c := cli.NewContext(app, set, nil)
result := strings.TrimSpace(capturer.CaptureStdout(func() { User(c) }))
result := strings.TrimSpace(capturer.CaptureStdout(func() { _ = User(c) }))
if result != table.expected {
t.Fatalf("URL user `%v`, should be `%v`", result, table.expected)