Go语言中文网 为您找到相关结果 3

go study second

go 内部实现了http协议,下面一段代码简洁的实现了一个webserver, 很精彩,后续有机会深入挖掘 package main import ( "fmt" "net/http" ) type Hello struct{} func (h Hello) ServeHTTP( w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, "Hello!") } func main() { var h Hello http.ListenAndServe("localhost:4000",h) } 访问http://localhost:4000 就可以看到一个hello!的消...阅读全文

博文 2016-03-07 09:00:00 ShiningStarPxx

golang 1.9 -a bug?

现象是,golang,项目里用了sqlite,gogland里debug时极慢 另外run或debug时提示需要gcc,即使install了之后同样提示需要gcc 发现gogland debug和run不同,加了 -a参数 go build -h -a force rebuilding of packages that are already up-to-date. 给gogland提issue后得知 It's an unfortunate side effect of GO-4249 go 1.9才有这问题 暂时先改下go源码绕过一下问题,提高debug速度,等待后续go或者goland的修...阅读全文

博文 2017-08-30 16:35:09 ddatsh

LeetCode - 160. Intersection of Two Linked Lists

题链接:https://leetcode.com/problems/intersection-of-two-linked-lists/ 简单题拿golang练练手。 /** * Definition for singly-linked list. * type ListNode struct { * Val int * Next *ListNode * } */ func getIntersectionNode(headA, headB *ListNode) *ListNode { la := getLen(headA) lb := getLen(headB) if(la > lb) { headA = skipNodes(la - lb, headA) } else if (lb > la...阅读全文

博文 2020-03-08 17:32:42 码农老姜