Write your own cat Tool - Golang
A simple implementaiton
A Go implementation of the GNU cat command.
Usage:
Checking the with the examples mentioned in the challenge
head -n1 test.txt | ./cat -
It is same as the output from cut, see
diff <(cut -f2 tests/testdata/sample.tsv) <(./cc-cut -f2 tests/testdata/sample.tsv)
A sample run for stdin,
echo "f1,f2,f3,f4\n1,2,3,4\na,b,c,d" | ./cc-cut -f1-2,3-4 -d, --output-delimiter=%
f1%f2%f3%f4
1%2%3%4
a%b%c%d
The output for the various options are same as that of the cit tool and it is verified using both Go tests and Functional tests
cd go/cat
go test - v
cd go/cat
go build -o cc-cat ./cmd
The testdata is used which to compare alignment with cut to run the test use test.sh.
./test.sh -p ../cc-cat
There are same as the ones in the py-cat implementation, see