go-gprc gprc go

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 ......
Creating Structs Time One Go

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 ......
Instances Creating Struct Go

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( ......
项目 Gin go

超能组合:python 的开发效率 + go 的并发 + shell 的短小精悍

工具思维:利用合适的工具做合适的事情,然后合理地加以组合。 在”谈谈程序员应当具备的技术思维“一文中谈到了工具思维。本文对工具思维作一发挥运用。 批量下载图片 程序员总是有点”美图“爱好的。由于程序员通常又是比较”懒惰“的(可没有那个耐心和体力去一页页点开再点击按钮),那么,就会想到用程序来自动化拉 ......
短小精悍 超能 效率 python 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 { ......
Displays Parsing Structs Into Time

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 ......
Formatting time Go

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 ......
Measuring Lapsed Time Go

go语言ent教程:使用zerolog定制ent日志

背景:ent开始debug模式后,可以输出日志,但是我们想为ent接入zerolog,该怎么做呢? 一、引入zerolog go get -u github.com/rs/zerolog 二、自定义zerolog配置 customLog := func(args ...any) { str := f ......
ent zerolog 语言 教程 日志

go语言ent教程:开启debug调试模式

背景:ent模式是没有开启debug模式的 开启ent的调试模式有2种方法: 一、通过配置选项开启 client, err := ent.Open("mysql", "root:dev@123456@tcp(localhost:3306)/test?parseTime=True", ent.Debu ......
语言 模式 教程 debug ent

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 ......
Representing Duration Go

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 ......
Representing Zones Time Go

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. ......
kubelet getting Error found 2466

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 ......
Customized Decoding Structs Binary Format

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 ......
Customized Encoding Binary Format Data

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 ......
Decoding Structs Format Data gob

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 ......
Data Encoding Format gob Go

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 之间存在一条边。 每个节点都关联一个价 ......
整数 数组 节点 长度 语言

go定时任务

目录go定时任务TimeNewTimerNewTickercron文档 go定时任务 Time NewTimer package main import ( "fmt" "time" ) func cronTimer() { /** timer定时器 实现一些定时操作 本质通过chan阻塞实现 且只 ......
任务

Go语言中泛型的一个用法

type OperationWithData[T any] func() (T, error) type Operation func() error func (o Operation) withEmptyData() OperationWithData[struct{}] { return fu ......
语言

Go - Creating JSON Data Streams from Structs

Problem: You want to create streaming JSON data from structs. Solution: Create an encoder using NewEncoder in the encoding/json package, passing it an ......
Creating Streams Structs Data JSON

Go - Creating JSON Data Byte Arrays from Structs

Problem: You want to create JSON data from a struct. Solution: Create the structs then use the json.Marshal or json.MarshalIndent to marshal the data ......
Creating Structs Arrays Byte Data

C PHP Go.md

C 语言 1.visual Studio lnstaller 安装 去官网下载后点击exe文件,在弹出的窗口中点击继续后,选择c++桌面开发并点击安装。 注册账号 登录vsl的时候需要登录账号,所以需要试用邮箱创建一个账号。 新建项目 点击新建项目后,再点击控制台应用并下一步,输入项目名称、路径、解 ......
PHP Go md

go-ethereum mint nft用户支付实现

代码: package main // 签名用的公钥私钥也是采用的owner的公钥私钥 import ( "context" "fmt" "math/big" "user-pay/triplec" "github.com/ethereum/go-ethereum/common" "github.co ......
go-ethereum ethereum 用户 mint nft

go-ethereum设置signer

设置代码: package main // 签名用的公钥私钥也是采用的owner的公钥私钥 import ( "fmt" "set_signer/triplec" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-eth ......
go-ethereum ethereum signer go

用go封装一下二级认证功能

本篇为[用go设计开发一个自己的轻量级登录库/框架吧 - 秋玻 - 博客园 (cnblogs.com)]的二级认证业务篇,会讲讲二级认证业务的实现,给库/框架增加新的功能。 源码:https://github.com/weloe/token-go ......
功能

5.go语言函数提纲

1 本篇前瞻 前端时间的繁忙,未曾更新go语言系列。由于函数非常重要,为此将本篇往前提一提,另外补充一些有关go新版本前面遗漏的部分。 需要恭喜你的事情是本篇学完,go语言中基础部分已经学完一半,这意味着你可以使用go语言去解决大部分的Leetcode的题,为此后面的1篇,将带领大家去巩固go语言的 ......
提纲 函数 语言 go

Go结构体深度探索:从基础到应用

在Go语言中,结构体是核心的数据组织工具,提供了灵活的手段来处理复杂数据。本文深入探讨了结构体的定义、类型、字面量表示和使用方法,旨在为读者呈现Go结构体的全面视角。通过结构体,开发者可以实现更加模块化、高效的代码设计。这篇文章旨在为您提供关于结构体的深入理解,助您更好地利用Go语言的强大功能。 关 ......
深度 结构 基础

Go每日一库之155:go-spew(输出 Go 数据结构)

对于应用的调试,我们经常会使用 fmt.Println来输出关键变量的数据。或者使用 log 库,将数据以 log 的形式输出。对于基础数据类型,上面两种方法都可以比较方便地满足需求。对于一些结构体类型数据,通常我们可以先将其序列化后再输出。 如果结构体中包含不可序列化的字段,比如 func 类型, ......
数据结构 go-spew 结构 数据 spew