tasks/go.py
def fmt(ctx, targets, fail_on_fmt=False):
    """
    Run go fmt on targets.

    Example invokation:
        inv fmt --targets=./pkg/collector/check,./pkg/aggregator
    """
    if isinstance(targets, str):
        # when this function is called from the command line, targets are passed
        # as comma separated tokens in a string
        targets = targets.split(',')

    result = ctx.run("gofmt -l -w -s " + " ".join(targets))
    if result.stdout:
        files = {x for x in result.stdout.split("\n") if x}
        print(f"Reformatted the following files: {','.join(files)}")
        if fail_on_fmt:
            print("Code was not properly formatted, exiting...")
            raise Exit(code=1)
    print("gofmt found no issues")

    Run go fmt on targets.

    Example invokation:
        inv fmt --targets=./pkg/collector/check,./pkg/aggregator
    
Run go fmt on targets.
Run go fmt on targets .
def fmt(ctx, targets, fail_on_fmt=False):
    if isinstance(targets, str):
        targets = targets.split(',')
    result = ctx.run("gofmt -l -w -s " + " ".join(targets))
    if result.stdout:
        files = {x for x in result.stdout.split("\n") if x}
        print(f"Reformatted the following files: {','.join(files)}")
        if fail_on_fmt:
            print("Code was not properly formatted, exiting...")
            raise Exit(code=1)
    print("gofmt found no issues")
def fmt ( ctx , targets , fail_on_fmt = False ) : if isinstance ( targets , str ) : targets = targets . split ( ',' ) result = ctx . run ( "gofmt -l -w -s " + " " . join ( targets ) ) if result . stdout : files = { x for x in result . stdout . split ( "\n" ) if x } print ( f"Reformatted the following files: {','.join(files)}" ) if fail_on_fmt : print ( "Code was not properly formatted, exiting..." ) raise Exit ( code = 1 ) print ( "gofmt found no issues" )
Run go fmt on targets.
Run go fmt on targets .
"""
    Run go fmt on targets.

    Example invokation:
        inv fmt --targets=./pkg/collector/check,./pkg/aggregator
    """ # when this function is called from the command line, targets are passed # as comma separated tokens in a string
ctx
targets
fail_on_fmt