Go Core - Entity
|Word Count:0|Reading Time:1mins
Author: zhongmingmao
Copyright Notice: All articles on this blog are licensed under CC BY-NC-SA 4.0 unless otherwise stated.
Related Articles

2022-05-15
Go Core - Array + Slice

2022-05-15
Go Core - List + Ring

2023-05-02
Go Engineering - Design Pattern
设计模式 创建型模式 提供了一种在创建对象的同时隐藏创建逻辑的方式 单例模式饿汉方式 在包被加载时创建 12345678910package singletontype Singleton struct {}var instance *Singleton = &Singleton{}func GetInstance() *Singleton { return instance} 懒汉方式 在第一次使用时创建 - 使用最多,但非并发安全,需要加锁 不加锁1234567891011121314package singletontype Singleton struct {}var instance *Singleton// GetInstance is not thread-safefunc GetInstance() *Singleton { if instance == nil { instance = &Singleton{} ...

2022-04-16
Go Engineering - Foundation - API - RESTful
概述 REST:Representational state transfer REST 只是一种软件架构风格,是一组架构约束条件和原则,而不是技术框架 REST 有一系列规范,满足这些规范的 API 均可称为 RESTful API REST 规范把所有内容都视为资源,对资源的操作对应 HTTP 协议提供的 GET、POST、PUT 和 DELETE 方法 由于 REST 与 HTTP 协议相辅相成,因此 HTTP 协议已经成为 RESTful API 的事实标准 特点 以资源为中心,一切都可以抽象成资源,所有行为都是对资源的 CRUD 资源对应着面向对象范式里面的对象 资源使用 URI 标识,每个资源实例都有一个唯一的 URI 标识 资源是有状态的,使用 JSON/XML 等在 HTTP Body 里表征资源的状态 客户端通过 HTTP Method 对资源进行操作,实现 REST 无状态:每个 RESTful API 请求都包含了所有足够完成本次操作的信息,服务器无需保持 Session 无状态对于服务端的弹性扩容是很重要的 设计原则 RESTful API 的核心是规...

2023-05-05
Go Engineering - Makefile
基础语法 https://github.com/seisman/how-to-write-makefile 规则语法 伪目标 变量赋值 特殊变量 自动化变量 功能设计Target Target Desc gen Generate all necessary files, such as error code files. format Gofmt (reformat) package sources (exclude vendor dir if existed). lint Check syntax and styling of go sources. test Run unit test. cover Run unit test and get test coverage. build Build source code for host platform. build.multiarch Build source code for multiple platforms. See option PLATFORMS. image Build docker im...

2022-12-19
Go - Go Module
添加依赖 github.com/google/uuid main.go1234567891011package mainimport ( "github.com/google/uuid" "github.com/sirupsen/logrus")func main() { logrus.Println("hello, gomodule mode") logrus.Println(uuid.NewString())} go.mod 里的 require 字段中,没有任何 Module 提供了包 github.com/google/uuid 123$ go buildmain.go:4:2: no required module provides package github.com/google/uuid; to add it: go get github.com/google/uuid 手动 go get,下载依赖到本地 Module 缓存...
Announcement
Things are always unexpected!





