首页 > 其他分享 >[区块链Go]Vscode编写工具与main()函数

[区块链Go]Vscode编写工具与main()函数

时间:2022-10-20 21:31:29浏览次数:92  
标签:函数 编辑 Vscode fmt Println Go main 下载

 

[区块链Go]Vscode编写工具与main()函数_go

[区块链Go]Vscode编写工具与main()函数_区块链_02

​编辑

 往期文章

​[区块链go]windows系统中安装Go与环境变量配置​


目录

​ Vscode工具​

​main()函数​


 Vscode工具

​下载链接​

下载并安装完成后下载我们需要下载一些插件

受限需要下载一个 中文插件。

[区块链Go]Vscode编写工具与main()函数_主函数_03

[区块链Go]Vscode编写工具与main()函数_主函数_04

​编辑

 然后下载go语言在vscode编写时所需要的一个环境依赖。

[区块链Go]Vscode编写工具与main()函数_区块链_05

[区块链Go]Vscode编写工具与main()函数_主函数_06

编辑

 最后我们需要在下载一个插件方便我们运行查看编译结果。

[区块链Go]Vscode编写工具与main()函数_main函数_07

[区块链Go]Vscode编写工具与main()函数_main函数_08

​编辑

 然后我们就可以开始编写了。

main()函数

main函数只能声明在main包中。

package main     //声明包

import "fmt" //引入包

func main(){ //函数
fmt.Println("hello world")
}
//main函数必须放在main包中

[区块链Go]Vscode编写工具与main()函数_Go_09

点击箭头进行运行。 

[区块链Go]Vscode编写工具与main()函数_区块链_10

[区块链Go]Vscode编写工具与main()函数_Go_11

​编辑

[区块链Go]Vscode编写工具与main()函数_go_12

[区块链Go]Vscode编写工具与main()函数_Go_13

编辑

 Println  将结果输出到控制台并换行。

定义多个main函数

package main     //声明包

import "fmt" //引入包

func main(){ //函数
fmt.Println("hello world")
}
func main() { //函数
fmt.Println("hello world") //语句&表达式输出
}
//main函数必须放在main包中

[区块链Go]Vscode编写工具与main()函数_main函数_14

[区块链Go]Vscode编写工具与main()函数_主函数_15

[区块链Go]Vscode编写工具与main()函数_Go_16

​编辑

没有main函数

func test(){  //函数
fmt.Println("hello world")
}

[区块链Go]Vscode编写工具与main()函数_区块链_17

[区块链Go]Vscode编写工具与main()函数_go_18

[区块链Go]Vscode编写工具与main()函数_Go_19

​编辑

注:只能定义一个main主函数,并且也必须有main主函数作为入口函数,如果没有main函数或者有多个main函数,都会出错。


标签:函数,编辑,Vscode,fmt,Println,Go,main,下载
From: https://blog.51cto.com/u_15830125/5780589

相关文章

  • 解决Go程序可执行文件在alpine容器中无法运行
    Go可执行程序在alpine容器中无法运行的问题解决今天遇到一个问题,我把我的go应用编译好之后,在Dockerfile里指定它到容器中启动,但是启动不起来,我通过测试,发现了这个现象:我......
  • 项目开发神器VsCode配置指南!(含C++、Python、Java环境配置)
    作者:吴忠强,东北大学,Datawhale成员本篇文章虽然是VsCode挂名,但其实介绍了两款神器:Vscode和Vim,这两个结合起来,开发效率蹭蹭蹭!!!之前接触过VsCode但很少用。总感觉写Python......
  • Google Analytics 测试
    集成谷歌分析之后官方提供了测试工具——DebugView可以通过这个工具验证sdk集成的是否正确官方文档:https://firebase.google.com/docs/analytics/debugview测试步骤:......
  • 字段加密实践(django-fernet-fields)
    一、fernet介绍Fernet用于django模型字段对称加密,使用crytography库。官网帮助文档1、先决条件django-fernet-fields支持Django1.8.2以及更高版本,Python2.7、3......
  • Django启动问题大杂烩
    1.ProgrammingErrorat/admin/login/(1146,"Table'mes.auth_user'doesn'texist") 解决办法:输入命令:pythonmanage.pymigrate   更新数据库表单......
  • 记录python3.7版本中 Django+celery 启动报错
     虚拟环境启动I报错Traceback(mostrecentcalllast):File"/data/.virtualenvs/cmdb/lib/python3.7/site-packages/gunicorn/arbiter.py",line589,inspawn_w......
  • vscode怎么使用滚轮调整字体大小
    在使用webstorm的时候,可以使用滚轮调整字体大小,习惯之后,在vscode中总是在设置中调整字体大小,感觉很不方便。后面发现可以通过设置通过鼠标滚轮滑动来调整字体大小。步骤如......
  • Django初始化创建用户名
    (venv)D:\project\py37project\Djangopro\Procrm>Pythonmanage.pycreatesuperuser  #这是创建Django初始化用户名跟密码的一个命令。示例如下:Username(leavebla......
  • Django Rest Framework中文文档:Serializer relations
    这是对DRF官方文档:Serializerrelations的翻译,根据个人的理解对内容做了些补充、修改和整理。一,django模型间的关系在我们对数据进行建模时,最重要的一点就是根据功能需求......
  • 华科golang详细示例代码
    packagemainimport("net/url""net/http""bytes""fmt""io/ioutil")constProxyServer="ip.hahado.cn:39010"typeProxyAut......