module go
Go 项目代码布局
Go 项目代码布局 目录Go 项目代码布局一、Go 语言“创世项目”结构1.1 src 目录结构三个特点二、Go 项目布局演进2.1 演进一:Go 1.4 版本删除 pkg 这一中间层目录并引入 internal 目录2.2 演进二:Go1.6 版本增加 vendor 目录2.3 演进三:Go 1. ......
Go基础之变量和常量
Go基础之变量和常量 目录Go基础之变量和常量一. 标识符、关键字、内置类型和函数1.1 标识符1.2 关键字1.3 保留字1.4 内置类型1.4.1 值类型:1.4.2 引用类型:(指针类型)1.5 内置函数1.6 内置接口error二.Go变量命名规范2.1 采用驼峰体命名2.2 简单、短小为首 ......
Go 常用命令介绍
Go 常用命令 目录Go 常用命令一、Go 常用命令1.1 go build1.1.1 指定输出目录1.1.2 常用环境变量设置编译操作系统和 CPU 架构1.1.3 查看支持的操作系统和CPU架构1.2 go test1.3 go vet1.4 go clean1.5 go fmt1.6 go g ......
Go 语言开发环境搭建
Go 语言开发环境搭建 目录Go 语言开发环境搭建一. GO 环境安装1.1 下载1.2 Go 版本的选择1.3 安装1.3.1 Windows安装1.3.2 Linux下安装1.3.2 Mac下安装1.4 验证Go安装二. Go 语言环境变量2,1 查看Go 环境变量2.2 常用Go 配置项2.3 ......
第一个 Go 程序"hello,world" 与 main 函数和Go常用基本命令
第一个 Go 程序"hello,world" 与 main 函数和Go常用基本命令 目录第一个 Go 程序"hello,world" 与 main 函数和Go常用基本命令一.创建“hello,world”示例程序二. “hello,world” 程序结构拆解三、main 函数四、Go 语言中程序是怎 ......
Go 多版本管理工具
Go 多版本管理工具 目录Go 多版本管理工具一、go get 命令1.1 使用方法:二、Goenv三、GVM (Go Version Manager)四、voidint/g4.1 安装4.2 冲突4.3 使用 在平时开发中,本地新旧项目并行开发的过程中,你大概率会遇到一个令人头疼的问题,如何同时使 ......
Go 语言的前生今世与介绍
Go 语言的前生今世与介绍 目录Go 语言的前生今世与介绍一. Go 语言的发展1.1 Go 语言是如何诞生的?1.2 Go语言的早期团队和演进历程1.3 Go语言正式发布并开源1.4 Go 语言的版本发展历史二. GO语言介绍2.0 Go 语言原则2.1 为什么需要 Go 语言?2.2 Go 设计 ......
Go - Composing Structs from Other Structs
Problem: You want a struct that has data and methods of another struct. Solution: Embed an unnamed struct within another struct. The outer struct will ......
Go - Creating One - Time Structs
person := struct { Id int Name string Email string }{ 1 , "Chang Sau Sheong" , "sausheong@email.com" } person = struct { Id int Name string Email stri ......
2023-10-07:用go语言,给定n个二维坐标,表示在二维平面的n个点, 坐标为double类型,精度最多小数点后两位, 希望在二维平面上画一个圆,圈住其中的k个点,其他的n-k个点都要在圆外。
2023-10-07:用go语言,给定n个二维坐标,表示在二维平面的n个点, 坐标为double类型,精度最多小数点后两位, 希望在二维平面上画一个圆,圈住其中的k个点,其他的n-k个点都要在圆外。 返回一个圆心和半径,表示哪个圆可以圈住其中的k个点。 坐标和半径都是double类型,最多保留小数点 ......
Go - Creating Struct Instances
Problem: You want to create an instance of a struct. Solution: Create a struct instance directly using the name of the struct, or a pointer to a struc ......
<class 'torch.nn.modules.conv.Conv1d'> torch.nn.Conv1d
1、Conv1d 定义class torch.nn.Conv1d(in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, bias=True) 自然语言处理中一个句子序列,一维的,所以使用C ......
go.搭建简单Gin项目
新建gin_demo project 获取gin框架: go get -u github.com/gin-gonic/gin 建一个main方法 package main import "github.com/gin-gonic/gin" import _ "net/http" func main( ......
Cannot find module ‘node:module‘ & "plugins" is not allowed 的解决办法
在写demo时,装了下t-design-vue2的框架,想做个按需加载,官网这样说 但是我运行以后发现报错了 Error: Cannot find module 'node:module' Require stack: - D:\ruanjian\nvm\v19.0.0\xiangmu\niu789 ......
超能组合:python 的开发效率 + go 的并发 + shell 的短小精悍
工具思维:利用合适的工具做合适的事情,然后合理地加以组合。 在”谈谈程序员应当具备的技术思维“一文中谈到了工具思维。本文对工具思维作一发挥运用。 批量下载图片 程序员总是有点”美图“爱好的。由于程序员通常又是比较”懒惰“的(可没有那个耐心和体力去一页页点开再点击按钮),那么,就会想到用程序来自动化拉 ......
Go - Parsing Time Displays Into Structs
func main () { str := "4:31am +0800 on Oct 1, 2021" layout := "3:04pm - 0700 on Jan 2, 2006" t , err := time . Parse ( layout , str ) if err != nil { ......
Go - Formatting time
func main () { t := time . Now () fmt . Println ( t . Format ( "3:04PM" )) fmt . Println ( t . Format ( "Jan 02, 2006" )) } When you run this you shou ......
Go - Measuring Lapsed Time
Problem: You want to measure the lapsed time and make sure that it is accurate. Solution: Use the monotonic clock in the Time struct to find the lapse ......
go语言ent教程:使用zerolog定制ent日志
背景:ent开始debug模式后,可以输出日志,但是我们想为ent接入zerolog,该怎么做呢? 一、引入zerolog go get -u github.com/rs/zerolog 二、自定义zerolog配置 customLog := func(args ...any) { str := f ......
go语言ent教程:开启debug调试模式
背景:ent模式是没有开启debug模式的 开启ent的调试模式有2种方法: 一、通过配置选项开启 client, err := ent.Open("mysql", "root:dev@123456@tcp(localhost:3306)/test?parseTime=True", ent.Debu ......
Go - Representing Duration
Problem: You want to specify a duration of time. Solution: Use the Duration type to represent a span of time. The main representation for a span of ti ......
Go - Representing Time Zones
Problem: You want to include the time zone information in a Time struct. Solution: The Time struct includes a Location , which is the representation o ......
vue-router.esm.js:2065 Uncaught (in promise) Error: Redirected when going from "/login?redirect=%2Fhome" to "/home" via a navigation guard.
原因: vue-router路由版本更新产生的问题,导致路由跳转失败抛出该错误; 真正的原因是由于返回了一个Promise对象, 正常的跳转由then方法执行 当正常的路由跳转, 被"路由导航守卫"拦截并重新指定路由时, 由于 this.$router.push() 返回的是Promise对象, 此 ......
kubelet.go 2466 Error getting node not found
kubeadm初始化kubernetes集群报错,kubelet服务提示:kubelet.go:2466] "Error getting node" err="node \"k8s3-master\" not found处理记录。 0. ENV kubernetes 1.22.x/1.23.x/1. ......
Go - Decoding Data with a Customized Binary Format to Structs
Problem: You want to decode the customized binary format back to structs. Solution: Use the encoding/binary package to take data from the binary forma ......
Go - Encoding Data to a Customized Binary Format
Problem: You want to encode struct data to a customized binary format. Solution: Design your customized format and use the encoding/binary package to ......
Go - Decoding gob Format Data to Structs
Problem: You want to decode gob format data back to structs. Solution: Use the encoding/gob package to decode the gob format data back to structs. fun ......
Go - Encoding Data to gob Format Data
Problem: You want to encode structs into binary gob format. Solution: Use the encoding/gob package to encode the structs into bytes that can be stored ......
2023-10-04:用go语言,现有一棵无向、无根的树,树中有 n 个节点,按从 0 到 n - 1 编号 给你一个整数 n 和一个长度为 n - 1 的二维整数数组 edges , 其中 edge
2023-10-04:用go语言,现有一棵无向、无根的树,树中有 n 个节点,按从 0 到 n - 1 编号 给你一个整数 n 和一个长度为 n - 1 的二维整数数组 edges , 其中 edges[i] = [ai, bi] 表示树中节点 ai 和 bi 之间存在一条边。 每个节点都关联一个价 ......
Angular 里的 Module 增强
Angular 模块增强:扩展你的数据模型 Angular 是一个强大的前端框架,但在某些情况下,我们可能需要对其内置模型进行一些自定义。这时,Angular 的模块增强(Module Augmentation)就派上了用场。在本文中,我们将深入研究 Angular 模块增强的细节,以及如何利用它来 ......