Created
May 7, 2018 05:07
-
-
Save iwilsonq/2e15a9f4eb4f5b812fb311b06712abab to your computer and use it in GitHub Desktop.
A Go script generated gist.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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