[go-nuts] Force pointer at compile time to interface{} parameter

2018-11-19 Thread hay
Hi, I've the following example code of correct version. func SomeFunction(itemPtr interface{}) { //itemPtr must be pointer to struct and not struct. } func SomeFunctionCaller() { u := UserRecord{} SomeFunction(&u) } Above is the correct version, but some cod

[go-nuts] Re: Force pointer at compile time to interface{} parameter

2018-11-19 Thread Volker Dobler
> Is there a way to force "SomeFunction" to take pointers only at compile time? No, sorry. V. -- 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+unsub

Re: [go-nuts] Re: Force pointer at compile time to interface{} parameter

2018-11-19 Thread Robert Engels
Aren’t all interface references passed as a pointer? It is a var that contains a pointer to the struct and a concrete type of the struct? > On Nov 19, 2018, at 8:45 AM, Volker Dobler wrote: > > > Is there a way to force "SomeFunction" to take pointers only at compile > > time? > > No, sorry.

Re: [go-nuts] Force pointer at compile time to interface{} parameter

2018-11-19 Thread Chris Burkert
Hello Hay, with interface{} you explicitly allow everything. Instead you may consider to restrict the accepted input in the first place - e.g. with a non-empty interface. Chris hay schrieb am Mo. 19. Nov. 2018 um 15:37: > Hi, > > I've the following example code of correct version. > > func SomeF

Re: [go-nuts] Re: [RFC] Dynamically instrumentation Go binaries

2018-11-19 Thread Julio Guerra
On Fri, Nov 16, 2018 at 12:06 AM Damian Gryski wrote: > One approach would be to augment the compiler to instrument the binary > with the techniques outlined in: > > XRay: A Function Call Tracing System > https://ai.google/research/pubs/pub45287 > > Yes, this is very likely the best option for pe

Re: [go-nuts] [RFC] Dynamically instrumentation Go binaries

2018-11-19 Thread Julio Guerra
On Thu, Nov 15, 2018 at 7:55 PM Michael Jones wrote: > You could study Rob Pike’s coverage/profiling tool to see how he adds and > exploits basic block counting. Good work as always. > Good idea, thanks. I had a look at the implementation of it, and at the way it is integrated into the go toolc

Re: [go-nuts] [RFC] Dynamically instrumentation Go binaries

2018-11-19 Thread Julio Guerra
On Thu, Nov 15, 2018 at 9:57 PM Tristan Colgate wrote: > Maybe you mean something like support for linux uprobes? > There is some discussion here: > https://github.com/golang/go/issues/22008 > Google for "golang uprobes" picks up a couple of other links: > > http://www.brendangregg.com/blog/2017-

Re: [go-nuts] I cannot access global var from package. Any idea?

2018-11-19 Thread Juan Mamani
Thanks for comments. Good idea is to implement "package qualifier". I will try it. (Conclusion: Go's rule doesn't apply for subdirectories. If I'm wrong let me know=) Thanks again! El vie., 16 de nov. de 2018 a la(s) 10:53, Jan Mercl (0xj...@gmail.com) escribió: > > On Fri, Nov 16, 2018 at 2

[go-nuts] Determining latest released Go version

2018-11-19 Thread Janne Snabb
Dear Gophers, How to determine the latest released Go version programmatically? I am working on a system which needs to use the latest published Go version (whatever it is at the time it is run). I would rather not update it manually every time a new version comes out as this is error prone a

Re: [go-nuts] Re: Force pointer at compile time to interface{} parameter

2018-11-19 Thread Ian Denhardt
>From an implementation standpoint they are passed by reference (The representation is actually a pair (pointer to vtable, pointer to object), but from a semantic standpoint the difference still matters, because e.g. if the original value was a struct, it still can't be mutated. There are use cases

Re: [go-nuts] Re: Force pointer at compile time to interface{} parameter

2018-11-19 Thread Robert Engels
But isn’t that just for safety. Meaning the unmarshall could use it as a pointer via reflection and mutate it (but that is probably not what the caller expects in Go) ? > On Nov 19, 2018, at 2:04 PM, Ian Denhardt wrote: > > From an implementation standpoint they are passed by reference (The >

[go-nuts] improve the reflection of golang

2018-11-19 Thread iamybj via golang-nuts
I am dong a simple sql library, but i need access some unexpected members in the std lib. I find this project https://github.com/alangpierce/go-forceexport but it is out of date.\ The authors of golang are some old programmer, but programming language processing for several ten years. golang mus

[go-nuts] net/http/httputil.ReverseProxy Expect: 100-continue broken?

2018-11-19 Thread gregoryh
Hi folks! Hoping somebody can help me figure out what I'm doing wrong (or what Go's doing wrong in the small chance it's that). It _seems_ Go's reverse proxy doesn't support 100 Continue when the backend is HTTP/2 (but I'm guessing). I put up the sample at https://github.com/gholt/proxrepro --

Re: [go-nuts] Re: Force pointer at compile time to interface{} parameter

2018-11-19 Thread Ian Denhardt
Quoting Robert Engels (2018-11-19 15:13:53) > But isn’t that just for safety. Meaning the unmarshall could use it as a > pointer via reflection and mutate it (but that is probably not what the > caller expects in Go) ? No, see: https://play.golang.org/p/MyF0Dx87-1j If you pass in &foo inst

Re: [go-nuts] improve the reflection of golang

2018-11-19 Thread Ian Lance Taylor
On Mon, Nov 19, 2018 at 2:11 AM, iamybj via golang-nuts wrote: > > I am dong a simple sql library, but i need access some unexpected members in > the std lib. > I find this project https://github.com/alangpierce/go-forceexport > but it is out of date.\ > > The authors of golang are some old progra

Re: [go-nuts] Re: Force pointer at compile time to interface{} parameter

2018-11-19 Thread Robert Engels
Interesting. I guess that makes sense. But you would think that if using a reflection call should force the compiler to heap allocate , then no reason for the restriction. > On Nov 19, 2018, at 2:33 PM, Ian Denhardt wrote: > > Quoting Robert Engels (2018-11-19 15:13:53) >> But isn’t that just

Re: [go-nuts] Re: Force pointer at compile time to interface{} parameter

2018-11-19 Thread 'Axel Wagner' via golang-nuts
The restriction has nothing to do with heaps (in fact, the Go language (i.e. the spec) doesn't even have a concept of a "heap"). It's a type-safety requirement. If you pass in a value, it can't be mutated, full-stop. Reflect shouldn't allow you to bypass type-safety - only "unsafe" can do that, hen

Re: [go-nuts] Re: Force pointer at compile time to interface{} parameter

2018-11-19 Thread Robert Engels
That is not really true though, as I can declare a method that take a pointer receiver and mutate through it, but the caller can pass a struct which it thinks can not be mutated. https://play.golang.org/p/Abf4VX9kUTR Go isn’t type safe by stating that methods cannot mutate structs. Any reader o

Re: [go-nuts] Re: Force pointer at compile time to interface{} parameter

2018-11-19 Thread 'Axel Wagner' via golang-nuts
On Mon, Nov 19, 2018 at 10:37 PM Robert Engels wrote: > That is not really true though, as I can declare a method that take a pointer > receiver and mutate through it, but the caller can pass a struct which it > thinks can not be mutated. > > https://play.golang.org/p/Abf4VX9kUTR This is syntac

Re: [go-nuts] Re: Force pointer at compile time to interface{} parameter

2018-11-19 Thread Dan Kortschak
As Axel points out this is not the case. This can be demonstrated by trying to assign the struct to an interface that has the method you are wanting to call. The following would compile under the rules you're suggesting. It doesn't. https://play.golang.org/p/qRYPaDOPYsl On Mon, 2018-11-19 at 15:

Re: [go-nuts] Re: Force pointer at compile time to interface{} parameter

2018-11-19 Thread Robert Engels
I understand that. I was stating that the syntactic sugar of automatic pointer creation to call a method should be removed. Having an A become a *A in one instance but not in others just causes confusion, let alone makes things not obviously mutable, mutable, causing a developer to determine tha

Re: [go-nuts] Re: Force pointer at compile time to interface{} parameter

2018-11-19 Thread Dan Kortschak
I don't agree that it was a bad idea. It eases reading and writing in many cases. The mutability of a value is based on the method signature, which is readily available through the godoc. On Mon, 2018-11-19 at 17:57 -0600, Robert Engels wrote: > I understand that. I was stating that the syntactic

Re: [go-nuts] Re: Force pointer at compile time to interface{} parameter

2018-11-19 Thread Robert Engels
Sorry, I only brought it up because it seemed related to me, and the original question was answered as No... > On Nov 19, 2018, at 6:06 PM, Dan Kortschak > wrote: > > I don't agree that it was a bad idea. It eases reading and writing in > many cases. The mutability of a value is based on the m

[go-nuts] Re: go modules and vendor: redundant features?

2018-11-19 Thread andrewchamberss
I recall reading from Russ Cox that vendoring will be removed in the future and be replaced by explicit caching with modules. -- 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

[go-nuts] Re: compiling from within vim not working

2018-11-19 Thread Robert Solomon
I'm running gvim when I try this. I was able to symlink as an earlier poster instructed. Now I'm having a different problem. I'm getting the error that no go files are found. My code is in ~/go/src, so each file is dir/code file.go. gvim make is confused by that -- You received this me

[go-nuts] Determining latest released Go version

2018-11-19 Thread Tamás Gulácsi
See what github.com/niemeyer/godeb does. -- 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 options, visit https:/

Re: [go-nuts] [ANN] Elastic APM Go Agent

2018-11-19 Thread Andrew Wilkins
Hi folks, The Elastic APM Go agent has just released v1.0.0, and is now "generally available." Elastic APM is an open source Application Performance Monitoring solution built on top of the Elastic Stack. The Go agent now supports the OpenTracing API. All of our agents are implementing the draf

[go-nuts] Types are contract -, v2

2018-11-19 Thread Burak Serdar
Hi, A while ago I sent an email to this list proposing an alternative way to specify contracts using existing types, with a "like" keyword to represent contracts on primitives. The idea stirred up some discussion, I got some useful feedback, and eventually, it died down. The idea stuck with me tho

Re: [go-nuts] improve the reflection of golang

2018-11-19 Thread 'yinbingjun' via golang-nuts
in database/sql rows.Scan(…) can only copy values to seperate variables, the style is not comfortable ,I want use a struct as database row. I want to use unexported database/sql.convertAssign, type Test struct { Name string Age int Email

[go-nuts] 3 important things that go should do first

2018-11-19 Thread 'yinbingjun' via golang-nuts
Recently I want to build a personal website using go, and I found it is very difficult. First go should support generic types. Generic types is very useful in ORM projects. If this make complex, go can borrow idea from java: only support generic types in language grammar and compiling time, n

Re: [go-nuts] 3 important things that go should do first

2018-11-19 Thread Ian Denhardt
Quoting 'yinbingjun' via golang-nuts (2018-11-19 22:23:35) > First go should support generic types. There's ongoing discussion of this in the context of Go 2; see: https://blog.golang.org/go2draft Which also links to the full draft designs, as well as feedback pages (with *lots* of feedback)

[go-nuts] gob limitation or bug?

2018-11-19 Thread Hoping White
package main import ( "bytes" "encoding/gob" "fmt" ) var data = bytes.NewBuffer(nil) var buff = bytes.NewBuffer(nil) var encoder = gob.NewEncoder(data) var decoder = gob.NewDecoder(buff) func main() { encode() decode() decode() } func encode() { n := [][]int32{[]int32{1}, [

Re: [go-nuts] improve the reflection of golang

2018-11-19 Thread Reto Brunner
If you want to do that, there's already a package for it: https://github.com/jmoiron/sqlx ``` people := []Person{} db.Select(&people, "SELECT * FROM person ORDER BY first_name ASC") ``` -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubsc

[go-nuts] Where is the very first g/m/p?

2018-11-19 Thread Fei Ding
Hi I am trying to figure out the process of creation of the very first g(goroutine), together with the very fist m, and p. It seems that the deepest code I can find is at proc.go , and the getg() function is my dead end, which