Created
October 26, 2018 01:59
-
-
Save bookmebus/2b72579740e6e8154ea884b595b035ba to your computer and use it in GitHub Desktop.
Getting started with go
This file contains hidden or 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 age int | |
age = 10.0 | |
salary := 12 | |
age = age + salary | |
// var str string | |
str := fmt.Sprintf("Hello, world %d, 你好!\n", age) | |
fmt.Printf(str) | |
var ( year int ; month int; day int ) | |
var ( | |
hour int | |
minute int | |
second int | |
) | |
agency1, agency2 := "Mara", "Carlos" | |
agencies := fmt.Sprintf("%s, %s", agency1, agency2) | |
fmt.Printf("Agencies: %s \n", agencies) | |
date := fmt.Sprintf("%d-%d-%d", year, month, day) | |
time := fmt.Sprintf("%d:%d:%d", hour, minute, second) | |
fmt.Printf("DateTime is %s, %s \n", date, time) | |
// const | |
const pi = 3.1459 | |
const ( | |
c=30000 | |
g=9.8 | |
) | |
fmt.Printf("const pi=%f, c=%d, g=%f \n", pi, c, g) | |
var token = "pay-1i3hwldghwjf" | |
id := token | |
arr := []rune(token) | |
arr[0] = ' ' | |
fmt.Printf("string=%s, id=%s array= %q, %s \n", token, id, arr, string(arr)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment