Skip to main content
Go Base

Currently, the version of Go is 1.22

Go 数据类型

Go Type

基础类型

Go语言中,基础类型有如下这些

<!--  布尔 -->
bool
<!--  字符-->
string

<!--  有符号整数-->
int  int8  int16  int32  int64

<!--  无符号整数-->
uint uint8 uint16 uint32 uint64 uintptr

<!--  字节-->
byte // alias for uint8

<!--  -->
rune // alias for int32
     // represents a Unicode code point

<!--  浮点型-->
float32 float64

<!--  -->
complex64 complex128

MarshioAbout 3 mingobase
Go build

Currently, the version of Go is 1.22

Go build 命令


MarshioLess than 1 minutegobase
Go Code Style

Currently, the version of Go is 1.22

Go 开发规范

Go Code Style

以下是我个人精简后的规范

package命名

package 名称应该与文件名一致(虽然 go 可以使 package 名与文件名不一致,但是不建议这样做),并且以小写字母开头。

使用下划线命名法(Underscore Naming Convention), 在多个单词之间使用下划线作为分隔符,每个单词全部小写。


MarshioLess than 1 minutegobase
Go mod

Currently, the version of Go is 1.22

Go mod 命令

Go mod 文件组成

// go.mod 文件是 go 用于依赖管理的文件
// 可以通过 go mod init 来创建该文件

// 模块名称
module go-demo

// go sdk version
go 1.22

// 第三方依赖
require (
	// dependency latest
)

// 排除以来继承里不需要的依赖
exclude (
	// dependency latest
)

// 修改依赖包的路径
// 依赖包发生迁移
// 原始包无法使用
// 使用本地包

// 即当依赖包不可用时,可以使用 replace 替换依赖包
replace (
	// source latest => target latest
)

// 撤回
// 如,当前项目作为其他项目的依赖,如果当前版本出现问题,则回退到指定的版本
retract (
)

MarshioAbout 1 mingobase
Go run

Currently, the version of Go is 1.22

Go run 命令


MarshioLess than 1 minutegobase
Java JVM

简单来说,类加载就是Java将 .class 文件加载到程序内存中,随时准备被调用,其中所做的一些列动作就是类加载,包括加载连接初始化三个步骤,其中连接又分为验证准备解析三步。。

加载(Loading)

这是类加载的第一步,其作用是通过类的全限定名来获取定义该类的二进制字节流(编译好的 .class 文件),然后将这个字节流所代表的静态存储结构转化为方法区的运行时数据结构,最后在内存中生成一个代表这个类的 java.lang.Class 对象,作为方法区这个类的各种数据的访问入口。


MarshioAbout 3 minjavabase
Java Base

Currently, the latest version of Java is 24,the latest LTS (Long-Term Support) version is 21.


MarshioAbout 2 minjavabase
Java 中的类加载机制

简单来说,类加载就是Java将 .class 文件加载到程序内存中,随时准备被调用,其中所做的一些列动作就是类加载,包括加载连接初始化三个步骤,其中连接又分为验证准备解析三步。。

加载(Loading)

这是类加载的第一步,其作用是通过类的全限定名来获取定义该类的二进制字节流(编译好的 .class 文件),然后将这个字节流所代表的静态存储结构转化为方法区的运行时数据结构,最后在内存中生成一个代表这个类的 java.lang.Class 对象,作为方法区这个类的各种数据的访问入口。


MarshioAbout 3 minjavabase