再牛逼的梦想也抵不住傻逼似的坚持!   设为首页 - 加入收藏
您的当前位置:小鱼资料库 > 计算机 > go教程 >

go教程

  • Go字符串长度-Go实例教程|

    Go 字符串长度 package main import fmt func main () { var greeting = Hello world! fmt . Printf ( String Length is: ) fmt . Println ( len ( greeting )) }...

  • Go返回多个值-Go实例教程|

    Go 返回多个值 package main import fmt func swap ( x , y string ) ( string , string ) { return y , x } func main () { a , b := swap ( Mahesh , Kumar ) fmt . Println ( a , b ) }...

  • Goswitch-Go实例教程|

    Go switch package main import fmt func main () { var x interface {} switch i := x .( type ) { case nil : fmt . Printf ( type of x :%T , i ) case int : fmt . Printf ( x is int ) case...

  • Goifelseifelse语句-Go实例教程|

    Go if else if else 语句 package main import fmt func main () { /* local variable definition */ var a int = 100 /* check the boolean condition */ if ( a == 10 ) { /* if condition i...

  • Go错误处理-Go实例教程|

    Go 错误处理 package main import errors import fmt import math func Sqrt ( value float64 )( float64 , error ) { if ( value 0 ){ return 0 , errors . New ( Math: negative number pa...

  • Go接口-Go实例教程|

    Go 接口 package main import ( fmt math ) /* define an interface */ type Shape interface { area () float64 } /* define a circle */ type Circle struct { x , y , radius float64 } /* ...

  • Go类型转换-Go实例教程|

    Go 类型转换 package main import fmt func main () { var sum int = 17 var count int = 5 var mean float32 mean = float32 ( sum ) / float32 ( count ) fmt . Printf ( Value of mean : ...

  • Go递归计算斐波那契数列-Go实例教程|

    Go 递归计算斐波那契数列 package main import fmt func fibonaci ( i int ) ( ret int ) { if i == 0 { return 0 } if i == 1 { return 1 } return fibonaci ( i - 1 ) + fibonaci ( ...

  • Go使用递归计算阶乘-Go实例教程|

    Go 使用递归计算阶乘 package main import fmt func factorial ( i int ) int { if ( i = 1 ) { return 1 } return i * factorial ( i - 1 ) } func main () { var i int = 15 fmt . Pri...

  • Godelete()函数-Go实例教程|

    Go delete() 函数 package main import fmt func main () { /* create a map*/ countryCapitalMap := map [ string ] string { France : Paris , Italy : Rome , Japan : Tokyo , India : New ...

  • Go定义一个Map-Go实例教程|

    Go 定义一个Map package main import fmt func main () { var countryCapitalMap map [ string ] string /* create a map*/ countryCapitalMap = make ( map [ string ] string ) /* insert ...

  • GoRange-Go实例教程|

    Go Range package main import fmt func main () { /* create a slice */ numbers := [] int { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 } /* print the numbers */ for i := range numbers { fmt . P...

  • Goppend()和copy()函数-Go实例教程|

    Go ppend() 和 copy() 函数 package main import fmt func main () { var numbers [] int printSlice ( numbers ) /* append allows nil slice */ numbers = append ( numbers , 0 ) printSli...

  • GoSubslicing-Go实例教程|

    Go Subslicing package main import fmt func main () { /* create a slice */ numbers := [] int { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 } printSlice ( numbers ) /* print the original slice ...

  • GoNilslice-Go实例教程|

    Go Nil slice package main import fmt func main () { var numbers [] int printSlice ( numbers ) if ( numbers == nil ){ fmt . Printf ( slice is nil ) } } func printSlice ( x [] int ){ ...

  • Golen()和cap()函数-Go实例教程|

    Go len() 和 cap() 函数 package main import fmt func main () { var numbers = make ([] int , 3 , 5 ) printSlice ( numbers ) } func printSlice ( x [] int ){ fmt . Printf ( len=%d ca...

  • Go指向结构的指针-Go实例教程|

    Go 指向结构的指针 package main import fmt type Books struct { title string author string subject string book_id int } func main () { var Book1 Books /* Declare Book1 of type ...

  • Go结构作为函数参数-Go实例教程|

    Go 结构作为函数参数 package main import fmt type Books struct { title string author string subject string book_id int } func main () { var Book1 Books /* Declare Book1 of ty...

  • Go访问结构成员-Go实例教程|

    Go 访问结构成员 package main import fmt type Books struct { title string author string subject string book_id int } func main () { var Book1 Books /* Declare Book1 of type Boo...

  • Go传递指针给函数-Go实例教程|

    Go 传递指针给函数 package main import fmt func main () { /* local variable definition */ var a int = 100 var b int = 200 fmt . Printf ( Before swap, value of a : %d , a ) fmt...

小鱼资料库 www.xiaoyuzl.com

Copyright © 2020-2022 XIAOYUZL. All rights reserved. 冀ICP备2020029262号-2

声明:本站分享的文章、资源等均由网友上传,版权归原作者所有,只用于搜集整理。如有侵权,请您与站长联系,我们将及时处理!

Top