Skip to main content

Marshio

springboot-demo
A springboot project for dependencies usage
My Site
未完成备案,暂不支持访问
bookshelf
Detailed description of the book
yuque
Detailed description of the article
steam
Detailed description of the article
Git Troubleshooting

fatal: refusing to merge unrelated histories

root@root-Bro demo-gradle % git pull origin main
From github.com:imarshio/dmeo-gradle
 * branch            main       -> FETCH_HEAD
fatal: refusing to merge unrelated histories

# 使用 --allow-unrelated-histories 来避免
root@root-Bro demo-gradle % git pull origin main --allow-unrelated-histories
From github.com:imarshio/dmeo-gradle
 * branch            main       -> FETCH_HEAD
hint: Waiting for your editor to close the file... error: There was a problem with the editor 'vi'.
Not committing merge; use 'git commit' to complete the merge.

# 后面只需要在处理一下冲突,在 commit-push 一下就好了

MarshioLess than 1 minutegit
JVM 是什么

Java 虚拟机是一台包含类加载、运行时数据区、垃圾收集算法、Java 虚拟机指令优化等功能的一台【虚拟机】,就像一个接口,只是定义了一些方法和参数类型等,但是其内部的具体实现是没有的。

所以,说 Hotspot 是 Java 虚拟机没错,但是如果说 Java 虚拟机就是 Hotspot 则是错的,因为 Hotspot 虚拟机只是 Oracle JDK 的实现罢了,曾经的我也一度以为 Java 虚拟机就是 Hotspot ,Hotspot 就是 Java 虚拟机,后来也是在拜读了周志明老师的《深入理解Java虚拟机:JVM高级特性与最佳实践》一书后恍然。

此处引用官方对 Java 虚拟机的描述即


MarshioAbout 1 minjavabase
Java 中的类加载机制

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

加载(Loading)

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


MarshioAbout 6 minjavabase
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