countfloyd: a local feature server
<p><a href="https://github.com/Laughs-In-Flowers/countfloyd" rel="nofollow">https://github.com/Laughs-In-Flowers/countfloyd</a></p> <p>countfloyd is sort of an odd duck project that I've been to hell and back with, abstracted out of several projects that I won't really talk about as the...阅读全文
go学习笔记-init函数执行顺序分析
golang中有个神奇的函数init,该函数会在所有程序执行开始前被调用,每个包可以包含多个init函数,所有被编辑器识别到的init函数都会在main函数执行前被调用。通常被用来注册一个程序需要使用的依赖,如mysql注册,配置文件加载等。 在main包的使用 package main import "fmt" func main() { fmt.Println("这里是mian") } func init() { fmt.Println("这里是Init1") } func init() { fmt.Println("这里是Init2") } //输出结果 这里是Init1 这里是Init2 这里是main 一个很简单的示例,可以看到init函数是在main函数执行之前被执行的,并且一个...阅读全文
Well structured and documented small/medium projects to learn from
<p>Hi Everyone. I've been trying out Go for small projects for a month now, but when looking at my code I'm under the impression that I'm not using efficient patterns and making the most out of what Go gives (forgetting to use pointers, scarcely using anonymous functions). </p> <p>I'm looking for a...阅读全文
In Golang, is it generally preferred to write methods that return new values and then save the result, or methods that mutate receivers and arguments?
<p>I'm totally new to Go, and I was hoping someone could give me a bit of guidance as to what the best practices/patterns in it are.</p> <p>Say that I'm writing a tool that connects to public APIs over the internet, and saves response information to a local database. I make a struct, <code>apiClient</code...阅读全文
leetcode_893
Golang: 思路:把奇数位和偶数位的字符全部找出来,然后排序在组合起来,建个map看下情况即可 代码如下: func superEggDrop(K int, N int) int { if K==1{ return N } mat:=make([][]int,K+1) for k,_:=range mat{ mat[k]=make([]int,N+1) } for k,_:=range mat[1]{ mat[1][k]=k } for i:=2;i<=K;i++{ for j:=1;j<=N;j++{ low,high:=1,j for low+1
Can't seem to understand what this function is doing...
<p>This is in <code>pool.go</code>. Originally I was trying to understand how pool.get worked. It brought me down a rabbit hole and I ran into this</p> <pre><code>func indexLocal(l unsafe.Pointer, i int) *poolLocal { return &(*[1000000]poolLocal)(l)[i] } </code></pre> <p>What is it doi...阅读全文
九种排序具体实现代码
声明:本文内容纯属博主自己查找和归纳的个人所需的知识点,仅作参考,如有错误,博主强烈希望您指出。如果您是某个知识点的原创博主,如有需要,可联系本人加上链接。本文内容会根据博主所需进行更新,希望大家多多关照。 直接插入排序 void InsertSort(int r[]) { int n = sizeof(r) / sizeof(r[0]); for(int i = 1; i < n; ++i) { for(int j = i - 1; j >= 0; --j) { if(r[j+1] < r[j]) { int s = r[j+1]; r[j+1] = r[j]; r[j] = s; } } } } 折半插入排序 void BinInsertSort(int r[]) { int n = s...阅读全文
How did the dandelion, an edible and remarkably versatile plant, come to be classified as a weed?
<p>I was reading in the memoir of a Great Depression survivor that she would stop and gather dandelions while out looking for work and bring them all home for a dandelion dinner in case her mother had been unable to find anything to eat. This piqued my interest, and I did some research on the dandelion. I was shocked out how versatile this pl...阅读全文
What are multi-agents and how are they related to go-routines ?
<p>It seems the years 2000s have witnessed the rise and fall of multi-agents related software paradigms. As I was trying to understand it, I stumbled upon the following analogy: multi-agents are like cars on a city grid, all cars following the simple rule of traffic lights. Such uses cases for would be economic, structural and other kinds of ...阅读全文