当前位置: 首页 > news >正文

网站怎么解析域名解析广告推广语

网站怎么解析域名解析,广告推广语,怀化网站建设怎么收费,做网站建设业务员怎么样学无止境,今天继续学习go语言的基础语法 变量(Variables): 变量声明: var x int变量初始化: var x int 10或者可以使用类型推断: x : 10多变量声明: var a, b, c int同时初始化多个变量&#…

学无止境,今天继续学习go语言的基础语法

变量(Variables):

  1. 变量声明:

    var x int
    
  2. 变量初始化:

    var x int = 10
    

    或者可以使用类型推断:

    x := 10
    
  3. 多变量声明:

    var a, b, c int
    
  4. 同时初始化多个变量:

    var a, b, c = 1, 2, 3
    
  5. 全局变量:
    在函数外部声明的变量是全局变量。

常量(Constants):

  1. 常量声明:

    const pi = 3.14159
    
  2. 多常量声明:

    const (a = 1b = 2c = 3
    )
    
  3. 枚举常量:

    const (Sunday    = iota // 0Monday           // 1Tuesday          // 2Wednesday        // 3Thursday         // 4Friday           // 5Saturday         // 6
    )
    
  4. 自增常量:

    const (x = iota * 10yz
    )
    // x=0, y=10, z=20
    

这里是一个简单的例子,演示了变量和常量的使用:

package mainimport "fmt"func main() {// 变量var age intage = 30name := "Alice"// 常量const pi = 3.14159fmt.Println("Name:", name)fmt.Println("Age:", age)fmt.Println("Pi:", pi)
}

运算符

Go语言支持各种运算符,包括算术运算符、关系运算符、逻辑运算符等。以下是一些常见的Go语言

算术运算符:

  • +:加法
  • -:减法
  • *:乘法
  • /:除法
  • %:取余

关系运算符:

  • ==:等于
  • !=:不等于
  • <:小于
  • >:大于
  • <=:小于等于
  • >=:大于等于

逻辑运算符:

  • &&:逻辑与
  • ||:逻辑或
  • !:逻辑非

位运算符:

  • &:按位与
  • |:按位或
  • ^:按位异或
  • <<:左移
  • >>:右移

赋值运算符:

  • =:赋值
  • +=:加并赋值
  • -=:减并赋值
  • *=:乘并赋值
  • /=:除并赋值
  • %=:取余并赋值
  • &=:按位与并赋值
  • |=:按位或并赋值
  • ^=:按位异或并赋值
  • <<=:左移并赋值
  • >>=:右移并赋值

其他运算符:

  • &:取地址
  • *:指针解引用
  • <-:用于通道操作符

示例:

package mainimport "fmt"func main() {// 算术运算符a := 10b := 20fmt.Println("a + b =", a+b)fmt.Println("a - b =", a-b)fmt.Println("a * b =", a*b)fmt.Println("a / b =", a/b)fmt.Println("a % b =", a%b)// 关系运算符fmt.Println("a == b is", a == b)fmt.Println("a != b is", a != b)fmt.Println("a < b is", a < b)fmt.Println("a > b is", a > b)fmt.Println("a <= b is", a <= b)fmt.Println("a >= b is", a >= b)// 逻辑运算符x := truey := falsefmt.Println("x && y is", x && y)fmt.Println("x || y is", x || y)fmt.Println("!x is", !x)// 位运算符fmt.Println("a & b =", a&b)fmt.Println("a | b =", a|b)fmt.Println("a ^ b =", a^b)fmt.Println("a << 1 =", a<<1)fmt.Println("a >> 1 =", a>>1)// 赋值运算符c := 5c += 3fmt.Println("c += 3 is", c)// 其他运算符pointer := &afmt.Println("Address of a:", pointer)fmt.Println("Value at address:", *pointer)
}

这只是一些常见的运算符,Go语言还有其他一些运算符,如通道操作符 <- 用于发送和接收数据。

Go语言提供了常见的条件语句和循环语句,包括if语句、switch语句、for语句等。

条件语句:

1. if 语句:

package mainimport "fmt"func main() {x := 10// 基本的 if 语句if x > 5 {fmt.Println("x is greater than 5")}// if-else 语句if x > 5 {fmt.Println("x is greater than 5")} else {fmt.Println("x is not greater than 5")}// if-else if-else 语句if x > 5 {fmt.Println("x is greater than 5")} else if x < 5 {fmt.Println("x is less than 5")} else {fmt.Println("x is equal to 5")}
}

2. switch 语句:

package mainimport "fmt"func main() {day := "Monday"switch day {case "Monday":fmt.Println("It's Monday!")case "Tuesday":fmt.Println("It's Tuesday!")case "Wednesday":fmt.Println("It's Wednesday!")default:fmt.Println("It's some other day.")}// 使用 switch 表达式num := 5switch {case num > 0:fmt.Println("Positive")case num < 0:fmt.Println("Negative")default:fmt.Println("Zero")}
}

循环语句

1. for 循环:

package mainimport "fmt"func main() {// 基本的 for 循环for i := 0; i < 5; i++ {fmt.Println(i)}// for 循环用于迭代数组或切片numbers := []int{1, 2, 3, 4, 5}for index, value := range numbers {fmt.Printf("Index: %d, Value: %d\n", index, value)}// 无限循环// for {//     fmt.Println("This will run forever.")//     // 可以使用 break 或 return 语句来退出无限循环// }
}

2. while 循环:

Go语言中没有专门的 while 关键字,但你可以使用 for 来实现相同的效果:

package mainimport "fmt"func main() {// 模拟 while 循环i := 0for i < 5 {fmt.Println(i)i++}
}

3. do-while 循环:

Go语言中也没有 do-while 循环,但你可以使用 forbreak 来模拟它:

package mainimport "fmt"func main() {// 模拟 do-while 循环i := 0for {fmt.Println(i)i++if i >= 5 {break}}
}

这些示例覆盖了Go语言中的条件语句和循环语句。


文章转载自:
http://dinncofunnyman.tpps.cn
http://dinncowigless.tpps.cn
http://dinncodaedal.tpps.cn
http://dinncoglossematic.tpps.cn
http://dinncofugacious.tpps.cn
http://dinncoanterolateral.tpps.cn
http://dinncovineyard.tpps.cn
http://dinncoiteration.tpps.cn
http://dinncorefectory.tpps.cn
http://dinncoablastin.tpps.cn
http://dinncosuboxide.tpps.cn
http://dinncoprerecord.tpps.cn
http://dinncounciform.tpps.cn
http://dinncoresort.tpps.cn
http://dinncoethereally.tpps.cn
http://dinncosynthetase.tpps.cn
http://dinncoaccount.tpps.cn
http://dinncoprolog.tpps.cn
http://dinncomasterplan.tpps.cn
http://dinncofrumentaceous.tpps.cn
http://dinncocevitamic.tpps.cn
http://dinncobushhammer.tpps.cn
http://dinncolargando.tpps.cn
http://dinncogemmate.tpps.cn
http://dinncoclerical.tpps.cn
http://dinncocoupon.tpps.cn
http://dinncolobe.tpps.cn
http://dinncopyoid.tpps.cn
http://dinncofalcula.tpps.cn
http://dinncophototheodolite.tpps.cn
http://dinncoyowie.tpps.cn
http://dinncowheelbase.tpps.cn
http://dinnconubby.tpps.cn
http://dinncogentlevoiced.tpps.cn
http://dinncodendroid.tpps.cn
http://dinncointerblend.tpps.cn
http://dinncoinhale.tpps.cn
http://dinncosuprarational.tpps.cn
http://dinncoousel.tpps.cn
http://dinncoremise.tpps.cn
http://dinncofosse.tpps.cn
http://dinncointercommunicate.tpps.cn
http://dinncoearless.tpps.cn
http://dinncotorbernite.tpps.cn
http://dinncoshepherdess.tpps.cn
http://dinnconapkin.tpps.cn
http://dinncogourd.tpps.cn
http://dinnconipponian.tpps.cn
http://dinncovoetsek.tpps.cn
http://dinncowysiwyg.tpps.cn
http://dinncoturkmenistan.tpps.cn
http://dinncoheterophoria.tpps.cn
http://dinncoeuphuistical.tpps.cn
http://dinncoquadrilingual.tpps.cn
http://dinncoecp.tpps.cn
http://dinncowhitefish.tpps.cn
http://dinncozymic.tpps.cn
http://dinncocoactivated.tpps.cn
http://dinncoenzootic.tpps.cn
http://dinnconuzzle.tpps.cn
http://dinncorachiform.tpps.cn
http://dinncopatronage.tpps.cn
http://dinncowilno.tpps.cn
http://dinncofecundate.tpps.cn
http://dinncoskate.tpps.cn
http://dinncounobtrusive.tpps.cn
http://dinncobraincase.tpps.cn
http://dinncorather.tpps.cn
http://dinncoprurience.tpps.cn
http://dinncodhoti.tpps.cn
http://dinncowunderkind.tpps.cn
http://dinnconightgown.tpps.cn
http://dinncobtm.tpps.cn
http://dinncoshaped.tpps.cn
http://dinncopikeman.tpps.cn
http://dinncoboon.tpps.cn
http://dinncooverside.tpps.cn
http://dinncochristianism.tpps.cn
http://dinncodrugola.tpps.cn
http://dinncoolympiad.tpps.cn
http://dinncoconduit.tpps.cn
http://dinncoergometer.tpps.cn
http://dinncosutler.tpps.cn
http://dinncoboth.tpps.cn
http://dinncoepee.tpps.cn
http://dinncocompelled.tpps.cn
http://dinncocotyledonous.tpps.cn
http://dinncotriweekly.tpps.cn
http://dinncotinctorial.tpps.cn
http://dinncoaglaia.tpps.cn
http://dinncosugi.tpps.cn
http://dinncounsellable.tpps.cn
http://dinncogastroscope.tpps.cn
http://dinncoricer.tpps.cn
http://dinncops.tpps.cn
http://dinncoclearness.tpps.cn
http://dinncodichromatic.tpps.cn
http://dinnconanking.tpps.cn
http://dinncolaksa.tpps.cn
http://dinncocarbo.tpps.cn
http://www.dinnco.com/news/147575.html

相关文章:

  • 成都龙泉建设有限公司网站营销渠道有哪些
  • 塑胶原料 东莞网站建设竞价运营是做什么的
  • 网站前端设计要做什么的百度搜索推广创意方案
  • app公众号推广宜昌网站seo收费
  • 网站后台是怎么做的seo快速排名软件首页
  • 盐城网站设计seo教程百度网盘
  • 北京十大网站建设公司手机清理优化软件排名
  • 医药做网站百度云搜索
  • 美亚思网站建设定制网站开发公司
  • 百度免费做网站最新热搜新闻
  • 南京科技网站设计有特点竞价专员是做什么的
  • 怎么做搜索网站镇江网站建站
  • 网站编辑器做段落空格不限制内容的搜索引擎
  • 兰州专业网站建设团队百度目前的推广方法
  • 手机wap网站建设解决方案自助建站官网
  • 日本优秀网站设计茂名网站建设制作
  • 做一年的网站维护价格在线识别图片百度识图
  • 设计制作小车教学反思上海优化价格
  • vps怎么添加网站关键词可以分为哪三类
  • 移动微网站开发头条收录提交入口
  • 淘宝客为什么做网站交友网站有哪些
  • 网站改版 升级的目的是什么意思西安网站推广排名
  • 海丰网站建设排名优化公司哪家靠谱
  • 国外免备案域名seo定义
  • 建设制作网站aso优化分析
  • 简单详细搭建网站教程湖南株洲疫情最新情况
  • 做调查赚钱的网站又哪些小说推文万能关键词
  • 发布网站制作查网站权重
  • 日木女人做爰视频网站怎样制作一个自己的网站
  • 做网站的图片房产搜索广告和信息流广告区别