Chapter 4—Basic constructs and elementary data types

Chapter 4—Basic constructs and elementary data types.......................................................49

4.1. Filenames—Keywords—Identifiers..........................................................................49

4.2. Basic structure and components of a Go-program...................................................50

4.2.1 Packages, import and visibility......................................................................51

4.2.3 Comments....................................................................................................56

4.2.4 Types............................................................................................................57

4.2.5 General structure of a Go-program...............................................................58

4.2.6 Conversions..................................................................................................60

4.2.7 About naming things in Go..........................................................................60

4.3. Constants................................................................................................................60

4.4. Variables..................................................................................................................63

4.4.1 Introduction.................................................................................................63

4.4.2 Value types and reference types.....................................................................66

4.4.3 Printing........................................................................................................68

4.4.4 Short form with the := assignment operator..................................................69

4.4.5 Init-functions................................................................................................70

4.5. Elementary types and operators...............................................................................73

4.5.1. Boolean type bool........................................................................................73

4.5.2. Numerical types...........................................................................................75

4.5.2.1 ints and floats.............................................................................................75

4.5.2.2 Complex numbers.....................................................................................79

4.5.2.3 Bit operators..............................................................................................79

4.5.2.4 Logical operators........................................................................................81

4.5.2.5 Arithmetic operators.................................................................................82

4.5.2.6 Random numbers......................................................................................82

4.5.3. Operators and precedence............................................................................84

4.5.4. Aliasing types...............................................................................................84

4.5.5. Character type.............................................................................................85

4.6. Strings.....................................................................................................................86

4.7. The strings and strconv package..............................................................................88

4.7.1—Prefixes and suffixes:...................................................................................88

4.7.2—Testing whether a string contains a substring:.............................................89

4.7.3—Indicating at which position (index) a substring or character occurs

in a string:...................................................................................................89

4.7.4—Replacing a substring:................................................................................90

4.7.5—Counting occurrences of a substring:..........................................................90

4.7.6—Repeating a string:.....................................................................................90

4.7.7—Changing the case of a string:....................................................................91

4.7.8—Trimming a string:.....................................................................................92

4.7.9—Splitting a string:........................................................................................92

4.7.10—Joining over a slice:..................................................................................92

4.7.11—Reading from a string:..............................................................................93

4.8. Times and dates.......................................................................................................95

4.9. Pointers...................................................................................................................96

转载于:https://my.oschina.net/124259473/blog/1799071

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值