I need to format the output of go tool cover so I can split the first column by / so I get only the last two values, but keep the rest of the output as the original one.
Here is how the original output looks like:
$ go tool cover -func=coverage.out
github.com/company/utils/common.go:6: IsFoo 100.0%
github.com/company/utils/logger.go:118: maskFoo 100.0%
github.com/company/utils/logger.go:127: createFoo 100.0%
github.com/company/utils/logger.go:132: CreateFakeFoo 100.0%
github.com/company/utils/foo_validaiton.go:43: IsFoo 100.0%
github.com/company/utils/foo_validaiton.go:49: GreaterThanFoo 100.0%
github.com/company/utils/yaml.go:39: closeFOO 100.0%
total: (statements) 100.0%
I tried using awk to split the first column and get only the utils/file.go part, but the columns are not align.
$ go tool cover -func=coverage.out | awk '{split($1, a, "/"); print a[4]"/"a[5]"\t"$2"\t"$3}'
utils/common.go:6: IsFoo 100.0%
utils/logger.go:118: maskFoo 100.0%
utils/logger.go:127: createFoo 100.0%
utils/logger.go:132: CreateFakeFoo 100.0%
utils/foo_validaiton.go:43: IsFoo 100.0%
utils/foo_validaiton.go:49: GreaterThanFoo 100.0%
utils/yaml.go:39: closeFOO 100.0%
/ (statements) 100.0%
How can I archive the following output using awk or another cli tool?
utils/common.go:6: IsFoo 100.0%
utils/logger.go:118: maskFoo 100.0%
utils/logger.go:127: createFoo 100.0%
utils/logger.go:132: CreateFakeFoo 100.0%
utils/foo_validaiton.go:43: IsFoo 100.0%
utils/foo_validaiton.go:49: GreaterThanFoo 100.0%
utils/yaml.go:39: closeFOO 100.0%
total: (statements) 100.0%