Re: [go-nuts] Index operator on pointer to array or slice

2016-12-04 Thread Patrick Smith
There are cases when using a pointer to a slice is both natural and correct. For example, when using the container/heap package, I often write code similar to type Heap []Item func (h *Heap) Pop() interface{} { ... } func (h *Heap) Push(x interface{}) { ... } Here, "func (h Heap) ..." would be in

Re: [go-nuts] doc for reflect Value.Kind() seems incorrect

2016-12-04 Thread 'Axel Wagner' via golang-nuts
You need to distinguish between "the zero value of it's type" and "the zero (reflect.)Value". The docs here mean the latter, not the former. What is happening is, that in case of a nil-interface (w and in), the interface gets passed "as is" into reflect.ValueOf, which takes an interface{}. That is,

[go-nuts] latest gomobile arm64-only?

2016-12-04 Thread andrey mirtchovski
I'm having issues with the latest gomobile + reverse java bindings. I have a piece of code that linked with a C library via CGO. Previously (around 6 months ago) everything appeared file: cross compile library with NDK toolchain (gcc), link against go code with cgo, run "gomobile bind -target=andro

Re: [go-nuts] doc for reflect Value.Kind() seems incorrect

2016-12-04 Thread Jan Mercl
On Mon, Dec 5, 2016 at 6:55 AM Kaviraj Kanagaraj wrote: > But still docs seems to be misleading. It says "If v is the zero Value (IsValid returns false), Kind returns Invalid." The docs are correct: https://play.golang.org/p/Wo0mryLeZ5 -- -j -- You received this message because you are subs

Re: [go-nuts] doc for reflect Value.Kind() seems incorrect

2016-12-04 Thread Kaviraj Kanagaraj
Sry for the typo. Its true that Kind() returns "Invalid" if IsValid returns False. But still docs seems to be misleading. It says "If v is the zero Value (IsValid returns false), Kind returns Invalid." according to doc, all the variables in the code supposed to have a kind of "Invalid" (since a

[go-nuts] Anatomy of a go web application

2016-12-04 Thread DrGo
Thanks Tim, Very nice overview of the mechanics of a web app. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more o

[go-nuts] Re: Anatomy of a go web application

2016-12-04 Thread Egon
On Sunday, 4 December 2016 19:42:59 UTC+2, Tim Shannon wrote: > > I just finished writing a blog post to give an overview of building a web > application in go. > > http://tech.townsourced.com/post/anatomy-of-a-go-web-app/ > > It was kind of an excuse to play with hugo , but >

Re: [go-nuts] doc for reflect Value.Kind() seems incorrect

2016-12-04 Thread Jan Mercl
On Sun, Dec 4, 2016 at 9:01 PM Kaviraj Kanagaraj wrote: > https://play.golang.org/p/wrVwCedf65 See https://play.golang.org/p/RoIAXsxhIF -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving

[go-nuts] doc for reflect Value.Kind() seems incorrect

2016-12-04 Thread Kaviraj Kanagaraj
doc for Value.Kind() says, "If v is the zero Value (IsValid returns false), Kind returns Invalid." but thats not true. I does return "Invalid" in case of interfaces. but not for every type. It doesn't return "invalid" even if IsValid return false. https://play.golang.org/p/wrVwCedf65 -- You

[go-nuts] Anatomy of a go web application

2016-12-04 Thread Tim Shannon
I just finished writing a blog post to give an overview of building a web application in go. http://tech.townsourced.com/post/anatomy-of-a-go-web-app/ It was kind of an excuse to play with hugo , but hopefully there's some good information in there as well. Any corrections,

Re: [go-nuts] I see golang net/http code, i imitate it, but i can't.

2016-12-04 Thread Howl
HandlerFunc is not a struct. You probably wanted to do this (line 17): demo := HandlerFunc(Add) On 04/12/16 15:02, Neng Kong wrote: > i see this: > | > |type HandlerFuncfunc(ResponseWriter,*Request)// ServeHTTP calls f(w, > r).func (f HandlerFunc)ServeHTTP(w ResponseWriter,r *Request){f(w,r)

Re: [go-nuts] Re: database/sql and custom column types

2016-12-04 Thread Peter Nguyen
Thanks for the explanation! Den söndag 4 december 2016 kl. 01:26:10 UTC+1 skrev Nigel Tao: > > On Sat, Dec 3, 2016 at 4:26 AM, > wrote: > > A quick aside regarding the code that you posted. Postgres (bizarrely, > IMHO) > > stores longitude first, then latitude, so: > > Well, the usual order i

Re: [go-nuts] About golang net/http code trick, i want to imitate code trick but i can not.

2016-12-04 Thread Tamás Gulácsi
2016. december 4., vasárnap 15:14:44 UTC+1 időpontban Neng Kong a következőt írta: > > I replace > demo := HandlerFunc{} > to > var demo HandlerFunc > > also can not > [john@localhost gweb]$ go run inspiration_by_golang_http.go > panic: runtime error: invalid memory address or nil pointer derefe

Re: [go-nuts] About golang net/http code trick, i want to imitate code trick but i can not.

2016-12-04 Thread Neng Kong
I replace demo := HandlerFunc{} to var demo HandlerFunc also can not [john@localhost gweb]$ go run inspiration_by_golang_http.go panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x401035] goroutine 1 [running]:

[go-nuts] I see golang net/http code, i imitate it, but i can't.

2016-12-04 Thread Neng Kong
i see this: type HandlerFunc func(ResponseWriter, *Request) // ServeHTTP calls f(w, r). func (f HandlerFunc) ServeHTTP(w ResponseWriter, r *Request) { f(w, r) } and i imitate it, but can't compile: package main import "fmt" type Handler interface { Call(x, y int) } func Add(x, y int)

Re: [go-nuts] Are short variable declarations necessary?

2016-12-04 Thread T L
On Wednesday, November 9, 2016 at 6:29:13 PM UTC+8, Dave Cheney wrote: > > There are already too many ways to declare and or assign a variable in Go. > Adding more is not a solution. how about to prefix a ~ before identifiers to avoid shadowing: func f() { a, err := 1, error.New("an erro