Re: [go-nuts] SetMapIndex() equivalent for slice/array

2021-06-04 Thread 'Dan Kortschak' via golang-nuts
On Fri, 2021-06-04 at 20:29 -0700, Deiter wrote: > The reflect package provides the SetMapIndex method for updating > elements in a map that are represented by a reflect.Value type, but I > don’t see an equivalent for array/slice. > The sample app (link provided below) includes an example of map >

Re: [go-nuts] SetMapIndex() equivalent for slice/array

2021-06-04 Thread Howard Waterfall
I'm trying to decouple algorithm from type. if an algorithm works on a collection, it ought to work on either a map or slice. It appeared that result.Value facilitated the decoupling entirely, until I ran into the limitation with array/slice. It seems odd that I have to use the unsafe the package w

Re: [go-nuts] SetMapIndex() equivalent for slice/array

2021-06-04 Thread Kurtis Rader
More context would be useful; i.e., what are you really trying to do and why? Such information often allows people to provide better answers; including whether this is an example of the [XY Problem]( https://xyproblem.info/) or you have a misunderstanding how slices work. Given your play.golang.org

[go-nuts] SetMapIndex() equivalent for slice/array

2021-06-04 Thread Deiter
The reflect package provides the SetMapIndex method for updating elements in a map that are represented by a reflect.Value type, but I don’t see an equivalent for array/slice. The sample app (link provided below) includes an example of map that’s been made accessible through a a reflect.Valu

Re: [go-nuts] Re: Ignore /vendor by default in polyglot repository

2021-06-04 Thread Amnon
How about renaming your vendor directory to something else? On Friday, 4 June 2021 at 21:44:33 UTC+1 Brian Candler wrote: > I don't suppose you could move all the go code down a level, say into a > "go" subdirectory of the repo, including the go.mod file? > > On Friday, 4 June 2021 at 17:44:37 U

Re: [go-nuts] Re: Ignore /vendor by default in polyglot repository

2021-06-04 Thread Brian Candler
I don't suppose you could move all the go code down a level, say into a "go" subdirectory of the repo, including the go.mod file? On Friday, 4 June 2021 at 17:44:37 UTC+1 manlio@gmail.com wrote: > On Friday, June 4, 2021 at 6:24:28 PM UTC+2 Jacob Vosmaer wrote: > >> On Thu, Jun 3, 2021 at 6:

Re: [go-nuts] Computing a hash over a uintptr ?

2021-06-04 Thread Ian Lance Taylor
On Fri, Jun 4, 2021 at 10:00 AM Robert Engels wrote: > > I was thinking of using C.malloc to create off heap structures. The uintptr > to those structs should be stable and can be used as map keys or values, > right? > > Not suggesting anyone should do that - just feasibility. Yes, that works

Re: [go-nuts] Computing a hash over a uintptr ?

2021-06-04 Thread Robert Engels
I was thinking of using C.malloc to create off heap structures. The uintptr to those structs should be stable and can be used as map keys or values, right? Not suggesting anyone should do that - just feasibility. > On Jun 4, 2021, at 10:38 AM, Ian Lance Taylor wrote: > > On Fri, Jun 4, 2021

Re: [go-nuts] Re: Ignore /vendor by default in polyglot repository

2021-06-04 Thread Manlio Perillo
On Friday, June 4, 2021 at 6:24:28 PM UTC+2 Jacob Vosmaer wrote: > On Thu, Jun 3, 2021 at 6:35 PM Manlio Perillo > wrote: > > One possible solution is to have a GOENV file in the root directory of a > repository. > Thanks Manlio. Is that something that is possible now, or a feature > suggest

Re: [go-nuts] Re: Ignore /vendor by default in polyglot repository

2021-06-04 Thread 'Jacob Vosmaer' via golang-nuts
On Thu, Jun 3, 2021 at 6:35 PM Manlio Perillo wrote: > One possible solution is to have a GOENV file in the root directory of a > repository. Thanks Manlio. Is that something that is possible now, or a feature suggestion? From what I can tell it's not possible now. What is possible already, now

Re: [go-nuts] Computing a hash over a uintptr ?

2021-06-04 Thread Ian Lance Taylor
On Fri, Jun 4, 2021 at 5:23 AM Robert Engels wrote: > > I was referring to the “special cases” in this section > https://golang.org/cmd/cgo/ - wouldn’t all of these uintptr be stable? The cgo tool gets special treatment: each cgo call is permitted to pin a known number of pointers. There is som

[go-nuts] iOS NetworkExtension be killed with memory limit

2021-06-04 Thread hang zhou
Hi, I was use gomobile with go1.16.3 to build a framework for iOS NetworkExtension, but when the extension start, I found the memory it occupied is about 13M, and when we run some goroutine in go, the memory increase and do not decrease, and finally, the system kill my extension with the lmemo

Re: [go-nuts] Computing a hash over a uintptr ?

2021-06-04 Thread Jan Mercl
On Fri, Jun 4, 2021 at 3:02 PM christoph...@gmail.com wrote: > > That is true in current implementations, but Go, the language, does not > > guarantee that pointers will never move. > > That is what I thought, but it is allowed to use a pointer far map keys. And > I have seen some programs/pack

Re: [go-nuts] Computing a hash over a uintptr ?

2021-06-04 Thread 'Axel Wagner' via golang-nuts
No, because the Garbage Collector knows that they are pointers and would change the pointer in the map (and presumably its bucket) if it moved the value. It's certainly not trivial to implement, but these are problems that would have to be solved if the GC starts moving things around - because the

Re: [go-nuts] Computing a hash over a uintptr ?

2021-06-04 Thread christoph...@gmail.com
> That is true in current implementations, but Go, the language, does not guarantee that pointers will never move. That is what I thought, but it is allowed to use a pointer far map keys. And I have seen some programs/package using this feature. Apparently all these programs and packages would

Re: [go-nuts] Computing a hash over a uintptr ?

2021-06-04 Thread Robert Engels
I was referring to the “special cases” in this section https://golang.org/cmd/cgo/ - wouldn’t all of these uintptr be stable? > On Jun 4, 2021, at 12:25 AM, Ian Lance Taylor wrote: > > On Thu, Jun 3, 2021 at 9:13 PM Robert Engels wrote: >> >> Doesn’t that depend on what the uintptr refers to

Re: [go-nuts] Re: Is this a bug ?

2021-06-04 Thread Brian Candler
> var a byte = (1 << x) / 2 > var b byte = (1 << y) / 2 That one's more obvious [once the parentheses are added], and I find it helps understand the float case as well. x is a constant, so 1 << x is calculated at compile time to arbitrary precision, and then converted to a byte. That's fine.

[go-nuts] How to handle HTTPS between go reverse proxies

2021-06-04 Thread Van Fury
Hi, Am using "net/http/httputil" Reverse proxy and would to make HTTPS forwarding between the two proxy servers. Any help on how to handle HTTPS between the proxy servers instead of HTTP? Here are a sample of my code. Proxy A func main() { http.HandleFunc("/", proxyPassA) server.ListenA