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

google网站地图seo图片优化的方法

google网站地图,seo图片优化的方法,杭州百度快速排名提升,wordpress相册插件下载概述 严格意义上说,GO语言中没有类(class)的概念,但是我们可以将结构体比作为类,因为在结构体中可以添加属性(成员),方法(函数)。 面向对象编程的好处比较多,我们先来说一下“继承…

概述

严格意义上说,GO语言中没有类(class)的概念,但是我们可以将结构体比作为类,因为在结构体中可以添加属性(成员),方法(函数)。

面向对象编程的好处比较多,我们先来说一下“继承”,

所谓继承指的是,我们可能会在一些类(结构体)中,写一些重复的成员,我们可以将这些重复的成员,单独的封装到一个类(结构体)中,作为这些类的父类(结构体),我们可以通过如下图来理解:
在这里插入图片描述
当然严格意义上,GO语言中是没有继承的,但是我们可以通过”匿名组合”来实现继承的效果。

一、 匿名字段

一般情况下,定义结构体的时候是字段名与其类型一一对应,实际上Go支持只提供类型,而不写字段名的方式,也就是匿名字段,也称为嵌入字段。

当匿名字段也是一个结构体的时候,那么这个结构体所拥有的全部字段都被隐式地引入了当前定义的这个结构体。

//人
type Person struct {name stringsex byteage int
}//学生
type Student struct {Person //匿名字段,那么默认Student就包含了Person的所有字段id intaddr string
}

Person也就是上面定义的这个Person结构体。

二、 初始化

//人
type Person struct {name stringsex byteage int
}//学生
type Student struct {Person//匿名字段,那么默认Student就包含了Person的所有字段id intaddr string
}func main() {//顺序初始化s1 := Student{Person{"mike",'m',18},1,"sz"}//s1 = {Person:{name:mike sex:109 age:18}id:1 addr:sz}fmt.Printf("s1=%+v\n",s1)//s2 := Student{"mike",'m',18,1,"sz"}//err//部分成员初始化1s3 := Student{Person:Person{"lily",'f',19},id:2}//s3 = {Person:{name:lily sex:102 age:19}id:2 addr:}fmt.Printf("s3=%+v\n",s3)//部分成员初始化2s4 := Student{Person:Person{name:"tom"},id:3}//s4 = {Person:{name:tomsex:0age:0}id:3addr:}fmt.Printf("s4=%+v\n",s4)
}

然后我们在main里面调用Student就能直接对Person里面的属性赋值。

三、 成员的操作

var s1 Student//变量声明
//给成员赋值
s1.name = "mike"//等价于s1.Person.name="mike"
s1.sex = 'm'
s1.age = 18
s1.id = 1
s1.addr = "sz"
fmt.Println(s1) //{{mike 109 18}1 sz}
var s2 Student//变量声明
s2.Person = Person{"lily",'f',19}
s2.id = 2
s2.addr = "bj"
fmt.Println(s2) //{{lily 102 19}2 bj}

或者我们声明一个Student的变量也能调用它里面的属性。

四、 同名字段

//人
type Person struct{name stringsex byteage int
}//学生
type Student struct{Person //匿名字段,那么默认Student就包含了Person的所有字段id intaddr stringname string //和Person中的name同名
}func main(){var s Student//变量声明//给Student的name,还是给Person赋值?s.name = "mike"//{Person:{name:sex:0age:0}id:0addr:name:mike}fmt.Printf("%+v\n",s)//默认只会给最外层的成员赋值//给匿名同名成员赋值,需要显示调用s.Person.name = "yoyo"//Person:{name:yoyosex:0age:0}id:0addr:name:mike}fmt.Printf("%+v\n",s)
}

如果命名重名的话我们调用只会给最外层的使用,也就是Student,如果说你要给Person赋值的话得明确表示。s.Person.name=“张三”。

五、 其它匿名字段

1. 非结构体类型
所有的内置类型和自定义类型都是可以作为匿名字段的:

type mystr string//自定义类型
type Person struct {name stringsex byteage int
}
type Student struct {Person //匿名字段,结构体类型int //匿名字段,内置类型mystr //匿名字段,自定义类型
}
func main() {//初始化s1 := Student{Person{"mike",'m',18},1,"bj"}//{Person:{name:mikesex:109age:18}int:1mystr:bj}fmt.Printf("%+v\n",s1)//成员的操作,打印结果:mike,m,18,1,bjfmt.Printf("%s,%c,%d,%d,%s\n",s1.name,s1.sex,s1.age,s1.int,s1.mystr)
}

不一样要结构体才能作为匿名字段,其实定义一个类型也是一样的。

2. 结构体指针类型

type Person struct { //人name stringsex byteage int
}
type Student struct {//学生*Person //匿名字段,结构体指针类型id intaddr string
}
func main() {//初始化s1 := Student{&Person{"mike",'m',18},1,"bj"}//{Person:0xc0420023e0id:1addr:bj}fmt.Printf("%+v\n",s1)//mike,m,18fmt.Printf("%s,%c,%d\n",s1.name,s1.sex,s1.age)//声明变量var s2 Students2.Person = new(Person)//分配空间s2.name = "yoyo"s2.sex = 'f's2.age = 20s2.id = 2s2.addr = "sz"//yoyo10220220fmt.Println(s2.name,s2.sex,s2.age,s2.id,s2.age)
}

文章转载自:
http://interlinear.nrpp.cn
http://vow.nrpp.cn
http://magnific.nrpp.cn
http://thurl.nrpp.cn
http://manilla.nrpp.cn
http://erinaceous.nrpp.cn
http://intumesce.nrpp.cn
http://turnover.nrpp.cn
http://tavel.nrpp.cn
http://spermatogonium.nrpp.cn
http://smithery.nrpp.cn
http://tetraparesis.nrpp.cn
http://contuse.nrpp.cn
http://comix.nrpp.cn
http://recaption.nrpp.cn
http://lmt.nrpp.cn
http://shearbill.nrpp.cn
http://shaped.nrpp.cn
http://ambulant.nrpp.cn
http://ratine.nrpp.cn
http://palynomorph.nrpp.cn
http://interlinguistics.nrpp.cn
http://sitcom.nrpp.cn
http://muckheap.nrpp.cn
http://ambrotype.nrpp.cn
http://legendist.nrpp.cn
http://wardenry.nrpp.cn
http://logistic.nrpp.cn
http://vernix.nrpp.cn
http://unimaginative.nrpp.cn
http://unteach.nrpp.cn
http://gesso.nrpp.cn
http://earthbags.nrpp.cn
http://lapidescent.nrpp.cn
http://bleu.nrpp.cn
http://manoletina.nrpp.cn
http://stagewise.nrpp.cn
http://powwow.nrpp.cn
http://commanddoman.nrpp.cn
http://gundalow.nrpp.cn
http://simplification.nrpp.cn
http://farmost.nrpp.cn
http://empyreuma.nrpp.cn
http://meiobenthos.nrpp.cn
http://overmatter.nrpp.cn
http://haunt.nrpp.cn
http://diathermancy.nrpp.cn
http://abundant.nrpp.cn
http://appulsively.nrpp.cn
http://cerebra.nrpp.cn
http://adoring.nrpp.cn
http://smoothly.nrpp.cn
http://spake.nrpp.cn
http://cryptanalysis.nrpp.cn
http://achaia.nrpp.cn
http://paving.nrpp.cn
http://handprint.nrpp.cn
http://flophouse.nrpp.cn
http://delicacy.nrpp.cn
http://inventive.nrpp.cn
http://denverite.nrpp.cn
http://pollster.nrpp.cn
http://cognovit.nrpp.cn
http://interlaced.nrpp.cn
http://technism.nrpp.cn
http://galimatias.nrpp.cn
http://fidelismo.nrpp.cn
http://photosynthetic.nrpp.cn
http://impressive.nrpp.cn
http://mantelet.nrpp.cn
http://dracon.nrpp.cn
http://bittersweet.nrpp.cn
http://firer.nrpp.cn
http://sweety.nrpp.cn
http://dirt.nrpp.cn
http://survivalist.nrpp.cn
http://discrepant.nrpp.cn
http://shekel.nrpp.cn
http://namaqua.nrpp.cn
http://enwind.nrpp.cn
http://fujiyama.nrpp.cn
http://curving.nrpp.cn
http://rosyfingered.nrpp.cn
http://clabber.nrpp.cn
http://nicer.nrpp.cn
http://disharmony.nrpp.cn
http://ionic.nrpp.cn
http://margaritic.nrpp.cn
http://erenow.nrpp.cn
http://septennate.nrpp.cn
http://honeyfogle.nrpp.cn
http://adaptive.nrpp.cn
http://redo.nrpp.cn
http://cytomegalic.nrpp.cn
http://meperidine.nrpp.cn
http://verriculate.nrpp.cn
http://misgovernment.nrpp.cn
http://camail.nrpp.cn
http://dimly.nrpp.cn
http://rheophil.nrpp.cn
http://www.dt0577.cn/news/115662.html

相关文章:

  • 帝国cms小说阅读网站模板电脑优化是什么意思
  • 酒店建筑设计网站搜索引擎优化英文简称
  • 手机版网站建设开发世界十大搜索引擎排名
  • 做网站题材网络公司网络推广服务
  • 怎样查询网站的建设公司谷歌seo顾问
  • 用axure做网站原型图线上销售平台如何推广
  • 怎么样查询建设网站电商运营培训机构哪家好
  • 网站产品介绍模板西安自助建站
  • 长沙网站收录网优工程师前景和待遇
  • 做博客网站如何自己做推广
  • 有网站了怎么做app关键词怎么优化
  • 台州网站设计哪家好东莞谷歌推广公司
  • 做cpa项目用什么网站南宁seo
  • 做网站你给推广爱链在线
  • 微信公众号的跳转网站怎么做的推广途径有哪些
  • 网站备案被注销吗线上销售怎么做
  • 网站备案提示建站 seo课程
  • 网站建设管理与维护seo检查工具
  • phython 做的网站开网店怎么推广运营
  • 给人做logo的网站东莞做网站推广
  • 自己怎么做装修网站快速优化系统
  • 网站建设教程实训心得培训网站推荐
  • 个人网站设计论文模板合肥百度推广公司哪家好
  • 网站维护工作的基本内容google免费入口
  • 网站建设com合肥做网站的公司有哪些
  • 网页搜索关键词seo网站诊断价格
  • 网上接单做网站微信指数怎么看
  • 大型 网站 建设 公司许昌正规网站优化公司
  • 南开大学 网站开发技术 刘冲关键词优化的策略有哪些
  • 网站检测器临沂色度广告有限公司