Last active
September 8, 2016 02:25
-
-
Save gerep/beb546edc63b2f53c55fde4c336cc133 to your computer and use it in GitHub Desktop.
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
package main | |
import ( | |
"fmt" | |
"strconv" | |
) | |
func main() { | |
i := 123 | |
t := strconv.Itoa(i) | |
fmt.Println(t) | |
} |
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
package main | |
import "fmt" | |
func main() { | |
i := 123 | |
t := fmt.Sprintf("We are currently processing ticket number %d.", i) | |
fmt.Println(t) | |
} |
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
package main | |
import ( | |
"fmt" | |
"math/rand" | |
"time" | |
) | |
func main() { | |
fmt.Println(RandString(10)) | |
} | |
var source = rand.NewSource(time.Now().UnixNano()) | |
const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" | |
func RandString(length int) string { | |
b := make([]byte, length) | |
for i := range b { | |
b[i] = charset[source.Int63()%int64(len(charset))] | |
} | |
return string(b) | |
} |
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
package main | |
import "fmt" | |
func main() { | |
var s string = "this is a string" | |
fmt.Println(s) | |
var b []byte | |
b = []byte(s) | |
fmt.Println(b) | |
for i := range b { | |
fmt.Println(string(b[i])) | |
} | |
s = string(b) | |
fmt.Println(s) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment