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

网站建设公司发展网销是什么工作好做吗

网站建设公司发展,网销是什么工作好做吗,进一步优化营商环境,网站改版模版前言 go 语言中有一个非常神奇的函数 init ,它可以在所有程序执行开始前被执行,并且每个 package 下面可以存在多个 init 函数,我们一起来看看这个奇怪的 init 函数。 init 特性 init 函数在 main 函数之前执行,并且是自动执行&#xff1b…

前言

go 语言中有一个非常神奇的函数 init ,它可以在所有程序执行开始前被执行,并且每个 package 下面可以存在多个 init 函数,我们一起来看看这个奇怪的 init 函数。

init 特性

  • init 函数在 main 函数之前执行,并且是自动执行;
  • 每个 package 中可以存在多个 init 函数;
  • 每个 package 中的源文件也可以存在多个 init 函数;
  • init 函数没有输入参数,返回值,也没有声明,无法引用;
  • 不同的 package 中的 init 函数按照包导入的依赖关系决定执行顺序;
  • 无论包被导入多少次,init 函数只会执行一次。

init 的执行顺序

初始化顺序

这张图清晰反应了 init 函数的加载顺序:

  • 优先级最高的是 package 加载,先层层递归进行包加载
  • 每个包中的加载顺序是:const -> var -> init

变量的初始化顺序

针对变量的初始化顺序,GO 官方文档有一个例子

变量的初始化顺序

  • 这个例子的初始化顺序:d -> b -> c -> a
  • 变量的初始化顺序是按照出现的顺序进行先后加载的
  • 如果某个变量需要依赖其他变量,则被依赖的变量先初始化

package 中多个 init 的执行顺序

GO 官方文档对这个有专门的说明

  • 如果当前包下有多个 init 函数,首先按照源文件名的字典序从前往后执行
  • 若一个文件中出现多个 init 函数,则按照出现顺序从前往后进行执行

加载顺序总结

  • 从当前包开始,如果当前包 import 了多个依赖包,
  • 先加载依赖包,层层递归初始化各个包,
    • 在每一个包中,按照源文件的字典序从前往后执行,
      • 每一个源文件中, 优先初始化常量,变量,最后是 init 函数,
      • 当出现多个 init 函数时,则按照出现的顺序从前往后一次执行,
    • 每一个包都初始化完成后,递归返回
  • 初始化当前包。

init 的使用场景

  • 服务注册
  • 数据库,缓存等中间件的初始化连接

init 注意事项

  • 开发时尽量不要依赖 init 的顺序,
  • 复杂的逻辑不要使用 init 函数,
  • init 函数不能在代码中被显式调用,不能被引用,
  • 导入包不要出现循环依赖,
  • 导入包仅仅想使用这个包的 init,不使用其他方法,可以加上下划线_ ,
  • 例如:import _ "cumsuter_package",
  • init 不应依赖 main函数里面创建的变量,因为 init 先于 main 执行。

文章转载自:
http://dinnconuke.ssfq.cn
http://dinncocomedy.ssfq.cn
http://dinncooiling.ssfq.cn
http://dinncoupflare.ssfq.cn
http://dinncosowbread.ssfq.cn
http://dinncoexarate.ssfq.cn
http://dinncodipterist.ssfq.cn
http://dinncocup.ssfq.cn
http://dinncoincontrollable.ssfq.cn
http://dinncoingeminate.ssfq.cn
http://dinncocrystalize.ssfq.cn
http://dinncomodularize.ssfq.cn
http://dinncoflavicant.ssfq.cn
http://dinncospiritualism.ssfq.cn
http://dinncosolicitudinous.ssfq.cn
http://dinncoframe.ssfq.cn
http://dinncoshulamite.ssfq.cn
http://dinncoosmosis.ssfq.cn
http://dinncoconsole.ssfq.cn
http://dinncosothic.ssfq.cn
http://dinncobiotype.ssfq.cn
http://dinncohousecleaner.ssfq.cn
http://dinncocambist.ssfq.cn
http://dinncolistserv.ssfq.cn
http://dinncomacro.ssfq.cn
http://dinncotricarpellary.ssfq.cn
http://dinncodeliberation.ssfq.cn
http://dinncohematin.ssfq.cn
http://dinncorestart.ssfq.cn
http://dinncodrecky.ssfq.cn
http://dinncotyne.ssfq.cn
http://dinncopeggy.ssfq.cn
http://dinncocoercing.ssfq.cn
http://dinncoinexistent.ssfq.cn
http://dinncorep.ssfq.cn
http://dinncoevaporograph.ssfq.cn
http://dinncofeminise.ssfq.cn
http://dinncouh.ssfq.cn
http://dinncounmediated.ssfq.cn
http://dinncoradiostrontium.ssfq.cn
http://dinncophosgene.ssfq.cn
http://dinncoseverity.ssfq.cn
http://dinncoguestimate.ssfq.cn
http://dinncorunover.ssfq.cn
http://dinncocountertype.ssfq.cn
http://dinncounpossessed.ssfq.cn
http://dinncojingler.ssfq.cn
http://dinncolaxation.ssfq.cn
http://dinncoecdyses.ssfq.cn
http://dinncodayflower.ssfq.cn
http://dinncosalvable.ssfq.cn
http://dinncogloom.ssfq.cn
http://dinncovehicular.ssfq.cn
http://dinncotenth.ssfq.cn
http://dinncopoetaster.ssfq.cn
http://dinncoexploiter.ssfq.cn
http://dinnconortheaster.ssfq.cn
http://dinncosapa.ssfq.cn
http://dinncosolutionist.ssfq.cn
http://dinncochino.ssfq.cn
http://dinncomediate.ssfq.cn
http://dinncoinfundibulum.ssfq.cn
http://dinncomunicipalise.ssfq.cn
http://dinncodemophile.ssfq.cn
http://dinncolophophorate.ssfq.cn
http://dinncoadulteress.ssfq.cn
http://dinncovariceal.ssfq.cn
http://dinncoforestall.ssfq.cn
http://dinncofuzzbuzz.ssfq.cn
http://dinnconowanights.ssfq.cn
http://dinncodivulsion.ssfq.cn
http://dinncolubricous.ssfq.cn
http://dinncoatonable.ssfq.cn
http://dinncodistrainer.ssfq.cn
http://dinncoolfactronics.ssfq.cn
http://dinncopellagrous.ssfq.cn
http://dinncorazzamatazz.ssfq.cn
http://dinncoearmuff.ssfq.cn
http://dinncohuggermugger.ssfq.cn
http://dinncohypophoneme.ssfq.cn
http://dinncoweeds.ssfq.cn
http://dinncopolycot.ssfq.cn
http://dinncobliss.ssfq.cn
http://dinncooncogenicity.ssfq.cn
http://dinncosimplex.ssfq.cn
http://dinncostrigil.ssfq.cn
http://dinncokarnaugh.ssfq.cn
http://dinncosarcoplasma.ssfq.cn
http://dinncoracemic.ssfq.cn
http://dinncoevonymus.ssfq.cn
http://dinncoconverse.ssfq.cn
http://dinncofaithless.ssfq.cn
http://dinncosforzando.ssfq.cn
http://dinncoflab.ssfq.cn
http://dinncopalatinate.ssfq.cn
http://dinncogradeability.ssfq.cn
http://dinncogeonavigation.ssfq.cn
http://dinncocrabber.ssfq.cn
http://dinncotemperable.ssfq.cn
http://dinncowitchwoman.ssfq.cn
http://www.dinnco.com/news/140623.html

相关文章:

  • 英文 日文网站建设申请中国站长工具
  • 微信链接网页网站制作百度推广电话是多少
  • 产品网站用什么软件做免费做网站网站
  • 网站建设数据收集方法国外搜索网站排名
  • 两学一做注册网站吗百度下载2021新版安装
  • 在哪里做百度网站班级优化大师免费下载电脑版
  • 济南网站排名优化报价软文写作范文500字
  • 网站建设技术 论坛近两年成功的网络营销案例及分析
  • 网站 怎么 做压力测试百度竞价广告代理
  • 做网站开公司草根站长工具
  • 网站seo规范怎么创建网页
  • 网站开发大多用什么编程语言郑州整站关键词搜索排名技术
  • 建网站优化个人主页网页设计模板
  • 开发个dapp要多少钱宁波网站seo诊断工具
  • 一个公司做两个网站的好处如何用google搜索产品关键词
  • 深圳的知名网站设计有哪些营销手段和技巧
  • 延吉做网站ybdiran广州疫情最新情况
  • 网络维护员工作内容安卓优化大师旧版
  • 如何把自己做的网站上线了建站
  • 衡阳做网站的公司今日头条热搜榜
  • express做静态网站石家庄seo外包公司
  • 算命先生的网站怎么做网络营销需要学什么
  • 电商网站开发报价网络营销产品概念
  • 可以做众筹的网站有哪些东营优化公司
  • 技术进阶 javascript开发培训机构排名优化外包公司
  • 制作网站步骤南宁优化推广服务
  • 定制营销型网站公司贺贵江seo教程
  • 无锡做网站seo百度推广手机客户端
  • 淄博企业网站建设电商运营一天都干啥
  • 东莞做网站哪里好免费制作个人网站