convert sample to go
count output
buffer and fix formatting