在本教程中,我们将看到一个示例程序,以了解如何使用Golang和MySQL进行数据库CRUD操作。 CRUD是Create,Read,Update和Delete的首字母缩写。 CRUD操作是数据库的基本数据操作。在此示例中...
XanderCheung
8446
1
0
在本教程中,我们将看到一个示例程序,以了解如何使用Golang和MySQL进行数据库CRUD操作。 CRUD是Create,Read,Update和Delete的首字母缩写。 CRUD操作是数据库的基本数据操作。在此示例中...
XanderCheung
8446
1
0
如何自动下载所有依赖包? 大部分情况下大家下载 Go 项目都是使用go get命令,它除了会下载指定的项目代码,还会去下载这个项目所依赖的所有项目。 但是有的时候我们的项目由于...
XanderCheung
14344
0
0
这是Go应用程序项目的基本布局。它不是核心Go开发团队定义的官方标准; 然而,它是Go生态系统中一组常见的历史和新兴项目布局模式。其中一些模式比其他模式更受欢迎。它还有许...
XanderCheung
43468
0
2
Go is an absolutely incredible language to build a wide variety of different applications in. From command-line interfaces to distributed microsystems and even cloud platforms, its' simplicity and concurrency baked in makes it a powerful ch...
XanderCheung
6881
0
0
ADVANCEDWorking with Websockets and Socket.IO in Go - TutorialGo Protocol Buffer TutorialGo WebAssembly Tutorial - Building a Calculator TutorialGo Oauth2 TutorialGo Face Recognition Tutorial - Part 1Go Encryption and Decryption using AES -...
XanderCheung
8611
0
0
Note - This tutorial was written using Go version 1.9 and googollee/go-socket.ioWebsockets are something I find interesting in the sense that they provide us with an alternative option to communication between applications as opposed to t...
XanderCheung
6890
0
0
Welcome fellow coders! In this tutorial, we are going to be looking at how you can utilize the Protocol Buffers data format within your Go-based applications. We'll be covering what the data format is, and why it is an improvement over more...
XanderCheung
5910
0
0
Update - The code in this tutorial has been updated to work with the breaking changes in Go v1.12Welcome All! With Go v1.11 having just been released with an experimental port to WebAssembly included, I thought it would be awesome to see h...
XanderCheung
6437
0
0
Welcome fellow coders! In this tutorial, we are going to be taking a look at how you can implement your own OAuth2 Server and client using the go-oauth2/oauth2 package.This is without a doubt one of the most requested topics from commento...
XanderCheung
7350
0
0
The whole area of Face Recognition is something I love reading about. Implementing a facial recognition system yourself makes you sound like you are Tony Stark and you can use them for a variety of different projects such as an automatic lo...
XanderCheung
6556
0
0
ObjectivesBy the end of this tutorial, you will be able to...Encrypt text using the AES - Advanced Encryption Standard in GoWe'll then look at writing this encrypted message to a fileFinally we'll look at how we can decrypt this message usi...
XanderCheung
5879
0
0
So, I recently partook in Hacktoberfest which is an event that helps to support thousands of different Open Source projects. Usually, I tend to get caught up in other projects or can't find the time or make up a hundred other excuses for ...
XanderCheung
6342
0
0
JavaScript Frontend frameworks have undoubtedly helped to push the boundaries of what was previously possible in the context of a browser. Ever more complex applications have come out built on top of the likes of React, Angular and VueJS to...
XanderCheung
6155
0
0
Note - The full source code for this tutorial can be found here: TutorialEdge/go-jwt-tutorialJWTs, or JSON Web Tokens as they are more formally known, are a compact, URL-safe means of representing claims to be transferred between two part...
XanderCheung
7727
0
0
如查询”按照created_at升序第一个创建的User“ 正确的写法: db.Model(&models.User{}).Order("created_at ASC").Limit(1).Find(&s) sql: SELECT * FROM "users" ORDER BY created_at ASC LIMIT 1 错误写法: db.Model(&models...
XanderCheung
69221
0
0
在ruby中,我们如果想 得到某一时刻的 n 个月后,我们通常这样写: t = Time.parse("2020-03-31 12:00:00") t + 1.month # => 2020-04-30 12:00:00 +0800 # 或者 1.month.after(t) # => 2020-04-30 12:00:00 +0800 在golang ...
XanderCheung
23339
0
1
gorm 不支持自动转化成数据库精度,postgres支持.后面6位,所以如果直接使用 now.New(t).EndOfMonth() 去往数据库更新的话,就会导致被错误的前进了一秒,所以要把后面多余的精度设为0 imp...
XanderCheung
10240
0
0
给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标。你可以假设每种输入只会对应一个答案。但是,你不能重复利用...
XanderCheung
6338
0
0
golang logrus multiple output to different files import ( log "github.com/sirupsen/logrus" "os" ) func main() { if file, err := os.OpenFile("log1.log", os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0666); err == nil { log.SetOut...
XanderCheung
11305
0
0
go中将struct转成json时,time.Time 类型输出值是 "2021-04-13T20:38:51.466566+08:00" ,如下例: package main import ( "encoding/json" "os" "time" ) type MyStruct struct { ID uint `json:"id"` N...
XanderCheung
11319
0
0
f := float64(1622559008009325096) fmt.Println(f) f 值为 1622559008009325000 而不是 1622559008009325096
XanderCheung
6159
0
0
fmt.Println(time.Now().UnixNano()) nanosecond part is not filledsome results15064161549311200001506416154931136000150641615493113800015064161549311390001506416154931140000 https://github.com/golang/go/issues/22037
XanderCheung
5982
0
0
x := map[string]interface{}{"a": 1, "b": 2} b, err := json.MarshalIndent(x, "", " ") if err != nil { fmt.Println("error:", err) } fmt.Print(string(b)) 输出: { "a": 1, "b": 2 }
XanderCheung
5713
0
0
空结构体特殊性 func main() { var s struct{} fmt.Println(unsafe.Sizeof(s)) } 输出结果: 0 这是Go 编译器在内存分配时做的优化项 // base address for all 0-byte allocations var zerobase uintptr // Allocate a...
XanderCheung
5368
0
1
func main() { var a uint = 1 var b uint = 2 fmt.Println(a - b) } 最终结果不是 -1,如果系统是64位,结果是 2的64次方减1如果系统是32位,结果是 2的32次方减1
XanderCheung
4916
0
0
package main import ( "fmt" "sync" ) func printWord(word string, count int, currentChan, nextChan chan struct{}, wg *sync.WaitGroup) { var i = 0 for i < count { if _, ok := <-currentChan; ok { fmt.Print...
XanderCheung
8333
0
1
singleflight redsync kmutex 软件包singleflight提供了一个重复的函数调用抑制机制;主要作用就是将一组相同的请求合并成一个请求,实际上只会去请求一次,然后对所有的请求返回相同的...
XanderCheung
2990
0
0
github.com/gorilla/websocket 概述 Conn 类型表示一个 WebSocket 连接。服务器应用程序从 HTTP 请求处理程序调用 Upgrader.Upgrade 方法以获取 *Conn: var upgrader = websocket.Upgrader{ ReadBufferSize: 1024, ...
XanderCheung
5012
0
0
cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true} 针对不同平台编译:windows平台代码: sys_windows.go //go:build windows package util import ( "os/exec" "syscall" ) // PrepareBackgroundCommand 隐藏被执行...
XanderCheung
989
0
0