[go-nuts] Re: A modest format suggestion

2020-04-27 Thread Warren Stephens
Or really "Go for it" and suggestion a language syntax enhancement! // Great is a really great function. func Great( anArg int,/// This explains anArg anotherArg string, /// This explains anotherArg ) (err error) { ... Where 3 slashes `///` indicates that t

[go-nuts] Re: A modest format suggestion

2020-04-27 Thread Leszek Kubik
It wasn't mentioned here but I really like how C# IDE helps understanding function arguments. It's entirely true that arguments should have meaningful names but sometimes it's impossible. Standard C# function comments let you document arguments. The argument comment appears right when you need

[go-nuts] keyword func

2020-04-27 Thread レミリア・スカーレット
Why you need to write a "func sum(a, b int) int {...}", not "sum(a, b int) int {...}"? It seems to me that one could do without func keyword. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving email

[go-nuts] Need a way to check only key exist or not? without value?

2020-04-27 Thread adithyasashasai
Basically i need a slice with indexed values, so that i can check only existence. or a map with only keys? How it can be done? -- 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] func before function

2020-04-27 Thread valent . xarin
Why is it necessary to write func in go before declaring a function; if in C, when parsing a function, there is no such need? Why "func sum(a, b int) int {...}" can't be "sum(a, b int) int {...}" -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. T

Re: [go-nuts] Need a way to check only key exist or not? without value?

2020-04-27 Thread burak serdar
On Mon, Apr 27, 2020 at 10:46 AM wrote: > > Basically i need a slice with indexed values, so that i can check only > existence. > or a map with only keys? Use a map with struct{} values: m:=make(map[keyType]struct{}) Then you can add keys by: m[key]=struct{}{} and check existence using: _,

[go-nuts] Re: keyword func

2020-04-27 Thread Uli Kunitz
You are correct the func keyword for function definitions is functionally not needed. But it helps readability very much and also allows a natural syntax for anonymous functions and the definition of function types. Another factor is that it simplifies parser programming. > > -- You received

Re: [go-nuts] keyword func

2020-04-27 Thread Marvin Renich
* レミリア・スカーレット [200427 12:46]: > Why you need to write a "func sum(a, b int) int {...}", not "sum(a, b int) > int {...}"? > It seems to me that one could do without func keyword. I believe another reason is that the Go language designers decided that every top-level syntax element begins with a k

Re: [go-nuts] Deleting map entry from the top level of a nested map doesn't clean the underlying memory

2020-04-27 Thread Jake Montgomery
Perhaps a small program that reproduces the issue would help. I wrote a quick one: https://play.golang.org/p/hbnuZsEqUKV . However, after an hour of running I see no "leak". I am on "go1.14 windows/amd64". After 6,000,000 iterations and 4 TB total allocated The memory stats (HeapInuse and Hea

Re: [go-nuts] Deleting map entry from the top level of a nested map doesn't clean the underlying memory

2020-04-27 Thread Ian Lance Taylor
On Sun, Apr 26, 2020 at 9:57 PM Naveen Kak wrote: > I have my system up and running for let's say 10 hours or so where these > operations on map ( continuous add/delete) keep happening. Memory keeps > growing and goes very high. > Eventually at end of test we clear all map entries, memory is recl

Re: [go-nuts] keyword func

2020-04-27 Thread Ben Hoyt
Yeah, I agree with Marvin. "func" is also needed for anonymous functions and defining function types. This would be quite weird (and probably not easily parseable): add := (a, b int) int { return a+b } type adder (a, b int) int Most importantly for me, explicit syntax for this allows me

[go-nuts] Re: func before function

2020-04-27 Thread Ben Hoyt
> > Why is it necessary to write func in go before declaring a function; if in > C, when parsing a function, there is no such need? > Why "func sum(a, b int) int {...}" can't be "sum(a, b int) int {...}" > See discussion at very similar thread: https://groups.google.com/forum/#!topic/golang-nut

Re: [go-nuts] What is the current state of formatting and stack trace info for error values post 1.13 release?

2020-04-27 Thread Ian Lance Taylor
On Sun, Apr 26, 2020 at 8:18 PM pankaj pipada wrote: > > Any takers, please? I think the current status is that we have not in fact revisited these ideas. Sorry. Ian > On Tue, Apr 21, 2020 at 9:37 PM pankaj pipada wrote: >> >> As per comment: >> https://github.com/golang/go/issues/29934#iss

Re: [go-nuts] Concurrent io.Copy(tcpConn, file) and tcpConn.Write(...)

2020-04-27 Thread Ian Lance Taylor
On Sun, Apr 26, 2020 at 4:55 PM Liam wrote: > > During an io.Copy() where the Writer is a TCPConn and the Reader is a 200K > disk file, my code may concurrently Write() on the same TCPConn. > > I see the result of the Write() inserted into the result of the io.Copy(). I > had the impression that

Re: [go-nuts] Why do we use xchg rather than lock mov to inplement atomic.StoreX?

2020-04-27 Thread Ian Lance Taylor
On Sun, Apr 26, 2020 at 1:31 AM Cholerae Hu wrote: > > Atomic.StoreX doesn't return the old value of the given pointer, so lock mov > would work. Why do we use a xchg instead? It there any performance issue? I assume that you are talking about Intel processors. Intel processors do not have a lo

Re: [go-nuts] Concurrent io.Copy(tcpConn, file) and tcpConn.Write(...)

2020-04-27 Thread Liam
On Monday, April 27, 2020 at 4:22:41 PM UTC-7, Ian Lance Taylor wrote: > > On Sun, Apr 26, 2020 at 4:55 PM Liam > > wrote: > > > > During an io.Copy() where the Writer is a TCPConn and the Reader is a > 200K disk file, my code may concurrently Write() on the same TCPConn. > > > > I see the

Re: [go-nuts] Concurrent io.Copy(tcpConn, file) and tcpConn.Write(...)

2020-04-27 Thread Ian Lance Taylor
On Mon, Apr 27, 2020 at 5:10 PM Liam wrote: > > On Monday, April 27, 2020 at 4:22:41 PM UTC-7, Ian Lance Taylor wrote: >> >> On Sun, Apr 26, 2020 at 4:55 PM Liam wrote: >> > >> > During an io.Copy() where the Writer is a TCPConn and the Reader is a 200K >> > disk file, my code may concurrently W

Re: [go-nuts] Concurrent io.Copy(tcpConn, file) and tcpConn.Write(...)

2020-04-27 Thread Liam
On Monday, April 27, 2020 at 5:56:52 PM UTC-7, Ian Lance Taylor wrote: > > On Mon, Apr 27, 2020 at 5:10 PM Liam > > wrote: > > > > On Monday, April 27, 2020 at 4:22:41 PM UTC-7, Ian Lance Taylor wrote: > >> > >> On Sun, Apr 26, 2020 at 4:55 PM Liam wrote: > >> > > >> > During an io.Copy()

Re: [go-nuts] Concurrent io.Copy(tcpConn, file) and tcpConn.Write(...)

2020-04-27 Thread Liam
On Monday, April 27, 2020 at 5:56:52 PM UTC-7, Ian Lance Taylor wrote: > > On Mon, Apr 27, 2020 at 5:10 PM Liam > > wrote: > > > > On Monday, April 27, 2020 at 4:22:41 PM UTC-7, Ian Lance Taylor wrote: > >> > >> On Sun, Apr 26, 2020 at 4:55 PM Liam wrote: > >> > > >> > During an io.Copy()

[go-nuts] Re: Need a way to check only key exist or not? without value?

2020-04-27 Thread Shishir Verma
I think the idiomatic way to implement a set in golang is to use a map with bool values. Here is an example from effective go documentation : attended := map[string]bool{ "Ann": true, "Joe": true, ... } if attended[person] { // will be

Re: [go-nuts] Need a way to check only key exist or not? without value?

2020-04-27 Thread Randall O'Reilly
I think map[string]struct{} takes no storage for the value and is the most efficient way to do this. - Randy > On Apr 27, 2020, at 7:20 PM, Shishir Verma wrote: > > I think the idiomatic way to implement a set in golang is to use a map with > bool values. Here is an example from effective go

Re: [go-nuts] Concurrent io.Copy(tcpConn, file) and tcpConn.Write(...)

2020-04-27 Thread Ian Lance Taylor
On Mon, Apr 27, 2020 at 6:59 PM Liam wrote: > > On Monday, April 27, 2020 at 5:56:52 PM UTC-7, Ian Lance Taylor wrote: >> >> On Mon, Apr 27, 2020 at 5:10 PM Liam wrote: >> > >> > On Monday, April 27, 2020 at 4:22:41 PM UTC-7, Ian Lance Taylor wrote: >> >> >> >> On Sun, Apr 26, 2020 at 4:55 PM Lia