[go-nuts] A naive question, why not move the len and cap fields of string and slice types into the underlying types?

2017-03-02 Thread T L
After all, the len and cap fields of any value of string and slice values are immutable. -- 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...@

Re: [go-nuts] Re: Understanding garbage collection in Go with infinite lists

2017-03-02 Thread Yota Toyama
Nathan, As I posted above right after you posted, you are right. "Memory leak" was gone when I inserted sleep at the loop end. Thank you for your advice! Yota On Friday, March 3, 2017 at 10:39:02 AM UTC+9, Nathan Fisher wrote: > > Hi Yota, > > I don't disagree there's value in understanding how

[go-nuts] What is the implementation process of the program? thanks!!!

2017-03-02 Thread wk988g
//test/chan/goroutines.go package main import ( "os" "strconv" ) func f(left, right chan int) { left <- <-right } func main() { var n = 1 if len(os.Args) > 1 { var err error n, err = strconv.Atoi(os.Args[1])

Re: [go-nuts] How to prevent net/http from canonicalizing request paths?

2017-03-02 Thread Matt Harden
You could wrap ServeMux with one that escapes // to /%2f (or use your own escaping mechanism) and then passes the request on to ServeMux. You would have to unescape the path in the handler or use a wrapper for that also. On Tue, Feb 28, 2017 at 12:16 AM tsuna wrote: > Hi there, > the code in > h

[go-nuts] Re: the case for returning interface vs struct

2017-03-02 Thread Henry
Hi, Copying struct directly has its problems. As mentioned before, when your struct contains mutexes, maps, arrays, or pointers, you may not want your struct to be shallow-copied. You may initially have a simple struct that can be shallow-copied and it has then been used all over the place. Ho

[go-nuts] [ANN] chasquid: An SMTP (email) server written in Go

2017-03-02 Thread Alberto Bertogli
Hi! chasquid is an SMTP (email) server. It aims to be easy to configure and maintain for a small mail server, at the expense of flexibility and functionality. It's written in Go, and is open source under the Apache license 2.0. https://blitiri.com.ar/p/chasquid/ has more details (list of featur

[go-nuts] Re: Understanding garbage collection in Go with infinite lists

2017-03-02 Thread Yota Toyama
Volker, Sorry for double posts. Following your idea, I could fix my code of the 2nd version. When I insert time.Sleep(SomeTime) at for loop end, everything seems to be fine. The threshold of SomeTime is between 100 and 1000. When it is set to 100, the memory usage grows over time but, when 1000,

Re: [go-nuts] Re: Understanding garbage collection in Go with infinite lists

2017-03-02 Thread Nathan Fisher
Hi Yota, I don't disagree there's value in understanding how Go handles the scenario. What I'm not certain of is the potential tradeoffs when optimising for an uncommon edge case. The loop you've created is very tight and would be unusual to find in a typical application. The allocator is moving

[go-nuts] Re: Understanding garbage collection in Go with infinite lists

2017-03-02 Thread Yota Toyama
Volker, I don't know if the term "memory leak" is misuse. But, the 1st version's memory usage is constant but the 2nd version's one grows over time as if nothing is garbage-collected. Yota On Friday, March 3, 2017 at 2:38:08 AM UTC+9, Volker Dobler wrote: > > Am Donnerstag, 2. März 2017 17:15:0

Re: [go-nuts] Bots on the mailing list

2017-03-02 Thread Michael Jones
I get them too. Cruelly, I just presumed that Yahoo! was broken in some as yet undiagnosed way. On Thu, Mar 2, 2017 at 11:56 PM, Ian Lance Taylor wrote: > On Thu, Mar 2, 2017 at 12:32 PM, Nyah Check wrote: > > > > Has anyone noticed there might be some bots subscribed to this mailing > list > >

[go-nuts] Re: File path extractor Regexp

2017-03-02 Thread Scott Pakin
On Thursday, March 2, 2017 at 6:50:16 AM UTC-7, Nyah Check wrote: > > I am currently developing an application that identifies strings looking > like a file path and collects them and returns the array of strings. Over > the past week, I developed a regex to identify file paths to this: > "(?:/

[go-nuts] Re: the case for returning interface vs struct

2017-03-02 Thread 'Eric Johnson' via golang-nuts
Structs give the caller so many immediate benefits: - If there's internal state that clients shouldn't muck around with, then (a) keep a field private, or (b) keep a field private and make it a pointer to state (such as mutexes). - Structs can be copied directly. - Set and get don

[go-nuts] reading/writing after http.Handler returns

2017-03-02 Thread jonathan . gaillard
A few weeks ago we implemented a context that given some readClosers and writeClosers would track if any were idle and eventually cancel the context. We use this for handlers in our server. We seem to be having a crash though where we are effectively returning from a handler, and yet a read/writ

[go-nuts] Cancelling blocked Read()s and Write()s on net.Conn using a Context?

2017-03-02 Thread MartinG
Hi, I began to find it strange that most potentially blocking operations across the network for Dial, various http, sql and other things support context.Context, but basic Read() and Write on net.Conn do not. Instead they support a trick of setting the read or write deadlines to the past once

[go-nuts] Re: File organization in a github-ed Go project

2017-03-02 Thread ojucie
That is by design. All import paths should be complete, absolute paths, and that is enforced as much as possible. When somebody moves or copy a file to another directory structure, the program behaviour is preserved, even if by chance there is a similarly named package nearby. If "../serial" w

Re: [go-nuts] encoding an integral float like 1.0 as "1.0" in JSON (not "1"), and other JSON questions

2017-03-02 Thread 'Thomas Bushnell, BSG' via golang-nuts
There is no such distinction in json as a float vs. an int; they are just numbers. This is essentially a consequence of the javascript underpinnings of json. Thomas On Thu, Mar 2, 2017 at 2:29 AM Basile Starynkevitch < bas...@starynkevitch.net> wrote: > Hello All, > > This could be related to is

Re: [go-nuts] Bots on the mailing list

2017-03-02 Thread Ian Lance Taylor
On Thu, Mar 2, 2017 at 12:32 PM, Nyah Check wrote: > > Has anyone noticed there might be some bots subscribed to this mailing list > that constantly forward discussions to our emails? I've noticed this about 3 > times already. I don't know if there's something the Group admins can do > something a

[go-nuts] Re: encoding an integral float like 1.0 as "1.0" in JSON (not "1"), and other JSON questions

2017-03-02 Thread Basile Starynkevitch
Thanks for all for the help. I managed to commit 4da8b9c7a7d7822ca1e45ce660 -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group a

[go-nuts] Bots on the mailing list

2017-03-02 Thread Nyah Check
Hi Gophers, Has anyone noticed there might be some bots subscribed to this mailing list that constantly forward discussions to our emails? I've noticed this about 3 times already. I don't know if there's something the Group admins can do something about. Here are some of the emails I've found. 1.

[go-nuts] Re: Go 1.8 compiler SEGV - issue #19323

2017-03-02 Thread Basile Starynkevitch
On Tuesday, February 28, 2017 at 8:46:47 PM UTC+1, Basile Starynkevitch wrote: > > Hello All, > > I'm still a newbie, and I managed to crash the Go 1.8 compiler > (Linux/amd64/Debian/Sid). Probably I have some mistake in my own code (but > I am not expecting it to SEGV the compiler) > > I've w

[go-nuts] decoding various JSON in specific way (according to first JSON name)

2017-03-02 Thread Basile Starynkevitch
Hello all, This question is related to that one (which gives more detailed motivation). Assume I have some public type Person = struct { PersName: string `json:"name"` PersPhone: int `json:"phone"` } I want to unm

Re: [go-nuts] Re: Debugging in Go 1.8

2017-03-02 Thread Nyah Check
> When Delve compiles your program for you it passes `-gcflags="-N -l"`, > which will produce a binary that's more suited for debugging. If you need > to use `dlv exec` over `dlv debug`, you can build your binary using that > flag and you should have a better experience. > Thanks for the tip :-)

Re: [go-nuts] Re: Debugging in Go 1.8

2017-03-02 Thread Derek Parker
> > But I found it hard to debug a Go program not started by delve itself. > When Delve compiles your program for you it passes `-gcflags="-N -l"`, which will produce a binary that's more suited for debugging. If you need to use `dlv exec` over `dlv debug`, you can build your binary using that

[go-nuts] Re: Understanding garbage collection in Go with infinite lists

2017-03-02 Thread Volker Dobler
Am Donnerstag, 2. März 2017 17:15:05 UTC+1 schrieb Yota Toyama: > > Hi, all. > > I'm trying to understand argument liveness in Go 1.8. > As preparation for it, I wrote 2 programs which iterate over infinite > lists. > At first, I thought both can be run forever without any memory leak. > However,

Re: [go-nuts] Understanding garbage collection in Go with infinite lists

2017-03-02 Thread Ian Lance Taylor
On Thu, Mar 2, 2017 at 1:01 AM, Yota Toyama wrote: > > I'm trying to understand argument liveness in Go 1.8. > As preparation for it, I wrote 2 programs which iterate over infinite lists. > At first, I thought both can be run forever without any memory leak. > However, the result was that one coul

[go-nuts] Re: HTTP/2 Server Push - what is happening during 'Reading Push' ?

2017-03-02 Thread Oskar
+1 on this! Let me know if you have figured it out Steve. I have also long time spent on "Reading Push" while investigating different server push scenarios. And in fact it seems like the resource is still on the server while "Reading Push". I've implemented server push with node-spdy and in my

[go-nuts] Re: Can ServerMux serve two different handler functions on / and a path beyond / ?

2017-03-02 Thread Chris Coleman
On Tuesday, 28 February 2017 17:43:19 UTC, Howard Guo wrote: > > As it is currently implemented, if http.ServerMux serves a FileServer on a > path beyond "/", for example "/mydir", and then serves a very different > document on "/", the FileServer handler will not be triggered at all and > the "

[go-nuts] Understanding garbage collection in Go with infinite lists

2017-03-02 Thread Yota Toyama
Hi, all. I'm trying to understand argument liveness in Go 1.8. As preparation for it, I wrote 2 programs which iterate over infinite lists. At first, I thought both can be run forever without any memory leak. However, the result was that one could and the other couldn't. Their main difference is

Re: [go-nuts] Re: Debugging in Go 1.8

2017-03-02 Thread ojucie
I use vi and command line a lot as well, but for some tasks like debugging, a good IDE is of great help. All you have to do is to click at the left margin of your source code to create a breakpoint and press F5 to reach there. It is almost too easy. As far as I know, VSCode is not able to use d

Re: [go-nuts] Re: Debugging in Go 1.8

2017-03-02 Thread ojucie
After I installed 1.8 I deleted my GOPATH environment variable, but VSCode didn't like that, so I created GOPATH variable again, this time pointing to %USERPROFILE%\go While I were at it, I extended my PATH variable to include the bin from GOPATH %USERPROFILE%\go\bin Don't forget to drop dlv.

Re: [go-nuts] Slice from interface doesn't work as expected

2017-03-02 Thread James Bardin
All assignments are a copy, so there's no way to modify a slice value that is in an interface{} Just like if this were a function argument, you will need a pointer in order to modify the value. https://play.golang.org/p/kOdXUCiT_F On Thursday, March 2, 2017 at 9:01:48 AM UTC-5, Cornel Damian

Re: [go-nuts] Slice from interface doesn't work as expected

2017-03-02 Thread bart2yk
If you look where the slice is printed you will see that the data is missing. In the working example from me the data is there. And even so, your example doesn't help me, what i've set there is just for example, i my code each time i add data to the slice i must first cast it. On Thursday, March

Re: [go-nuts] Slice from interface doesn't work as expected

2017-03-02 Thread Jan Mercl
On Thu, Mar 2, 2017 at 2:46 PM wrote: > Can somebody explain me why? Did you mean https://play.golang.org/p/GUVZBUQlEj ? -- -j -- 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,

[go-nuts] Re: Can I edit/add struct tag at runtime?

2017-03-02 Thread martseniuk
https://play.golang.org/p/QNArOeqy94 On Tuesday, October 16, 2012 at 7:38:57 PM UTC+3, nvcnvn wrote: > > Can I edit/add struct tag at runtime? > I'm writting a simple wrap-pkg for appengine/datastore and > labix.org/v2/mgo. mgo support for dropping index by a method, since > datastore use struc

[go-nuts] File path extractor Regexp

2017-03-02 Thread Nyah Check
Hi, I am currently developing an application that identifies strings looking like a file path and collects them and returns the array of strings. Over the past week, I developed a regex to identify file paths to this: "(?:/[A-Z\\d.][A-Z\\d\\-.]{0,61})+". That does not seem to work. Can anyone giv

[go-nuts] Slice from interface doesn't work as expected

2017-03-02 Thread bart2yk
Hi I have a slice that is casted from an interface and even if the capacity of the slice is not exceeded the len and the data isn't keep. Can somebody explain me why? The pointer of the interface and the casted slice is the same and isn't changing. To make this scenario work i had to use poi

Re: [go-nuts] Re: Can I edit/add struct tag at runtime?

2017-03-02 Thread Konstantin Khomoutov
> > Hi, someone has the solution? > [...] Note that since 1.8 Go ignores tags on type conversions [1] so if you're actually dealing with an "XY problem" [2] -- trying to monkey-patch a struct type's tags at runtime to make it behave differently under different circumstances when (un)marshaling va

Re: [go-nuts] encoding an integral float like 1.0 as "1.0" in JSON (not "1"), and other JSON questions

2017-03-02 Thread Konstantin Khomoutov
On Thu, 2 Mar 2017 03:35:39 -0800 (PST) Basile Starynkevitch wrote: [...] > > JSON itself doesn't distinguish between integers and floats so it > > could be a bad fit for your use case. [...] > In theory you are right, json.org don't make the difference. In > practice, a lot of JSON libraries (e

[go-nuts] Re: Error type casting is something strange.

2017-03-02 Thread 장재휴
Thank you for your explain. I read the section in the FAQ. 2017년 2월 27일 월요일 오전 2시 20분 44초 UTC+8, Andrei Tudor Călin 님의 말: > > Hello. > > If any concrete value has been stored in an interface value - including a > nil pointer of some type - the interface will not be nil. > > See this section in

Re: [go-nuts] encoding an integral float like 1.0 as "1.0" in JSON (not "1"), and other JSON questions

2017-03-02 Thread Basile Starynkevitch
On Thursday, March 2, 2017 at 12:01:49 PM UTC+1, Jakob Borg wrote: > > > On 2 Mar 2017, at 18:29, Basile Starynkevitch > wrote: > > I would like that second line to be at least json_emit buf: -1.0 because > I need to separate objvalmo.FloatV from objvalmo.IntV types > > > JSON itself doesn't di

Re: [go-nuts] encoding an integral float like 1.0 as "1.0" in JSON (not "1"), and other JSON questions

2017-03-02 Thread Konstantin Khomoutov
On Thu, 2 Mar 2017 02:29:22 -0800 (PST) Basile Starynkevitch wrote: > I want to JSON encode a float64 point number always as a JSON float, > so 1.0 should be encoded as 1.0 not as 1 because at decoding time I > want to distinguish them. [...] Use custom type with a custom marshaler [1]: ---

Re: [go-nuts] encoding an integral float like 1.0 as "1.0" in JSON (not "1"), and other JSON questions

2017-03-02 Thread Jakob Borg
> On 2 Mar 2017, at 18:29, Basile Starynkevitch > wrote: > > I would like that second line to be at least json_emit buf: -1.0 because I > need to separate objvalmo.FloatV from objvalmo.IntV types JSON itself doesn't distinguish between integers and floats so it could be a bad fit for your us

[go-nuts] encoding an integral float like 1.0 as "1.0" in JSON (not "1"), and other JSON questions

2017-03-02 Thread Basile Starynkevitch
Hello All, This could be related to issue #6384 I want to JSON encode a float64 point number always as a JSON float, so 1.0 should be encoded as 1.0 not as 1 because at decoding time I want to distinguish them. Conceptually, I am persisting in JSON fo

Re: [go-nuts] Re: why the second memory allocation is blocked?

2017-03-02 Thread Dave Cheney
The oscar for worst autocorrect in a technical debate goes too ... On Thursday, 2 March 2017 21:04:16 UTC+11, Michael Jones wrote: > > Go deserves a keyword to "make love objects." > > On Thu, Mar 2, 2017 at 9:47 AM Dave Cheney > > wrote: > >> Your spinning goroutine is block the garbage collect

Re: [go-nuts] Re: why the second memory allocation is blocked?

2017-03-02 Thread Michael Jones
Go deserves a keyword to "make love objects." On Thu, Mar 2, 2017 at 9:47 AM Dave Cheney wrote: > Your spinning goroutine is block the garbage collector which needs to > stop, temporarily, all the running goroutines to make love objects. > > -- > You received this message because you are subscri

[go-nuts] Re: Can I edit/add struct tag at runtime?

2017-03-02 Thread martseniuk
https://play.golang.org/p/1lgcfs_wis On Tuesday, October 16, 2012 at 7:38:57 PM UTC+3, nvcnvn wrote: > > Can I edit/add struct tag at runtime? > I'm writting a simple wrap-pkg for appengine/datastore and > labix.org/v2/mgo. mgo support for dropping index by a method, since > datastore use struct

[go-nuts] Re: Can I edit/add struct tag at runtime?

2017-03-02 Thread sergey . yarmonov
Yes, you can. You can use this library: github.com/sevlyar/retag . вторник, 16 октября 2012 г., 23:38:57 UTC+7 пользователь nvcnvn написал: > > Can I edit/add struct tag at runtime? > I'm writting a simple wrap-pkg for appengine/datastore and > labix.org/v2/mgo. mgo support for dropping index by

[go-nuts] Re: nosplit stack overflow while installing

2017-03-02 Thread Dave Cheney
Can you please include _all_ the output, I suspect that your Go installation is broken somehow and the standard lib packages are being rebuilt On Thursday, 2 March 2017 19:25:44 UTC+11, Karan Chaudhary wrote: > > Hi, > > I'm getting this error when install the project: > > runtime.cgocall: nospl

[go-nuts] nosplit stack overflow while installing

2017-03-02 Thread Karan Chaudhary
Hi, I'm getting this error when install the project: runtime.cgocall: nosplit stack overflow 584 assumed on entry to runtime.cgocall (nosplit) 528 after runtime.cgocall (nosplit) uses 56 520 on entry to runtime.entersyscall (nosplit) 480 after runti