Help us shape the future of Go! Take the 2026 Go Developer Survey

capture

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 20, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

README

go-capture

Go Report Card Build Status codecov

Description

Utility functions to capture standard output, error output, or log output

Testing

Unit tests can be started by the following command:

./test.sh

It is also possible to specify CLI options for Go test. For example, if you need to disable test results caching, use the following command:

./test -count=1

CI

Travis CI is configured for this repository. Several tests and checks are started for all pull requests:

  • Unit tests that use the standard tool go test
  • go fmt tool to check code formatting. That tool is run with -s flag to perform following transformations
  • go vet to report likely mistakes in source code, for example suspicious constructs, such as Printf calls whose arguments do not align with the format string.
  • golint as a linter for all Go sources stored in this repository
  • gocyclo to report all functions and methods with too high cyclomatic complexity. The cyclomatic complexity of a function is calculated according to the following rules: 1 is the base complexity of a function +1 for each 'if', 'for', 'case', '&&' or '||' Go Report Card warns on functions with cyclomatic complexity > 9

History of checks done by CI is available at RedHatInsights / insights-operator-controller.

Contribution

Please look into document CONTRIBUTING.md that contains all information about how to contribute to this project.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorOutput added in v1.0.1

func ErrorOutput(function func()) (string, error)

ErrorOutput captures the error output for specified code block and then returns the captured output. Please see https://medium.com/@hau12a1/golang-capturing-log-println-and-fmt-println-output-770209c791b4 for further explanation how it works under the hood.

func StandardOutput

func StandardOutput(function func()) (string, error)

StandardOutput captures the standard output for specified code block and then returns the captured output. Please see https://medium.com/@hau12a1/golang-capturing-log-println-and-fmt-println-output-770209c791b4 for further explanation how it works under the hood.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL