[go-nuts] C's readdir equivalent

2017-10-18 Thread Bakul Shah
os.Readdirnames() just returns dir enry names[1], while os.Readdir() lstats all the dir entries. Pretty much every OS's (C lang) readdir() returns a direntry's type without having to stat the underlying file. More often than not this is all one wants -- not everyone wants to walk a directory

[go-nuts] Re: help with go dep

2017-10-18 Thread Dave Cheney
You must import the package as golang.org/x/sys On Thursday, 19 October 2017 14:21:40 UTC+11, Andrew Chambers wrote: > > > $ dep version > dep: > version : devel > build date : > git hash: > go version : devel +7b9d15d566 Wed Oct 18 21:45:30 2017 + > go compiler : gc >

[go-nuts] help with go dep

2017-10-18 Thread andrewchamberss
$ dep version dep: version : devel build date : git hash: go version : devel +7b9d15d566 Wed Oct 18 21:45:30 2017 + go compiler : gc platform: linux/amd64 $ dep init No versions of github.com/golang/sys met constraints: master: Could not introduce

Re: [go-nuts] nil maps

2017-10-18 Thread Alex Dvoretskiy
Looks fun!: https://play.golang.org/p/8mqzb-1H7f On Tuesday, October 17, 2017 at 10:39:46 AM UTC-7, Thomas Bushnell, BSG wrote: > > Here's a case that comes up for me: > > type table map[string]map[string]string > > func (t table) add(x, y, z string) { > if t[x] == nil { > t[x] =

RE: [go-nuts] accept4: too many open files;

2017-10-18 Thread Eliezer Croitoru
Hey, It really depends on couple factors and I am not sure I am following exactly what body are you closing or supposed to close? Also it depends on the client side of the connection and the keep-alive settings of the connection. The other factor is the actual load on the system. If it's a

[go-nuts] [dep] is it planned to integrate `go get` and future `go dep`?

2017-10-18 Thread Denis Cheremisov
Hi! I struggled a couple of days ago with an issue caused by the fact the *go get* is not aware of dependencies defined by the current *dep*, which I am using for the development purposes. *dep* sticked to fixed https://github.com/antlr/antlr4 version (latest, v4.7 released in march 2017),

[go-nuts] When should a RoundTripper close its connection?

2017-10-18 Thread trevordixon
I'm using httputil.ReverseProxy with an http.RoundTripper of my own implementation that uses an ssh.Channel as a transport. My RoundTrip method looks approximately like this: func (c SSHConnection) RoundTrip(req *http.Request) (*http.Response, error) { ch, err := c.GetChannel() if err != nil {

Re: [go-nuts] Re: Panic recovery and mutex lock question

2017-10-18 Thread Ian Lance Taylor
On Wed, Oct 18, 2017 at 7:46 AM, David Renne wrote: > > I guess I was wondering still if we had existing code with multiple mutexes > being locked or rLocked where we didnt have the defer unlocks and those > panic. > > I guess I dont understand why you would want the lock

Re: [go-nuts] Re: log. Sprintf

2017-10-18 Thread Rob Pike
fmt.Fprintf is fine for concurrent use if you use it properly. It does a single write system call to the output once the result is created. C does not guarantee that, if that's how you came to think it unsafe. The same applies to log.Printf. -rob On Thu, Oct 19, 2017 at 6:48 AM, Alex Buchanan

[go-nuts] Re: Panic recovery and mutex lock question

2017-10-18 Thread Juliusz Chroboczek
> I guess I dont understand why you would want the lock entirely for the > entire execution of the function until the defer. You can get the effect of block-scoped defers by using a local anonymous function: func f(a *A) { func() { a.mu.Lock() defer

[go-nuts] Re: afpacket does not get GRE tunneled packets?

2017-10-18 Thread Juliusz Chroboczek
This is not Go-specific, I hope I'm not breaking some unwritten rule by replying. > I just figured this out. I need to manually set the NIC to promiscuous > mode. > Now the question is, is there a way to set the NIC to promiscuous mode > in code, like in pcap.openlive? You want to call

[go-nuts] Re: log. Sprintf

2017-10-18 Thread Alex Buchanan
You mean fmt.Fprintf right? Formatting a string without writing to a io.Writer (fmt.Sprintf) must be safe for concurrent use. The "log" package should be safe for concurrent use, and has a Printf function: https://godoc.org/log#Logger """ A Logger represents an active logging object that

[go-nuts] log. Sprintf

2017-10-18 Thread David Renne
I had a question that I cant seem to figure out. I know fmt is a bad package to use if you have any concurrent workers because it uses f.Write() and is not thread safe apparently. But I like using Sprintf because I can format strings and return as a string. How can I implement something to

[go-nuts] Re: How to convert byte slice to UUID?

2017-10-18 Thread howardcshaw
I don't know if you are going to get very far on that, as it seems to have been a deliberate change: " It differs from these earlier packages in that a UUID is a 16 byte array rather than a byte slice." Looks from here: https://github.com/pborman/uuid/issues/3 like being able to use them as

Re: [go-nuts] How to convert byte slice to UUID?

2017-10-18 Thread paul . h . breslin
We're using github.com/google/uuid I'll post an issue there. Thanks. -- 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.

Re: [go-nuts] Re: Ternary operator needed in Go

2017-10-18 Thread Nicolas Grilly
On Monday, October 16, 2017 at 8:37:25 PM UTC+2, Dave Cheney wrote: > > Prior to this recent post, this thread had been dormant for eight years. I > think the results speak for themselves and this topic does not need to be > revisited again. At least, it proves people are searching in the

Re: [go-nuts] How to convert byte slice to UUID?

2017-10-18 Thread Ian Lance Taylor
On Wed, Oct 18, 2017 at 8:05 AM, wrote: > > We are passing 16 byte binary UUIDs via grpc and need to be able to cast > these from byte slice back to type uuid.UUID. > There doesn't seem to be an easy way to do this. It would be nice if the > UUID package had a method

[go-nuts] [JOB] Senior Software Engineer (Backend/API team) @ TreeTop Commons in Portland, OR

2017-10-18 Thread imprintpdx
Hi everyone! I'm hiring for the awesome, diverse engineering team at *TreeTop Commons* , a Certified B-Corp located in the Pearl District whose team works to create unique software that bridges social gaps by tracking volunteer service and connecting

[go-nuts] dynamic xml

2017-10-18 Thread Jeffrey Smith
I have a lot of XML documents that have sections in that contain tags that can be of any name but will contain type,minOccurs,maxOccurs and have a description inside it. For instance name,description,definition and id below. description number1 user graphCreate API

[go-nuts] Re: afpacket does not get GRE tunneled packets?

2017-10-18 Thread Chun Zhang
I just figured this out. I need to manually set the NIC to promiscuous mode. Now the question is, is there a way to set the NIC to promiscuous mode in code, like in pcap.openlive?? I don't see that option with AF_packet. Thanks, Chun On Tuesday, October 17, 2017 at 6:31:21 PM UTC-4, Chun

[go-nuts] How to convert byte slice to UUID?

2017-10-18 Thread paul . h . breslin
We are passing 16 byte binary UUIDs via grpc and need to be able to cast these from byte slice back to type uuid.UUID. There doesn't seem to be an easy way to do this. It would be nice if the UUID package had a method for this. This works but is there a better way? var b [16]byte

[go-nuts] Re: Panic recovery and mutex lock question

2017-10-18 Thread David Renne
Thank you Ian. I guess I was wondering still if we had existing code with multiple mutexes being locked or rLocked where we didnt have the defer unlocks and those panic. I guess I dont understand why you would want the lock entirely for the entire execution of the function until the defer.

Re: [go-nuts] repeatable builds

2017-10-18 Thread Jack Christensen
On 10/18/2017 03:08 AM, Conrad Wood wrote: I did (admittedly found it only after I send the email). I give that a try and see how it goes - thank you! And advice on point #2 by any chance? When I have a mixed language repo I tend to include an entire GOPATH in the the repo. Something like

Re: [go-nuts] Golang version 1.9.2

2017-10-18 Thread Jacob Cartledge
Great stuff, Thanks. Jake On Wednesday, 18 October 2017 15:18:00 UTC+1, Ian Lance Taylor wrote: > > On Wed, Oct 18, 2017 at 7:06 AM, Jacob Cartledge > wrote: > > Fantastic! > > > > However, how soon is real soon? Days, weeks, months? > > Probably days. No guarantees,

Re: [go-nuts] Golang version 1.9.2

2017-10-18 Thread Ian Lance Taylor
On Wed, Oct 18, 2017 at 7:06 AM, Jacob Cartledge wrote: > Fantastic! > > However, how soon is real soon? Days, weeks, months? Probably days. No guarantees, of course. Ian > On Wednesday, 18 October 2017 15:00:17 UTC+1, Ian Lance Taylor wrote: >> >> On Wed, Oct 18, 2017

Re: [go-nuts] Golang version 1.9.2

2017-10-18 Thread Jacob Cartledge
I'm just trying to see if its worth looking at a work around for periodically clearing an expvar Map. On Wednesday, 18 October 2017 15:06:15 UTC+1, Jacob Cartledge wrote: > > Fantastic! > > However, how soon is real soon? Days, weeks, months? > > > Cheers > Jake > > On Wednesday, 18 October

Re: [go-nuts] Golang version 1.9.2

2017-10-18 Thread Jacob Cartledge
Fantastic! However, how soon is real soon? Days, weeks, months? Cheers Jake On Wednesday, 18 October 2017 15:00:17 UTC+1, Ian Lance Taylor wrote: > > On Wed, Oct 18, 2017 at 3:30 AM, > wrote: > > > > Is any body aware of an ETA for Golang v1.9.2? > > > > I'm

Re: [go-nuts] Golang version 1.9.2

2017-10-18 Thread Ian Lance Taylor
On Wed, Oct 18, 2017 at 3:30 AM, wrote: > > Is any body aware of an ETA for Golang v1.9.2? > > I'm currently waiting on a fix that's in master but not in Go v1.9.1. Real Soon Now. Ian -- You received this message because you are subscribed to the Google Groups

Re: [go-nuts] best practice to read/write shared map in a web application

2017-10-18 Thread Shawn Milochik
My suggestion is something like this: https://play.golang.org/p/1NdQbAW65k There is a discussion very similar to this from a few days ago: https://groups.google.com/forum/#!topic/golang-nuts/AeV0BYaWABw -- You received this message because you are subscribed to the Google Groups "golang-nuts"

[go-nuts] Golang version 1.9.2

2017-10-18 Thread hi . im . jc
Hi All, Is any body aware of an ETA for Golang v1.9.2? I'm currently waiting on a fix that's in master but not in Go v1.9.1. Thanks! -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails

Re: [go-nuts] accept4: too many open files;

2017-10-18 Thread lee
In the end the fix seemed to be implementing some timeouts. I found a good guide here... https://blog.cloudflare.com/the-complete-guide-to-golang-net-http-timeouts/ On Tuesday, October 17, 2017 at 10:01:17 PM UTC+1, Tamás Gulácsi wrote: > > Yes. -- You received this message because you are

Re: [go-nuts] Re: perfs of a Go binary VS C++

2017-10-18 Thread mura
Could you use `perf record ./test f64s.root` and then `perf report --stdio` for both the Go and C++ programs? (You may need to `echo 0 | sudo tee /proc/sys/kernel/kptr_restrict before perf record, supposing that you can test it on Linux) I am just interested in the performance comparison

[go-nuts] best practice to read/write shared map in a web application

2017-10-18 Thread woosley. xu.
Hi, I am writing an application here using echo framework, this application(*client node*) runs on every server and report its OS/Hardware facts to a master node. On master, it store all the server facts in a big map, the key

[go-nuts] Re: Make error handling less verbose with Zig %% operator and %return expression?

2017-10-18 Thread Nicolas Grilly
On Wednesday, October 18, 2017 at 4:50:32 AM UTC+2, Bryan Mills wrote: > > There are lots of similar proposals in the issue tracker. > Of those, https://golang.org/issue/21161 seems to have the most traffic. > Bryan, thanks for the link. I wasn't aware of Ian's proposal. -- You received this

Re: [go-nuts] repeatable builds

2017-10-18 Thread Conrad Wood
I did (admittedly found it only after I send the email). I give that a try and see how it goes - thank you! And advice on point #2 by any chance? On Tue, 2017-10-17 at 19:46 +0100, roger peppe wrote: > Have you looked at the dep tool (github.com/golang/dep) ? > > On 17 Oct 2017 13:42,

Re: [go-nuts] Re: How to pass a value to multiple readers of a shared channel

2017-10-18 Thread Юрий Соколов
Between those two lines (fetching value from channel and sending it back to channel) channel is empty. This leads to two possible errors: - less dangerous is if some checks channel in non-blocking mode (ie select with default). Then it sees empty channel and thinks value is not set yet. - more

Re: [go-nuts] Re: How to pass a value to multiple readers of a shared channel

2017-10-18 Thread roger peppe
On 18 October 2017 at 06:05, Sokolov Yura wrote: > Following is a dangerous error-prone technique. If you use it in you program, > most likely you have a hidden bug, that will appear in high concurrency > situation. > > ``` > func wait(c chan T) T { > v :=

Re: [go-nuts] Implementing futures with channels [was: How to pass a value...]

2017-10-18 Thread 'Axel Wagner' via golang-nuts
What you are doing is what sync.Once was invented for: https://play.golang.org/p/erZqwFYgIR On Tue, Oct 17, 2017 at 11:37 PM, Juliusz Chroboczek wrote: > > The answer depends on whether you have just one value or many. For a > single > > value (sometimes known as a "future"), I