[go-nuts] Re: Language proposal: labelled "with" statements to help make test code easier to write

2020-02-29 Thread Jason E. Aten
Try Test Driven Development. Since testing is non-negotiable, write your tests first and let them structure your implementation incrementally. It will radically improve your software. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscri

[go-nuts] Re: RFC Package structuring

2020-02-29 Thread haskell_mustard via golang-nuts
1 go.{mod|sum} per repository, no vendoring tree/ angular-ui/ cmd/ hello-api-server/ hello-cli/ hello-daemon/ internal/ internal-lib1/ internal-lib2/ library1/ library2/ library3/ python-tests/ go.mod go.sum On Saturday, 29 February 2020 19:03:34 UTC+1, Sankar wrote: >

Re: [go-nuts] How to handle EINTR from syscall.Dup2

2020-02-29 Thread Philip Boampong
On Sun, Mar 1, 2020 at 3:06 AM Ian Lance Taylor wrote: > > > But if you opened newfd yourself, or if it is 0/1/2 and you never > > closed os.Std*, then you *can* dup2 safely, regardless of other > > packages. > > Those are examples where you are in charge of the FD namespace > (assuming you know t

Re: [go-nuts] How to handle EINTR from syscall.Dup2

2020-02-29 Thread Kurtis Rader
On Sat, Feb 29, 2020 at 7:35 AM Uli Kunitz wrote: > My reading of the Linux kernel sources (5.3) is that dup2 will never > return -EINTR. Any necessary file closure will happen, but its return value > will be ignored. > That a specific implementation might never return EINTR as a result of a `du

Re: [go-nuts] How to handle EINTR from syscall.Dup2

2020-02-29 Thread Kurtis Rader
In addition to all of the other points that have been made by Ian and others I think it is important to reinforce another point. On UNIX like systems every function call that returns a file descriptor (e.g., `open()` and `socket()`) is expected to return the lowest unused file descriptor. If the se

Re: [go-nuts] Re: RFC Package structuring

2020-02-29 Thread Sankar P
ஞாயி., 1 மார்., 2020, முற்பகல் 4:17 அன்று, hartzell எழுதியது: > On Saturday, February 29, 2020 at 10:03:34 AM UTC-8, Sankar wrote: >> >> I am starting a new project (say `hello`) and I am totally confused about >> what package structure to use. [...] >> > > You might find the project-layout note

[go-nuts] Re: SIGILL running 1.14 on macOS

2020-02-29 Thread Jon Conradt
I am looking forward to 1.14.1, this ruined my Saturday. :( -- 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. To view this

Re: [go-nuts] How to handle EINTR from syscall.Dup2

2020-02-29 Thread Ian Lance Taylor
On Sat, Feb 29, 2020 at 12:16 PM Philip Boampong wrote: > > Can you really do that? I don't think the standard library guarantees > that it will not create a new FD behind the scenes tomorrow (nor it > exactly documents its FD usage and timing). I forgot to reply to this point. The Go standard l

Re: [go-nuts] How to handle EINTR from syscall.Dup2

2020-02-29 Thread Ian Lance Taylor
On Sat, Feb 29, 2020 at 12:16 PM Philip Boampong wrote: > > On Sat, Feb 29, 2020 at 1:34 PM Ian Lance Taylor wrote: > > > > It does not make sense to use dup2 if you are not in control of the FD > > namespace. In order to use dup2 you need to specify the new FD. If > > that FD might be concurre

[go-nuts] help w/ therecipe/qt

2020-02-29 Thread Justin Israel
You are likely to get the most focused support by checking with the project: https://github.com/therecipe/qt/blob/master/README.md Maybe asking on their slack channel if you can't figure it out from the Qt docs + therecipe/qt api? -- You received this message because you are subscribed to the

Re: [go-nuts] help w/ therecipe/qt

2020-02-29 Thread rob
"Getting Started w/ Qt 5," by Benjamin Baka.  Published by Packtpub On 2/29/20 2:55 PM, Rob Muhlestein wrote: Hi there Rob, would you mind sharing that book so I can share it with people on my rwxrob.live stream. I like the idea of doing what you are doing. I might be able to help you past th

[go-nuts] why would slice = slice[1:] allocate

2020-02-29 Thread Jason E. Aten
Profiling suggests that reslicing to remove the first element of a slice is doing alot of allocation; for instance in mycode() below. This is surprising to me How could this be? is there anything I can do about it? e.g. type A struct{ B string } func mycode(slice []A) { slice = slice[

[go-nuts] Re: RFC Package structuring

2020-02-29 Thread hartzell
On Saturday, February 29, 2020 at 10:03:34 AM UTC-8, Sankar wrote: > > I am starting a new project (say `hello`) and I am totally confused about > what package structure to use. [...] > You might find the project-layout notes from the golang-standards GitHub organization (which seems to be a

Re: [go-nuts] How to handle EINTR from syscall.Dup2

2020-02-29 Thread Philip Boampong
> If you are getting an error nothing has happened, no replacement of newfd and > no close I wish that sentence was written on the man page. That was the way I first understood it too (and it makes more sense) but the little information I found disagree (libuv [1], python [2] (see the note about

Re: [go-nuts] How to handle EINTR from syscall.Dup2

2020-02-29 Thread Uli Kunitz
On Saturday, February 29, 2020 at 9:32:11 PM UTC+1, Philip Boampong wrote > > Whether it cannot harm is what I'm trying to find out. > If newfd gets closed then a retry loop is racy, see my previous messages. > > [1] > https://stackoverflow.com/questions/23440216/race-condition-when-using-dup2

Re: [go-nuts] Language proposal: labelled "with" statements to help make test code easier to write

2020-02-29 Thread Dan Kortschak
Why can't you spell "with" as "func"? On Sat, 2020-02-29 at 06:16 -0800, Warren Stephens wrote: > I often write a function or module to handle some process that takes > 3 or 4 steps to complete. > > After I am happy with the code I then proceed to write tests for the > code, > but find that I am

Re: [go-nuts] How to handle EINTR from syscall.Dup2

2020-02-29 Thread Philip Boampong
On Sat, Feb 29, 2020 at 9:13 PM Brian Candler wrote: > > I don't quite follow. If two threads are fighting to use the target fd, then > that's just a race anyway. One case is when you have full control of the FD namespace, then you can rely on your own synchronization and do whatever you want,

Re: [go-nuts] Language proposal: labelled "with" statements to help make test code easier to write

2020-02-29 Thread Mhd Shulhan
Pada tanggal Min, 1 Mar 2020 01.11, Warren Stephens < wsteph...@prognoshealth.com> menulis: > I often write a function or module to handle some process that takes 3 or > 4 steps to complete. > > After I am happy with the code I then proceed to write tests for the code, > but find that I am compell

Re: [go-nuts] How to handle EINTR from syscall.Dup2

2020-02-29 Thread Philip Boampong
On Sat, Feb 29, 2020 at 4:35 PM Uli Kunitz wrote: > > My reading of the Linux kernel sources (5.3) is that dup2 will never return > -EINTR. Thanks, good to know. > But you will have to program the loop around the syscall anyway, because > Linux may return EBUSY, which happens if the new fd has

Re: [go-nuts] Re: How to handle EINTR from syscall.Dup2

2020-02-29 Thread Philip Boampong
On Sat, Feb 29, 2020 at 3:41 PM Manlio Perillo wrote: > > What about using fcntl with F_DUPFD? > [...] > It does not have the problems of dup2 where you can use an already in use fd, > and unlike dup you can specify where the new fd should be allocated. Thanks, good to know and may come in handy

Re: [go-nuts] How to handle EINTR from syscall.Dup2

2020-02-29 Thread Philip Boampong
On Sat, Feb 29, 2020 at 1:34 PM Ian Lance Taylor wrote: > > It does not make sense to use dup2 if you are not in control of the FD > namespace. In order to use dup2 you need to specify the new FD. If > that FD might be concurrently opened by some other package, or by the > runtime, then you can

Re: [go-nuts] How to handle EINTR from syscall.Dup2

2020-02-29 Thread Brian Candler
On Saturday, 29 February 2020 12:37:24 UTC, Ian Lance Taylor wrote: > > On Sat, Feb 29, 2020 at 12:33 AM Brian Candler > wrote: > > > > Just to ask the an obvious question: is dup2() idempotent or not? > > dup2 in itself is idempotent. But I'm not sure that is a useful > question. I think i

[go-nuts] Language proposal: labelled "with" statements to help make test code easier to write

2020-02-29 Thread Warren Stephens
I often write a function or module to handle some process that takes 3 or 4 steps to complete. After I am happy with the code I then proceed to write tests for the code, but find that I am compelled to chop the code into pieces in order to simplify the test code -- thereby losing the nice top

[go-nuts] RFC Package structuring

2020-02-29 Thread Sankar
I am starting a new project (say `hello`) and I am totally confused about what package structure to use. I am going to go with a monolithic source repository which would be checked out under `~/src` directory in the developer machines. I have three golang binaries available in my project. 1)

[go-nuts] help w/ therecipe/qt

2020-02-29 Thread rob
Hi.  I'm trying to learn therecipe/qt by working my way thru a book using C++ examples and translating them into Go.  I'm stuck at QKeySequence stuff. My computer runs ubuntu 18.04, and I installed Go 1.13.8 on it, along w/ all the Qt development stuff from qt.io, and therecipe/qt. Where are

[go-nuts] Can plugins be used across repositories?

2020-02-29 Thread Sean Russell
Has anyone had any success using plugins across repositories using Go modules? I have two github repositories; one uses plugins (USER), the other contains a plugin (USED). I have a tag on a commit in the USER repo, and the go.mod in the USED repo references that version. Both go.mod files ref

Re: [go-nuts] How to handle EINTR from syscall.Dup2

2020-02-29 Thread Uli Kunitz
My reading of the Linux kernel sources (5.3) is that dup2 will never return -EINTR. Any necessary file closure will happen, but its return value will be ignored. But you will have to program the loop around the syscall anyway, because Linux may return EBUSY, which happens if the new fd has been

[go-nuts] Re: How to handle EINTR from syscall.Dup2

2020-02-29 Thread Manlio Perillo
On Friday, February 28, 2020 at 9:41:39 PM UTC+1, pboam...@gmail.com wrote: > > (I've asked the same question already, but probably in the wrong thread, > sorry for the repost.) > > What to do on EINTR from syscall.Dup2 (Linux)? > > 1) It never happen. > 2) Retry. > 3) Take it as irrecoverable. >

Re: [go-nuts] How to handle EINTR from syscall.Dup2

2020-02-29 Thread Ian Lance Taylor
On Sat, Feb 29, 2020 at 12:33 AM Brian Candler wrote: > > Just to ask the an obvious question: is dup2() idempotent or not? dup2 in itself is idempotent. But I'm not sure that is a useful question. The issue is whether some other thread in the same process can open a file at the target file des

Re: [go-nuts] How to handle EINTR from syscall.Dup2

2020-02-29 Thread Ian Lance Taylor
On Fri, Feb 28, 2020 at 8:27 PM Philip Boampong wrote: > > The Go programmer is not fully in charge of the FD namespace: > libraries and the runtime can create new FDs at any time. Therefore, > unless you are sure that newfd *is* in use and know exactly what it > is, you are probably looking for t

[go-nuts] Re: modules and my v2 package only partly appearing on go.dev

2020-02-29 Thread Paul Hankin
On Friday, 28 February 2020 20:43:16 UTC+1, Paul Hankin wrote: > > I am rather confused about modules, and have trouble making them work. > > I have a package: https://github.com/paulhankin/poker > > The go.mod looks like this: ` > module github.com/paulhankin/poker/v2 > > go 1.13 > ` > > The packa

Re: [go-nuts] Significance of Mon Jan 2 15:04:05 -0700 MST 2006?

2020-02-29 Thread Adrian Ho
On 28/2/20 5:53 pm, Steve Mynott wrote: > I was just wondering what was the significance, if any, of the magic > time layout as used by time.Parse()? > Here's my answer from 2015, long before I started learning Go: https://www.quora.com/Why-is-the-Golang-reference-time-Jan-2-2006-at-3-04pm-MST?shar

Re: [go-nuts] How to handle EINTR from syscall.Dup2

2020-02-29 Thread Brian Candler
Just to ask the an obvious question: is dup2() idempotent or not? > > -- 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. T