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

2021-06-06 Thread lewgun
mabye @bradfitz can give you some advise On Friday, 4 June 2021 at 23:09:08 UTC+8 hang zhou wrote: > 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

Re: [go-nuts] Knowing from documentation whether an interface is holding a pointer or a struct?

2021-06-06 Thread ben...@gmail.com
> I recently translated a substantial C library into Go, and watching all > the pointers disappear, at least syntactically (there were still slices), > was marvelous. > Side point: Rob, is this open source? If so, I'd be interested to see the side-by-side comparison of the C vs Go code

Re: [go-nuts] Re: Knowing from documentation whether an interface is holding a pointer or a struct?

2021-06-06 Thread Marvin Renich
* Joshua [210606 16:52]: > > In most cases (or most cases in actual practice?) an interface can be > > thought of as a pointer, > > This is however, an implementation detail specific to the compiler you use > though, correct? Well, sort of, but really no. Whether the compiler wastefully

Re: [go-nuts] Knowing from documentation whether an interface is holding a pointer or a struct?

2021-06-06 Thread Marvin Renich
* 'Dan Kortschak' via golang-nuts [210606 06:43]: > On Sun, 2021-06-06 at 03:17 -0700, Brian Candler wrote: > > When you assign a regular (non-pointer) value to an interface > > variable, it does take a copy of that value: > > https://play.golang.org/p/XyBREDL4BGw > > It depends on whether it's

[go-nuts] Re: Knowing from documentation whether an interface is holding a pointer or a struct?

2021-06-06 Thread Joshua
> In most cases (or most cases in actual practice?) an interface can be thought of as a pointer, This is however, an implementation detail specific to the compiler you use though, correct? And similarly, the wording of the FAQ is "fine", given that it's talking about the behaviour as the

[go-nuts] Re: Query on using Closures

2021-06-06 Thread Scott Pakin
Just a guess: You may need to make a local copy of index inside your loop because index gets overwritten each iteration. On Sunday, June 6, 2021 at 12:45:01 PM UTC-6 Suveetha Kamatchi wrote: > Hi team > I am a newbie to golang. > I am writing a code that does transactions in postgres. > The

Re: [go-nuts] Operator precedence

2021-06-06 Thread Scott Pakin
Axel and Keith: Thanks for responding. I'm glad it sounds like I'm reading the spec correctly—and that Go shouldn't do anything sneaky with evaluation order. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and

Re: [go-nuts] Operator precedence

2021-06-06 Thread Scott Pakin
Alex and Keith: Thanks for responding. I'm glad it sounds like I'm reading the spec correctly—and that Go shouldn't do anything sneaky with evaluation order. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and

Re: [go-nuts] Query on using Closures

2021-06-06 Thread Jan Mercl
On Sun, Jun 6, 2021 at 8:44 PM 'Suveetha Kamatchi' via golang-nuts wrote: Please post code as plain text, no colors, no inverted schema in particular. Or share code via a link at play.golang.org, thank you. -- You received this message because you are subscribed to the Google Groups

[go-nuts] Query on using Closures

2021-06-06 Thread 'Suveetha Kamatchi' via golang-nuts
Hi team I am a newbie to golang. I am writing a code that does transactions in postgres. The list of queries to be executed under one transaction is gathered across multiple handler code. The way I am maintaining the query structure is as follows type TxQuery struct { function TxFunc data

[go-nuts] Re: packages for a self-hosted http(s) (reverse?) multi-proxy

2021-06-06 Thread Sean Liao
net/http/httputil.ReverseProxy should do it https://pkg.go.dev/net/http/httputil#ReverseProxy I think it's easier if you set it up as a standard server and configure a SingleHostReverseProxy as a handler for each of the upstreams On Sunday, June 6, 2021 at 10:28:15 AM UTC+2 Sebastien Binet

[go-nuts] Re: Knowing from documentation whether an interface is holding a pointer or a struct?

2021-06-06 Thread Gregg Townsend
On Saturday, June 5, 2021 at 2:15:27 PM UTC-7 Joshua wrote: > However, I see lots of calls of "If you're using pointers to interfaces a > lot, you probably don't understand them". > > Well, what am I not understanding? > To answer this particular point: In most cases (or most cases in actual

Re: [go-nuts] Knowing from documentation whether an interface is holding a pointer or a struct?

2021-06-06 Thread jake...@gmail.com
On Sunday, June 6, 2021 at 9:33:31 AM UTC-4 ren...@ix.netcom.com wrote: > For example, the fact that this code is broken is not intuitively obvious > for any reader. It requires way too much scrutiny IMO. > > https://play.golang.org/p/-f73t_Pm7ur > I would like to note that your example goes

Re: [go-nuts] Knowing from documentation whether an interface is holding a pointer or a struct?

2021-06-06 Thread robert engels
For example, the fact that this code is broken is not intuitively obvious for any reader. It requires way too much scrutiny IMO. https://play.golang.org/p/-f73t_Pm7ur > On Jun 6, 2021, at 6:37 AM, Robert Engels wrote: > > For me this is the most inconsistent and obtuse aspect of the Go

[go-nuts] Re: Table-driven benchmarks defeat inlining

2021-06-06 Thread Paul S. R. Chisholm
Thanks! I'd seen the "dead code elimination" comment somewhere and questioned it, but not enough. If I worry about what some future Go compiler might optimize, I end up worrying quite a lot! For example, could this code: func BenchmarkPopCountAlive(b *testing.B) { sum = 0 for i := 0; i <

Re: [go-nuts] Knowing from documentation whether an interface is holding a pointer or a struct?

2021-06-06 Thread Robert Engels
For me this is the most inconsistent and obtuse aspect of the Go language. It seems it would always be saner to treat interfaces as pointers. Which would mean if they had non pointer receiver methods might force more objects to be allocated on the heap - but it would prevent a lot of

[go-nuts] times of stw in one gc cycle?

2021-06-06 Thread xie cui
https://github.com/golang/go/blob/master/src/runtime/mgc.go#L858-L876 due to these code lines, stw in one gc cycle may happen more than 2 times. so stw times in one gc cycle could be 2(general), 3, 4, and even for ever? -- You received this message because you are subscribed to the

Re: [go-nuts] Knowing from documentation whether an interface is holding a pointer or a struct?

2021-06-06 Thread 'Dan Kortschak' via golang-nuts
On Sun, 2021-06-06 at 03:17 -0700, Brian Candler wrote: > When you assign a regular (non-pointer) value to an interface > variable, it does take a copy of that value: > https://play.golang.org/p/XyBREDL4BGw It depends on whether it's safe to leave uncopied or not. You can see this here

Re: [go-nuts] Knowing from documentation whether an interface is holding a pointer or a struct?

2021-06-06 Thread 'Axel Wagner' via golang-nuts
On Sun, Jun 6, 2021 at 12:17 PM Brian Candler wrote: > When you assign a regular (non-pointer) value to an interface variable, it > does take a copy of that value: > https://play.golang.org/p/XyBREDL4BGw > Yupp, as I said :) > As to whether the value is copied when you copy a non-pointer

Re: [go-nuts] Knowing from documentation whether an interface is holding a pointer or a struct?

2021-06-06 Thread Joshua
I can only give the opinion of someone who's new to the language, but maybe that is helpful for me to describe the learning journey a bit. I'd seen references (hehe) to maps and slices "acting like pointers" and thus weren't costly to be passing around directly into functions, and so I went to

Re: [go-nuts] Knowing from documentation whether an interface is holding a pointer or a struct?

2021-06-06 Thread Brian Candler
When you assign a regular (non-pointer) value to an interface variable, it does take a copy of that value: https://play.golang.org/p/XyBREDL4BGw Compare with what happens when the interface contains a pointer: https://play.golang.org/p/UpZnHS0xDU1 As to whether the value is copied when you copy

Re: [go-nuts] Knowing from documentation whether an interface is holding a pointer or a struct?

2021-06-06 Thread 'Axel Wagner' via golang-nuts
TBH from that FAQ answer I would have come to the same conclusion as OP. It literally says "Copying an interface value makes a copy of the thing stored in the interface value". But it doesn't. Assigning to an interface variable makes a copy of the value. Calling one of the methods on the

Re: [go-nuts] Why the limit on regex repeat is 1000?

2021-06-06 Thread 'Dan Kortschak' via golang-nuts
On Sun, 2021-06-06 at 18:14 +1000, Rob Pike wrote: > You are using a steamroller to press a shirt. Tomi Ungerer has already published this approach. https://kotonoha-books.ocnk.net/data/kotonoha-books/product/20160619_70ddf5.JPG -- You received this message because you are subscribed to the

[go-nuts] packages for a self-hosted http(s) (reverse?) multi-proxy

2021-06-06 Thread 'Sebastien Binet' via golang-nuts
hi, I am trying to setup a little self-hosted http(s) server at home. it should be able to serve the following: - https://example.com/x/pkg1 [a 'go-get'-able Go pkg] - https://example.com/x/pkg2 [ditto] - https://example.com/mumble [a mumble server for family and friends] -

Re: [go-nuts] Knowing from documentation whether an interface is holding a pointer or a struct?

2021-06-06 Thread Rob Pike
Can you explain the trap? I don't pick up that vibe, but I may be the author of that paragraph. Plus there is no such thing as a big interface. In the current implementation, all interfaces are the same size - a pair of words. You may still have a misapprehension. Try the first half of this

Re: [go-nuts] Re: Why the limit on regex repeat is 1000?

2021-06-06 Thread Rob Pike
The reason is that the only way to implement repetition in an NFA or DFA is literally to repeat the expression, so asking for `a{6}` means to generate the machine for `aa`. It is a notational convenience only, a macro mechanism if you will. Other "regexp" packages, which do not adhere to the

Re: [go-nuts] Knowing from documentation whether an interface is holding a pointer or a struct?

2021-06-06 Thread Joshua
Thanks all for the insights, I think a key takeaway for me is "Don't worry about it unless it's a problem", but it's also good to know that it (probably) isn't a problem! I'm glad at least the semantics are the same, and I guess I'll cross the performance bridge if I ever come to it and

[go-nuts] Re: Why the limit on regex repeat is 1000?

2021-06-06 Thread Alberto Donizetti
Probably not a bug, since it's documented: https://golang.org/pkg/regexp/syntax/ > Implementation restriction: The counting forms x{n,m}, x{n,}, and x{n} reject forms that create a minimum > or maximum repetition count above 1000. Unlimited repetitions are not subject to this restriction. I

Re: [go-nuts] Why the limit on regex repeat is 1000?

2021-06-06 Thread Rob Pike
It is to protect the regexp engine from overly expensive computations, as the repetition can introduce quadratic behavior in the compiler. The Go engine is concerned about pathological execution - not all engines have this property (see https://swtch.com/~rsc/regexp/regexp1.html) - and is being

[go-nuts] Why the limit on regex repeat is 1000?

2021-06-06 Thread M Hasbini
Playground: https://play.golang.org/p/opVpDD5Ts8S Here's an example regex that fails to compile: `[a-zA-Z0-9]{1001,}` Here's where the 1000 is specified: https://github.com/golang/go/blob/4d9ecde/src/regexp/syntax/parse.go#L250 Other languages regex engine behavior: The regex is valid on all