当前位置:网站首页>【GO记录】从零开始GO语言——用GO语言做一个示波器(一)GO语言基础
【GO记录】从零开始GO语言——用GO语言做一个示波器(一)GO语言基础
2022-07-07 22:28:00 【创客协会的阿蛋°】
今天参加了一个挑战,从零开始GO语言,一周时间用GO语言开发一个串口示波器。
目前没有接触过GO语言,只会C/C++,从零开始学GO,预计8小时速成。
学习视频用这个:学习视频
GO语言好处:简单易用。
大厂开路,有C基础容易起飞。
目标
GO语法:
GO语言的变量
类似于C语言的枚举:
返回两个值:


init和import导包


类似于include,在GO中叫导包




基本指针(学过C可以跳过)
defer(不是define)
以压栈形式最后执行。(大致就是在函数中设置一块栈,先执行先压进去,函数运行玩之后,在出栈,先进压在最后出)
遵循先进后出原则。


return后的语句先执行。defer最后执行。
for循环:
len计算数组长度:
数组长度要匹配

//传递的是引用传递,传的是指针(类似于数组名,类型是int[])

slice的四种方法:
%v是打印出变量variable的意思,连带输出[]。

四种声明slice的方式:
靠make()添加
slice切片追加与截取:
容量和长度是不一样的,

长度确实是3,但是容量是不合法的指针ptr外的值(由make第三个参数来决定),想要操作后面第一个个,得用append(切片名[],2)意思是向切片名追加一个值,为2,
再用append(切片名[],3)即可追加为操作第五个容量的数据,当到了第五个以上,再用append(切片名[],2)即可为开辟长度容量了,开辟大小为之前的cap的容量(一次性开辟了5个,在寸土寸金的单片机flash可不兴这么玩)
copy函数:
map的三种声明定义:
现在这个是一个空map(==nil(相当于中的NULL))
map用法:
边栏推荐
- "An excellent programmer is worth five ordinary programmers", and the gap lies in these seven key points
- 去了字节跳动,才知道年薪 40w 的测试工程师有这么多?
- Smart regulation enters the market, where will meituan and other Internet service platforms go
- 51与蓝牙模块通讯,51驱动蓝牙APP点灯
- Solution to prompt configure: error: curses library not found when configuring and installing crosstool ng tool
- 服务器防御DDOS的方法,杭州高防IP段103.219.39.x
- The standby database has been delayed. Check that the MRP is wait_ for_ Log, apply after restarting MRP_ Log but wait again later_ for_ log
- Single machine high concurrency model design
- [basis of recommendation system] sampling and construction of positive and negative samples
- 什么是负载均衡?DNS如何实现负载均衡?
猜你喜欢

第四期SFO销毁,Starfish OS如何对SFO价值赋能?
![[question de programmation] [scratch niveau 2] oiseaux volants en décembre 2019](/img/5e/a105f8615f3991635c9ffd3a8e5836.png)
[question de programmation] [scratch niveau 2] oiseaux volants en décembre 2019

C language 001: download, install, create the first C project and execute the first C language program of CodeBlocks
![[basis of recommendation system] sampling and construction of positive and negative samples](/img/4b/753a61b583cf38826b597fd31e5d20.png)
[basis of recommendation system] sampling and construction of positive and negative samples

Set up personal network disk with nextcloud

【测试面试题】页面很卡的原因分析及解决方案

单机高并发模型设计

Anaconda+pycharm+pyqt5 configuration problem: pyuic5 cannot be found exe

After going to ByteDance, I learned that there are so many test engineers with an annual salary of 40W?
![[programming problem] [scratch Level 2] draw ten squares in December 2019](/img/4f/14ea8e786b7f8b0a263aa5c55abf15.png)
[programming problem] [scratch Level 2] draw ten squares in December 2019
随机推荐
深潜Kotlin协程(二十三 完结篇):SharedFlow 和 StateFlow
paddle入门-使用LeNet在MNIST实现图像分类方法一
51与蓝牙模块通讯,51驱动蓝牙APP点灯
Common selectors are
每日刷题记录 (十六)
[question de programmation] [scratch niveau 2] oiseaux volants en décembre 2019
关于组织2021-2022全国青少年电子信息智能创新大赛西南赛区(四川)复赛的通知
[programming problem] [scratch Level 2] draw ten squares in December 2019
快速上手使用本地测试工具postman
How to learn a new technology (programming language)
Tools for debugging makefiles - tool for debugging makefiles
Les mots ont été écrits, la fonction est vraiment puissante!
赞!idea 如何单窗口打开多个项目?
Coindesk comments on the decentralization process of the wave field: let people see the future of the Internet
An error is reported during the process of setting up ADG. Rman-03009 ora-03113
The result of innovation in professional courses such as robotics (Automation)
[研发人员必备]paddle 如何制作自己的数据集,并显示。
Development of a horse tourism website (optimization of servlet)
Introduction to paddle - using lenet to realize image classification method I in MNIST
某马旅游网站开发(登录注册退出功能的实现)