当前位置:网站首页>Go package import mode member visibility
Go package import mode member visibility
2022-06-12 18:35:00 【Foxconn quality inspector zhangquandan】
Package import
1) Absolute path import
import(
go Standard package
Third party package
Local package
)2) Relative path import

If there are two bags , There's... In it Add Method , If you use point import , So use Add Which one to use in the end ? There will be problems , So this method is also less used .



Member visibility
Go Language uses the case of the initial letter of the name to judge the object ( Constant 、 Variable 、 function 、 type 、 Structure 、 Such method ) Access rights of , The initial capital letter indicates that it is visible outside the package ( Open ), Otherwise, it is only accessible in the package ( Inside ).
You can define some contents in the package that you don't want to be accessed from outside , Write a function for internal use , This involves the accessibility of the members in the package .
In bag Capital letters are visible outside the package , The lowercase initials can only be seen inside the package . It can be seen whether it is possible to call .
Function type visibility

If the invisible member wants to be called , It can be used in visible members , This can be used by callers outside the package .

Variable type accessibility


Changing this variable outside will also affect the variable inside the package , If it is lowercase, it cannot be accessed outside the package .
边栏推荐
- Installation and configuration of window version pytorch entry depth learning environment
- JS中的数组(含leetcode例题)<持续更新~>
- [Huawei cloud stack] [shelf presence] issue 10: difficulties and solutions of it monitoring and diagnosis in the cloud scenario of government enterprise hybrid in the cloud native Era
- General differences between SQL server versions released by Microsoft in different periods so far, for reference
- Mysql ->>符号用法 Json相关
- 迄今微软不同时期发布的SQL Server各版本之间的大致区别,供参考查阅
- Implementing reflexive ACL in Cisco packet tracker
- Introduction to reinforcement learning and analysis of classic items 1.3
- Random talk about redis source code 91
- dumi 搭建文档型博客
猜你喜欢

干货 | 一文搞定 pytest 自动化测试框架(二)

A story on the cloud of the Centennial Olympic Games belonging to Alibaba cloud video cloud

C language learning -- data storage in memory

Gospel of audio and video developers, rapid integration of AI dubbing capability

js求斐波那契数列

The difference between user status and system status in CRM

基于Halcon的矩形卡片【手动绘制ROI】的自由测量

Gd32f4xx controls dgus variable display

间隔两个月,我的第二次上榜纪念日【2022.6.2】

Typescript common types (I)
随机推荐
Mise en œuvre de l'ACL réflexe dans le simulateur Cisco Cisco Packet Tracer
标准库template学习入门原创
Title 54: take 4 ~ 7 bits of an integer a from the right end.
Introduction to service grid and istio - continued
The difference between user status and system status in CRM
Arrays in JS (including leetcode examples) < continuous update ~>
GD32F4xx 与符合DLT645的电能表通信_2
232-CH579M学习开发-以太网例程-TCP服务器(项目应用封装,局域网或广域网测试)
js求斐波那契数列
JS for Fibonacci sequence
2022.6.12-----leetcode. eight hundred and ninety
Difference between rxjs of() and of ({})
Use of nexttick function
Two months later, my second listing anniversary [June 2, 2022]
用一个性能提升了666倍的小案例说明在TiDB中正确使用索引的重要性
Review of MySQL (VII): use of tables
When openharmony meets openeuler
Stack in JS (including leetcode examples) < continuous update ~>
在思科模拟器Cisco Packet Tracer实现自反ACL
Problems that the sap Spartacus e-commerce cloud UI shipping method does not display in the unit test environment