上一页 1 ··· 4 5 6 7 8 9 10 11 12 下一页

2018年3月22日

4.3 字符串格式转换成时间格式

摘要: ```go package main import ( "fmt" "time" ) func main() { // If timezone is not defined // than Parse function returns // the time in UTC timezone. t, err := time.Parse("2/1/2006", "31/7/2015... 阅读全文

posted @ 2018-03-22 00:23 cucy_to 阅读(186) 评论(0) 推荐(0) 编辑

4.2 时间格式转为字符串格式

摘要: ```go package main import ( "fmt" "time" ) func main() { tTime := time.Date(2017, time.March, 5, 8, 5, 2, 0, time.Local) // The formatting is done // with use of reference value // Jan 2 15:... 阅读全文

posted @ 2018-03-22 00:21 cucy_to 阅读(117) 评论(0) 推荐(0) 编辑

4.1 今天日期 time.Now

摘要: ```go package main import ( "fmt" "time" ) func main() { today := time.Now() fmt.Println(today) } /* 2018-03-22 00:18:44.558974 +0800 CST m=+0.000385597 */ ``` 阅读全文

posted @ 2018-03-22 00:20 cucy_to 阅读(92) 评论(0) 推荐(0) 编辑

3.12 Checksum md5

摘要: ```go package main import ( "crypto/md5" "fmt" "io" "os" ) var content = "This is content to check" func main() { checksum := MD5(content) checksum2 := FileMD5("content.dat") fmt.Printf("C... 阅读全文

posted @ 2018-03-22 00:19 cucy_to 阅读(194) 评论(0) 推荐(0) 编辑

3.9

摘要: ```go package main import ( "fmt" "math/cmplx" ) func main() { // complex numbers are // defined as real and imaginary // part defined by float64 a := complex(2, 3) fmt.Printf("Real part: ... 阅读全文

posted @ 2018-03-22 00:14 cucy_to 阅读(122) 评论(0) 推荐(0) 编辑

3.8 随机数

摘要: ```go package main import ( crypto "crypto/rand" "fmt" "math/big" "math/rand" ) func main() { sec1 := rand.New(rand.NewSource(10)) sec2 := rand.New(ra 阅读全文

posted @ 2018-03-22 00:12 cucy_to 阅读(105) 评论(0) 推荐(0) 编辑

3.6 二进制,十进制,十六进制转换

摘要: ```go package main import ( "fmt" "strconv" ) const bin = "10111" const hex = "1A" const oct = "12" const dec = "10" const floatNum = 16.123557 func main() { // Converts binary value into hex ... 阅读全文

posted @ 2018-03-22 00:08 cucy_to 阅读(278) 评论(0) 推荐(0) 编辑

3.5

摘要: ```go package main import ( "fmt" ) var integer int64 = 32500 var floatNum float64 = 22000.456 func main() { // Common way how to print the decimal // number fmt.Printf("%d \n", integer) // ... 阅读全文

posted @ 2018-03-22 00:07 cucy_to 阅读(183) 评论(0) 推荐(0) 编辑

3.4 最大浮点数?

摘要: ```go package main import ( "fmt" "math" "math/big" ) const PI = const diameter = 3.0 const precision = 400 func main() { pi, _ := new(big.Float).SetP 阅读全文

posted @ 2018-03-22 00:03 cucy_to 阅读(144) 评论(0) 推荐(0) 编辑

3.3 四舍五入

摘要: ```go package main import ( "fmt" "math" ) var valA float64 = 3.55554444 func main() { // Bad assumption on rounding // the number by casting it to // integer. intVal := int(valA) fmt.Print... 阅读全文

posted @ 2018-03-22 00:01 cucy_to 阅读(72) 评论(0) 推荐(0) 编辑

上一页 1 ··· 4 5 6 7 8 9 10 11 12 下一页

导航