摘要: 直接上方法 cd /etc/yum.repos.d/ rm -rf docker-ce.repo 之后参照这个文档安装daocker 部署并使用Docker 阅读全文
posted @ 2021-10-14 17:15 CJ-cooper 阅读(4247) 评论(0) 推荐(1) 编辑
摘要: https://www.cnblogs.com/pxstar/p/14808244.html 阅读全文
posted @ 2021-10-12 22:17 CJ-cooper 阅读(15) 评论(0) 推荐(0) 编辑
摘要: 异步协程 package main import ( "gopkg.in/gin-gonic/gin.v1" "time" "log" ) func main(){ // only set in Production // gin.SetMode(gin.ReleaseMode) router := 阅读全文
posted @ 2021-10-11 15:41 CJ-cooper 阅读(416) 评论(0) 推荐(0) 编辑
摘要: 一般情况使用 c.ShouldBindJSON c.ShouldBind 第二次读取 request body 的数据就会出现 EOF 的错误,因为 c.Request.Body 不可以重用 gin 1.4 之后官方提供了一个 ShouldBindBodyWith 的方法,可以支持重复绑定,原理就是 阅读全文
posted @ 2021-10-06 14:55 CJ-cooper 阅读(500) 评论(0) 推荐(0) 编辑
摘要: 203.移除链表元素 力扣链接 创建一个虚拟头节点 func removeElements(head *ListNode, val int) *ListNode { p:=&ListNode{} p.Next=head q:=p for p!=nil&&p.Next!=nil{ if p.Next. 阅读全文
posted @ 2021-09-28 20:29 CJ-cooper 阅读(211) 评论(0) 推荐(0) 编辑
摘要: 704. 二分查找 力扣链接 注意边界问题 func search(nums []int, target int) int { r,l,mid:=0,len(nums)-1,(len(nums)-1)/2 for l>=r{ mid = (r+l)/2 if nums[mid]==target{ r 阅读全文
posted @ 2021-09-24 17:19 CJ-cooper 阅读(95) 评论(0) 推荐(0) 编辑
摘要: GMP Goroutine调度是一个很复杂的机制,下面尝试用简单的语言描述一下Goroutine调度机制,想要对其有更深入的了解可以去研读一下源码。 介绍 首先介绍一下GMP什么意思: G goroutine: 即Go协程,每个go关键字都会创建一个协程。 M thread内核级线程,所有的G都要放 阅读全文
posted @ 2021-09-15 01:39 CJ-cooper 阅读(5634) 评论(1) 推荐(0) 编辑
摘要: 516.最长回文子序列 题目 思路 回文子序列都是动态规划经典题目,用从Carl哥那里学来的动态规划五部曲: 确定dp数组以及下标的含义 确定递推公式 dp数组如何初始化 确定遍历顺序 列举推导dp数组 确定dp数组以及下标的含义 dp[i] [j]:字符串s在[i, j]范围内最长的回文子序列的长 阅读全文
posted @ 2021-09-14 20:27 CJ-cooper 阅读(207) 评论(0) 推荐(0) 编辑
摘要: Golang抢占式调度 在1.2版本之前,go的调度器仍然不支持抢占式调度,程序只能依靠Goroutine主动让出CPU资源才能触发调度,这会引发一些问题,比如: 某些 Goroutine 可以长时间占用线程,造成其它 Goroutine 的饥饿 垃圾回收器是需要stop the world的。如果 阅读全文
posted @ 2021-09-13 22:21 CJ-cooper 阅读(511) 评论(0) 推荐(0) 编辑
摘要: 今天刷力扣碰到要求最大公因数,总结一下。 方法 用到的方法是辗转相除法,具体思路如下: 代码实现 func gcd(a,b int)int{ if a%b==0{ return b } return gcd(b,a%b) } 或者 func gcd(a,b int)int{ for a%b!=0{ 阅读全文
posted @ 2021-09-12 21:29 CJ-cooper 阅读(229) 评论(0) 推荐(0) 编辑