Skip to content

Instantly share code, notes, and snippets.

@iwilsonq
Created May 7, 2018 05:07
Show Gist options
  • Save iwilsonq/2e15a9f4eb4f5b812fb311b06712abab to your computer and use it in GitHub Desktop.
Save iwilsonq/2e15a9f4eb4f5b812fb311b06712abab to your computer and use it in GitHub Desktop.
A Go script generated gist.
// Unicode constants
const (
TAB = 9
SPACE = 32
NEWLINE = 10
)
func removeInitialNewline(content string) string {
if content[0] == NEWLINE {
content = content[1:]
}
return content
}
func replaceTabsWithSpaces(content string) string {
var buffer bytes.Buffer
for _, c := range content {
if c == TAB {
buffer.WriteRune(SPACE)
buffer.WriteRune(SPACE)
} else {
buffer.WriteRune(c)
}
}
return buffer.String()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment