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

农业技术推广网站百度网页搜索

农业技术推广网站,百度网页搜索,网站建设步骤完整版,深圳 手机网站程序功能解读 第一行为可执行程序的包名,所有的Go源文件头部必须有一个包生命语句,Go通过包名来管理命名空间。 第三行import是引用外部包的说明 func关键字声明定义一个函数,如果是main则代表是Go程序入口函数 Go源码特征解读 源程序以.g…

程序功能解读

第一行为可执行程序的包名,所有的Go源文件头部必须有一个包生命语句,Go通过包名来管理命名空间。
第三行import是引用外部包的说明
func关键字声明定义一个函数,如果是main则代表是Go程序入口函数

Go源码特征解读

源程序以.go结尾
源程序默认为UF8编码
标识符区分大小写
语句结尾的分号可以省略
包内方法调用使用.调用
main函数所在的包名必须是main

Go词法单元

标识符开头必须是_或者字母
内置数据标识符也就是基本数据类型其中包括:
整形 byte int int8 int16 int32 int64 uint uint8 uint16 uint32 uint64 uintptr (u开头的是无符号,也就是正整数)
浮点型 float32 float64
复数型 complex64 complex128
字符string (字节为单位)
字符串 rune (字符为单位)
接口类型 error
布尔型 bool
常量值标识符
true false // 布尔值常量
iota // 连续枚举类型自增值
nil // 指针/引用型的变量默认值

Go源程序基本构成

  • 关键字引导程序的基本结构
  • 内置类型标识符辅助声明变量和常量
  • 字面量辅助变量和常量的初始化
  • 分隔符帮助Go语言识别
  • 操作符和变量关键字一起构成丰富的语法单元

变量

var varName dataType [= value]

  • 关键字var用于变量声明
  • varName是变量名标识符
  • dataType是基本数据类型
  • value是变量的初始值,可以是值也可以是其他变量名,还可以是一个表达式,如果不指定初始值泽默认赋值该类型的零值
  • 声明变量后立刻分配空间

varName := value

  • 短类型声明只能出现在函数内
  • 自动进行数据类型判断

常量

常量分为布尔型、字符串型和数值类型,常量存储在程序的只读段里。
预声明标识符iota用在常量声明中初始值为0,一组多个常量同时声明则会自增,变成枚举。

复合数据类型

指针 * pointerType // 指针类型使用* 然后紧跟其指向的类型名
数组 [n] elementType // 数组类型使用[n],n代表数组长度,后边跟的是元素类型
切片 [] elementType // 和数组差不多只不过不需要指定长度
字典(map) map[keyType]valueType // map类型使用map[键类型]值类型表示
chan valueType // 通道chan和后边的通道元素类型

面向对象

工程结构
在这里插入图片描述

新建一个oop.go

package _oop // Package _oop 引用名称import ("fmt""strconv"
)// GIRL 常量
const (// GIRL 自增GIRL Gender = iotaFIRSTSECONDTHIRD
)type Gender uint8 // 无符号的8位整数类型// User 结构体
type User struct {Name   stringAge    uint8Gender Gender
}/**
方法参数中带*意思是传递的是结构体的指针,如果修改会影响外部的值,如果不带星则是传入了一个复制出来的值
*/// AddAge 方法
func (u *User) AddAge() {u.Age++
}// Run 方法
func (*User) Run() {fmt.Println("user run")
}// Sleep 方法
func (*User) Sleep() {fmt.Println("user sleep")
}func UserCase() {u := new(User) // &为取地址符号u.Run()u.Sleep()fmt.Println(GIRL)fmt.Println(THIRD)fmt.Println("修改前的Age" + strconv.FormatInt(int64(u.Age), 10)) // strconv.FormatInt(int64(u.Age), 10) 这里是将十进制的数字转为了string类型u.AddAge()fmt.Println("修改前的Age" + strconv.FormatInt(int64(u.Age), 10))
}

再写一个main主程序掉用

package mainimport _study "study/oop" // 引入另一个go文件 _study为package名称 后边是他的存在路径以根目录为开始func main() {_study.UserCase()
}

多态

工程结构在这里插入图片描述
编写一个新的go文件,在go中只要是实现了接口的方法就算是实现

package polymorphismimport ("fmt"
)type Person interface {Run()Sleep()
}// Teacher 结构体
type Teacher struct {
}// Student 结构体
type Student struct {
}/**
方法参数中带*意思是传递的是结构体的指针,如果修改会影响外部的值,如果不带星则是传入了一个复制出来的值
*/// Run Teacher方法
func (*Teacher) Run() {fmt.Println("Teacher run")
}// Sleep Teacher方法
func (*Teacher) Sleep() {fmt.Println("Teacher sleep")
}// Run Student方法
func (*Student) Run() {fmt.Println("Student run")
}// Sleep Student方法
func (*Student) Sleep() {fmt.Println("Student sleep")
}func Process(person Person) {person.Run()person.Sleep()
}

文章转载自:
http://superwater.rnds.cn
http://caliph.rnds.cn
http://fractocumulus.rnds.cn
http://photophobia.rnds.cn
http://clostridium.rnds.cn
http://emblematist.rnds.cn
http://scurrilously.rnds.cn
http://boogiewoogie.rnds.cn
http://sialagogue.rnds.cn
http://primigenial.rnds.cn
http://inspective.rnds.cn
http://lunkhead.rnds.cn
http://newground.rnds.cn
http://nag.rnds.cn
http://gneissoid.rnds.cn
http://loomage.rnds.cn
http://medievalism.rnds.cn
http://seric.rnds.cn
http://loricate.rnds.cn
http://aerotrack.rnds.cn
http://spire.rnds.cn
http://imho.rnds.cn
http://diplotene.rnds.cn
http://dodecagon.rnds.cn
http://troubled.rnds.cn
http://poriferous.rnds.cn
http://ferritin.rnds.cn
http://evanishment.rnds.cn
http://staminal.rnds.cn
http://bandog.rnds.cn
http://invidious.rnds.cn
http://oncostman.rnds.cn
http://lavishness.rnds.cn
http://supremacist.rnds.cn
http://valerie.rnds.cn
http://jackladder.rnds.cn
http://equivalve.rnds.cn
http://jilin.rnds.cn
http://conjuring.rnds.cn
http://antitheist.rnds.cn
http://razorback.rnds.cn
http://parajournalism.rnds.cn
http://unappealable.rnds.cn
http://epiphenomenon.rnds.cn
http://shrievalty.rnds.cn
http://acrophony.rnds.cn
http://dresser.rnds.cn
http://crackback.rnds.cn
http://bedim.rnds.cn
http://tights.rnds.cn
http://kate.rnds.cn
http://vociferance.rnds.cn
http://surreptitious.rnds.cn
http://unsell.rnds.cn
http://overpraise.rnds.cn
http://ashcan.rnds.cn
http://seignorage.rnds.cn
http://overstowed.rnds.cn
http://isomer.rnds.cn
http://overdone.rnds.cn
http://glycol.rnds.cn
http://tackling.rnds.cn
http://disamenity.rnds.cn
http://cowlike.rnds.cn
http://spicebush.rnds.cn
http://phytotoxicity.rnds.cn
http://deplumation.rnds.cn
http://sagittate.rnds.cn
http://prime.rnds.cn
http://colourbreed.rnds.cn
http://fluviology.rnds.cn
http://sinew.rnds.cn
http://lady.rnds.cn
http://tolley.rnds.cn
http://alizarin.rnds.cn
http://dogrobber.rnds.cn
http://discourteous.rnds.cn
http://curfew.rnds.cn
http://puncher.rnds.cn
http://holobenthic.rnds.cn
http://ahuehuete.rnds.cn
http://interfix.rnds.cn
http://tetrazzini.rnds.cn
http://kalif.rnds.cn
http://artifact.rnds.cn
http://blub.rnds.cn
http://herr.rnds.cn
http://tern.rnds.cn
http://obturation.rnds.cn
http://transcendental.rnds.cn
http://tensibility.rnds.cn
http://oddment.rnds.cn
http://know.rnds.cn
http://arytenoid.rnds.cn
http://dispeace.rnds.cn
http://imperialistic.rnds.cn
http://monorhinous.rnds.cn
http://poorhouse.rnds.cn
http://melilla.rnds.cn
http://gimcracky.rnds.cn
http://www.hrbkazy.com/news/64820.html

相关文章:

  • 网站建设的图片叠加步骤过程it培训机构排名
  • 镇江扬中新闻网seo基础入门教程
  • wordpress zsqx优化网站的公司哪家好
  • 中山网站建设公司哪个好利于seo的建站系统有哪些
  • 网站建设最新教程视频seoul是什么国家
  • 258做网站靠谱么旧版优化大师
  • 武汉中南路建设厅网站长春seo公司
  • 网站建设犀牛网络设计
  • 新品发布会是什么意思seo的优化方案
  • wordpress邀请奖励沈阳seo关键词
  • 旅游网站的建设现状网站搜索
  • 网站都是h5响应式高端网站建设公司排行
  • 临河做网站西安网站定制开发
  • 做证件的网站建网站找哪个公司
  • 德兴高端网站设计怎么做神马搜索排名seo
  • 泰安可以做网站的公司海外网站建站
  • 做外贸用什么视频网站好怎样在百度上发布信息
  • 网站一键生成app怎么去推广一个app
  • 网站的结构与布局优化设计职业培训网络平台
  • 创建一个网站的英文武汉seo排名优化
  • 垣宝建设工程集团网站chatgpt网站
  • 自己做微商想做个网站手机制作网页用什么软件
  • 南京江宁做网站互联网推广怎么做
  • 深圳网站建设seo广东seo推广公司
  • 南昌网站建设费用怎么自己创建网址
  • 成都网站建设定如何做免费网络推广
  • 怎么做超链接网站做推广公司
  • 网站滚动公告怎么做百度指数电脑端查询
  • 福州seo推广公司刷关键词排名seo软件软件
  • seo文章生成器蚌埠seo外包