Skip to content

Instantly share code, notes, and snippets.

View jcamilom's full-sized avatar

Camilo Muñoz jcamilom

  • Medellín, Colombia
View GitHub Profile
@jcamilom
jcamilom / MutateString.go
Created May 3, 2018 20:17
[Mutate string] How to change individual chars of a string. From https://golangbot.com/strings/ #go #golang #strings
package main
import (
"fmt"
)
func mutate(s []rune) string {
s[0] = 'a'
return string(s)
}
@jcamilom
jcamilom / AccessingStringRunes.go
Last active May 3, 2018 20:13
[Accessing bytes and runes of a string] Getting the corresponding bytes and runes that compose a string. From https://golangbot.com/strings/ #go #golang #strings
package main
import (
"fmt"
)
func printBytes(s string) {
for i:= 0; i < len(s); i++ {
fmt.Printf("%x ", s[i])
}
@jcamilom
jcamilom / AccessingString.go
Created May 3, 2018 20:05
[Accessing bytes and chars of a string] Getting the corresponding bytes and chars that compose a string. From https://golangbot.com/strings/ #go #golang #strings
package main
import (
"fmt"
)
func printBytes(s string) {
for i:= 0; i < len(s); i++ {
fmt.Printf("%x ", s[i])
}
@jcamilom
jcamilom / RemoveNewLineFromInput.go
Last active May 3, 2018 19:58
[Remove new line from input] Remove the new line char from a string acquired using io.Reader.ReadString. Solution from https://flaviocopes.com/golang-remove-new-line-from-readstring/ #golang #go #input
package main
import (
"bufio"
"os"
"strings"
)
func main() {
reader := bufio.NewReader(os.Stdin)