Re: [go-nuts] Re: command to pre-compile vendor libs

2024-04-30 Thread Harmen
> > It all works fine, just wondering if there's a nicer way to get all
> > "compilable" packages stored in /vendor.
> 
> go list ./vendor/...

I knew there had to be a simpler way, 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/ZjCxUOsjOdDnnRiK%40arp.lijzij.de.


[go-nuts] command to pre-compile vendor libs

2024-04-30 Thread Harmen
Hi,

in both my Nix and Docker builds I have a step to build all libraries in
/vendor, and then cache that. Works great, saves me multiple minutes for every
CI build.

Now I would like to improve the command, this is what I currently use:

$ go build -v `cat vendor/modules.txt |grep -v '#'|grep -v sys/windows|grep -v 
tpmutil/tbs|grep -v internal`

In order to keep the cache key valid I can't depend on my own code, I can only
depend on go.{mod,sum} and on what's in /vendor/. The sys/windows and 
tpmutil/tbs are packages which
have "build constraints exclude all Go files".

It all works fine, just wondering if there's a nicer way to get all
"compilable" packages stored in /vendor.

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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/ZjCQ-HorXAXMvqK8%40arp.lijzij.de.


Re: [go-nuts] Convert html text to pdf using go language .

2024-04-05 Thread Harmen
On Fri, Apr 05, 2024 at 06:45:03AM -0700, KRITIKA AWASTHI wrote:
>  I want to convert html text to pdf using go language .
> Previously, I used chromedp 
>  to create PDFs, but it 
> was consuming too much server capacity. So, currently I am using using 
> wkhtmltopdf  package  which is  
> deprecated .
> There is one more package, gofpdf 
> , which is also deprecated 
> and no longer maintained  .
> I would appreciate if you suggest  some other alternatives of these 
> packages . 

We use weasyprint with plain `cmd := exec.Command(Exe, "--stylesheet", cssfile, 
"-", "-")` and some Go templating. Nothing fancy, works, looks nice.

-- 
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 discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/ZhAljVe1x70MdKpx%40arp.lijzij.de.


Re: [go-nuts] Re: assert library with generics?

2024-02-23 Thread Harmen
On Thu, Feb 22, 2024 at 04:41:53PM -0800, Seth Hoenig wrote:
> https://github.com/shoenig/test
> 
> We've been using this for a couple years now, and it's been great. I am 
> biased though, for obvious reasons. It makes use of the go-cmp library 
> under the hood for creating legible diffs, and integrates well with 
> protocmp for when you need to work with protobufs. 

That's exactly what I was looking for:

  func Eq[A any](t T, exp, val A, settings ...Setting)

Will give it a try, thanks!


> 
> On Thursday, February 22, 2024 at 2:20:57 AM UTC-6 Harmen wrote:
> 
> > Hi,
> >
> > anyone has a tip for a nice (small) "assert" test help library which uses 
> > generics for the "equals" and "not equals" functions?
> >
> > testify is the obvious library to use for tests, which works fine, but it 
> > would
> > be nice to have something which uses generics here.
> >
> > 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/61fe55d0-8e3d-4dc0-a12e-00f48dbc7856n%40googlegroups.com.

-- 
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 discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/ZdhYe9qzxjII5HBo%40arp.lijzij.de.


[go-nuts] assert library with generics?

2024-02-22 Thread Harmen
Hi,

anyone has a tip for a nice (small) "assert" test help library which uses 
generics for the "equals" and "not equals" functions?

testify is the obvious library to use for tests, which works fine, but it would
be nice to have something which uses generics here.

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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/ZdcDz2ULDQl02Z3R%40arp.lijzij.de.


Re: [go-nuts] Re: pure-go implementation of sqlite

2020-06-16 Thread Harmen
> > is there (or is somebody working on) a pure-go implementation of sqlite ? 
> > or at least a subset of it, to be able to read sqlite files ? 
> >
> > -s 
> >
> > PS: I know about the (by now) canonical implementations 
> > (mattn/go-sqlite and others) but a completely go-based solution would 
> > facilitate deployment and development across devs machines... 

If you only need to read, and not write, sqlite files, have a look at
https://github.com/alicebob/sqlittle

-- 
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 discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/20200616103957.GA6629%40arp.lijzij.de.


Re: [go-nuts] Dependency hell with Go modules

2019-01-17 Thread Harmen
On Fri, Jan 18, 2019 at 07:18:41AM +1300, Justin Israel wrote:
> On Fri, Jan 18, 2019, 12:36 AM Francis Chuang  wrote:
> 
> > Hey everyone,
> >
> > I was wondering if I can get some ideas on how to solve this dependency
> > problem with Go modules. I am using Go 1.11.4 on Linux (Windows Subsystem
> > for Linux to be exact).
> >
> > The first part of the problem is that for one of my libraries, I am
> > importing github.com/hashicorp/vault/api, which is an api client to
> > access Vault servers. This package is pretty thin and does not contain a
> > lot of dependencies. However, the root project at
> > github.com/hashicorp/vault has quite a few dependencies.
> > If I delete the current go.mod and go.sum files in my library and start
> > from scratch:
> > - I run go mod init github.com/username/mylibrary
> > - I then run go mod tidy to add missing packages to my go.mod and generate
> > a go.sum
> >
> > Go mod imports the Vault repository at its root (
> > github.com/hashicorp/vault) as expected. Unfortunately, this pulls in a
> > lot of subdependencies and I have a ton of indirect dependencies in my
> > go.mod and go.sum. This is not unexpected of course as this is how go
> > modules work. Unfortunately, this does slow down continuous integration
> > builds and is probably not great for Github and VCS hosts as each build
> > pulls in all of these unneeded dependencies.
> >
> > The second problem is that 2 of Vault's subdependencies (not sure how
> > deep) is labix.org/v2/mgo and launchpad.net/gocheck. These are bazaar
> > repos, so they necessitate the installation of the bzr tool. In my library,
> > I added the following to my go.mod to force it to pull from the Github
> > repos:
> >
> > replace labix.org/v2/mgo => github.com/go-mgo/mgo
> > v0.0.0-20160801194620-b6121c6199b7
> >
> > replace launchpad.net/gocheck => github.com/go-check/check
> > v0.0.0-20180628173108-788fd7840127
> >
> > This works great for running tests in the username/mylibrary repo as I no
> > longer need to install bzr when running my CI builds. However, if I create
> > another project such as github.com/username/some-project and import
> > username/mylibrary, go mod will attempt to download launchpad.net/gocheck
> > and labix.org/v2/mgo from the original bazaar repos when running go test
> > and other commands.These causes errors such as `go:
> > labix.org/v2/mgo@v0.0.0-20140701140051-0287: bzr branch
> > --use-existing-dir https://launchpad.net/mgo/v2 . in
> > /go/pkg/mod/cache/vcs/ca61c737a32b1e09a0919e15375f9c2b6aa09860cc097f1333b3c3d29e040ea8:
> > exec: "bzr": executable file not found in $PATH `. This is quite annoying
> > and I'd like to avoid having to add those `replace` statements in the
> > go.mod of projects that consume the mylibrary package. In addition,
> > consumers of my library would need to install bazaar (which most people
> > probably won't have installed).
> >
> > The 2 options I have thought of are:
> > 1. Ask the Vault team to extract the api package into a separate
> > repository. I am not sure how likely they would be interested in doing
> > this, but I am guessing it would be quite low.
> > 2. Make a copy of the api package and copy it directly into my library.
> > This is something I am hoping to avoid as much as possible, because I'd
> > like to use go modules to manage my dependencies.
> >
> > Are there any other options I've missed?

Yes: don't run `go mod tidy`
See for example: https://github.com/golang/go/issues/27920
(which was also with a hashicorp project)

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] go mod tidy pulls in too much

2018-09-28 Thread Harmen
On Fri, Sep 28, 2018 at 10:19:50AM -0700, thepudds1...@gmail.com wrote:
> Hi Harmen,
> 
> And my first sentence might not have been clear. When I said "even in your 
> current situation, 'go build' is still pulling in exactly what it needs", I 
> was trying to reference the actual compilation process.
> 
> In other words, I was just trying to make it clear that even if you have 
> "extra" dependencies appearing in your go.mod file, the resulting binary 
> produced by 'go build' does not have anything extra or any unused 
> dependencies.

Hi thepudds,
thanks for your anwers.

It doesn't hurt per-se, but all those unused modules will be vendored in the
repo (or the CI will have to download them every time). Maybe the consul repo
is a particularly unlucky repo, since the /api package is small compared to the
rest of the repo, but still.

As for the argument that it's for test reproducibility, I do not follow that.
Everything to test /api is there, and the stuff I don't import doesn't need to
be tested in the first place.

> In any event, I wanted to share at least my personal understanding, but of 
> course happy to learn more...

I'm trying to do the same :)
Thanks!

> 
> --thepudds
> 
> 
> On Friday, September 28, 2018 at 1:00:17 PM UTC-4, thepud...@gmail.com 
> wrote:
> >
> >  > "So if consul adds a go.mod file in the root, then `mod tidy` will 
> > suddenly 
> > behave as I would expect (i.e. not pull in unused dependencies)? "
> >
> > Hi Harmen,
> >
> > Just in case this isn't already clear-- note that even in your current 
> > situation, 'go build' is still pulling in exactly what it needs (and not 
> > pulling in unused dependencies).
> >
> > I think there is not a significant harm in your go.mod containing these 
> > indirect dependencies (aside from of course seeing that longer list, etc.).
> >
> > And there is some benefit -- this behavior is part of what provides for 
> > 100% reproducible builds and tests. The modules system records precise 
> > dependency version information, and in your case, that precise dependency 
> > version information for some of your indirect dependencies is being 
> > recorded in your go.mod (given that it is not yet recorded in the 
> > non-existent go.mod of some of your direct dependencies).  
> >
> > As an example, this behavior helps make sure that `go test all` is 100% 
> > reproducible for you (where `go test all` runs tests for both your module, 
> > your direct dependencies, and your indirect dependencies, which is valuable 
> > as one way of validating that the currently selected packages versions are 
> > compatible -- the number of possible version combinations is exponential in 
> > the number of modules, so in general you cannot expect your dependencies to 
> > have tested against all possible combinations of *their* dependencies).
> >
> > --thepudds
> >
> > On Friday, September 28, 2018 at 12:48:20 PM UTC-4, Harmen wrote:
> >>
> >> On Fri, Sep 28, 2018 at 04:48:32PM +0100, Paul Jolly wrote: 
> >> > Hi Harmen 
> >> > 
> >> > I described the problem on https://github.com/golang/go/issues/27920, 
> >> which 
> >> > > got 
> >> > > closed within three minutes as being "documented", and "works as 
> >> > > expected" (which I assume also means "works as intended"). 
> >> > > Is this really the intented behaviour? It seems unexpected to me. Or 
> >> > > should I 
> >> > > simply stay away from `go mod tidy`? 
> >> > > 
> >> > 
> >> > I replied to your issue earlier. But could arguably have been slightly 
> >> more 
> >> > detailed in my response beyond simply linking to 
> >> > 
> >> https://github.com/golang/go/wiki/Modules#why-does-go-mod-tidy-record-indirect-and-test-dependencies-in-my-gomod
> >>  
> >> > 
> >> > As you note, github.com/hashicorp/consul/api is a package. It is a 
> >> package 
> >> > in the module github.com/hashicorp/consul. Despite there being no 
> >> go.mod in 
> >> > github.com/hashicorp/consul, the go tool simulates it as a module. 
> >> > 
> >> > Given there are no go.mod files in any subdirectories below 
> >> > github.com/hashicorp/consul, then github.com/hashicorp/consul is the 
> >> module 
> >> > for all the packages github.com/hashicorp/consul/... 
> >> > 
> >> > Hence go mod tidy (per the link in my response to your issue) is 
> >

Re: [go-nuts] go mod tidy pulls in too much

2018-09-28 Thread Harmen
On Fri, Sep 28, 2018 at 04:48:32PM +0100, Paul Jolly wrote:
> Hi Harmen
> 
> I described the problem on https://github.com/golang/go/issues/27920, which
> > got
> > closed within three minutes as being "documented", and "works as
> > expected" (which I assume also means "works as intended").
> > Is this really the intented behaviour? It seems unexpected to me. Or
> > should I
> > simply stay away from `go mod tidy`?
> >
> 
> I replied to your issue earlier. But could arguably have been slightly more
> detailed in my response beyond simply linking to
> https://github.com/golang/go/wiki/Modules#why-does-go-mod-tidy-record-indirect-and-test-dependencies-in-my-gomod
> 
> As you note, github.com/hashicorp/consul/api is a package. It is a package
> in the module github.com/hashicorp/consul. Despite there being no go.mod in
> github.com/hashicorp/consul, the go tool simulates it as a module.
> 
> Given there are no go.mod files in any subdirectories below
> github.com/hashicorp/consul, then github.com/hashicorp/consul is the module
> for all the packages github.com/hashicorp/consul/...
> 
> Hence go mod tidy (per the link in my response to your issue) is pulling
> in the transitive dependencies needed for tests in
> github.com/hashicorp/consul/... The reason you see all of these in your
> go.mod is that github.com/hashicorp/consul has not yet been converted to a
> module as yet.
> 
> Hopefully that gives a bit more colour on what's going on here.

Hi Paul,

thanks for your extended reply.

So if consul adds a go.mod file in the root, then `mod tidy` will suddenly
behave as I would expect (i.e. not pull in unused dependencies)? And until they
add it (if ever) I either better not run `mod tidy`, or simply go back to the
old dep system?

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] go mod tidy pulls in too much

2018-09-28 Thread Harmen
Hi all,

I've been converting some work projects to use go.mod.
Today I ran into a problem that after importing the sub-package
github.com/hashicorp/consul/api `go mod tidy` pulled in everything imported
anywhere in the hashicorp/consul repo, even if it's never imported in my
project.

I described the problem on https://github.com/golang/go/issues/27920, which got
closed within three minutes as being "documented", and "works as
expected" (which I assume also means "works as intended").
Is this really the intented behaviour? It seems unexpected to me. Or should I
simply stay away from `go mod tidy`?

Thanks!
Harmen

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Fancy Comments & Documentation

2018-04-19 Thread Harmen
On Wed, Apr 18, 2018 at 10:37:26PM -0700, Chris FractalBach wrote:
> So, I'm one of those people who sometimes adds comments like this to my 
> code:
> 
> ++
> |   Program Title|
> |   Author   |
> |Date|
> ++
>  Synopsis, Description, etc.
> __
> 
> 
> However, adding comments like this into Go code often ruins the 
> documentation, so I have been avoiding it.
> Are there any solutions to get the best of both worlds?

If you indent that part of the comment it should end up in a  block.

Do note that godoc does give you headers if you do this:

> Each span of unindented non-blank lines is converted into a single paragraph.
> There is one exception to the rule: a span that consists of a single line, is
> followed by another paragraph span, begins with a capital letter, and contains
> no punctuation is formatted as a heading. 
https://golang.org/pkg/go/doc/#ToHTML

Maybe that helps enough.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Go 1.10 is released

2018-02-16 Thread Harmen
On Fri, Feb 16, 2018 at 02:35:44PM -0500, Andrew Bonventre wrote:
> Hello gophers,
> 
> We just released Go 1.10.
> 
> You can read the announcement blog post here:
>   https://blog.golang.org/go1.10
> 
> You can download binary and source distributions from our download page:
>   https://golang.org/dl/
> 
> To compile from source using a Git checkout, update to the release with
> "git checkout go1.10" and build as usual.
> 
> To find out what has changed, read the release notes:
>   https://golang.org/doc/go1.10

Great!

Can we have an update of https://golang.org/doc/devel/release.html ?
(To serve as reference in wikipedia, mostly)

Thanks!
Harmen

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] go build for mips

2017-06-22 Thread Harmen
On Thu, Jun 22, 2017 at 11:32:27AM -0700, Nathan Kerr wrote:
> >
> > I try to build a simple hello world with
> > cgo_enabled=1 goarch=mips goos=linux go build hello.go| Result: 
> > illegal instruction 

They need to be captitals:

$ GOARCH=mips GOOS=linux go build


> >
> > file information: ELF 32-bit MSB executable, MIPS, MIPS32 version 1 
> > (SYSV), statically linked, not stripped
> >
> > Also, tried to build with another compile (CC=/path/to/Compiler) instead 
> > the one go uses. Also illegal instruction 
> > on my router tp-linkwdr3500.
> >
> > If anyone could give me a hint, I would be grateful.
> >
> > Thanks,
> > Lucas.
> >
> >
> > On Thursday, June 22, 2017 at 11:37:08 AM UTC-3, Ian Lance Taylor wrote:
> >>
> >> On Wed, Jun 21, 2017 at 7:48 PM, lucas.w...@gmail.com 
> >>  wrote: 
> >> > 
> >> > Since go1.8 added support for mips32, why can't build a simple hello 
> >> world 
> >> > for a mips architecture system? 
> >> > 
> >> > I successfully build programs for arm architecture, but could not do 
> >> the 
> >> > same for mips. 
> >>
> >> Tell us precisely what you did and precisely what happened. 
> >>
> >> Ian 
> >>
> >
> 
> -- 
> 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.
> For more options, visit https://groups.google.com/d/optout.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] glog with logrotate

2017-06-12 Thread Harmen
On Sun, Jun 11, 2017 at 05:52:14PM -0700, Kumkum wrote:
> Hi,
> 
> Is there an easy way to use logrotate with golang/glog 
> (https://github.com/golang/glog) ?

I wrote my own logrotate-like-replacement thing:
https://github.com/realzeitmedia/glogrotate

maybe that helps.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Initializing a channel as "Closed" so that it doesn't block if a "Thing" hasn't been done yet

2016-07-13 Thread Harmen B
I don't understand the problems 100%, but maybe these things can point you
in the right direction:

- try to see if using a sync.WaitGroup{} can help you. WaitGroups are great
to use when you need to keep track of a varying bunch of Go routines.
- you can send channels over channels, to wait for things to happen.
In pseudo-pseudo-code:

type myThing struct {
quit chan chan struct{}
}

func (m *myThing) Quit() {
q := make(chan struct{})
m.quit <- q
<- q
}

elsewhere:

for {
select {
case <-somewhere:
// do something.
case q := <- m.quit:
// tell all Go routines to quit and wait for that. Maybe
using a WaitGroup
close(q)
}
}

On Wed, Jul 13, 2016 at 6:28 PM, Evan Digby  wrote:

> Hi All,
>
> I'm looking for some advice on a pattern I've found myself trapped in. I
> don't think I like it.
>
> For all examples, assume I have to meet the following interface (enforced
> externally):
>
> type DoerCloser interface {
> Do()
> Close()
> }
>
>
> The code below is mostly snippets from:
>
> https://play.golang.org/p/RQp97u4ZeK
>
> First, the part that seems standard (or is this my first incorrect
> assumption?):
>
> I'm using a "closed" (or "closing") channel to tell all methods on a
> struct that the user has asked us to close, and then a "done" channel to
> allow the methods to alert that they're done.
>
> func (t *doerCloser) do() {
> t.doneDoing = make(chan struct{})
> defer close(t.doneDoing)
> for {
> select {
> case <-t.closed:
> return
> case <-time.After(time.Second):
> fmt.Println("Doing a thing!")
> }
> }
> }
>
> func (t *doerCloser) Close() {
> close(t.closed)
> <-t.doneDoing
> }
>
> This works fine if the "New" function that creates the struct kicks off
> the action, and therefore the "doneDoing" channel is always created and in
> a good state.
>
> func NewDoerCloser1() DoerCloser {
> dc := {
> closed: make(chan struct{}),
> }
> go dc.do()
> return dc
> }
>
> User can do the following safely:
>
> dc := NewDoerCloser1()
> defer dc.Close()
>
>
> Where it gets tricky is if "Do" can't be kicked off right away. In my
> current real-world example I need to meet an external interface, and the
> interface dictates that "Do" kicks of the thing--in other examples perhaps
> you simply want the user to be able to explicitly start the doing.
>
> // If "do" is never called, Close will "Block" because it's a nil channel
> func NewDoerCloser2() DoerCloser {
> return {
> closed: make(chan struct{}),
> }
> }
>
> If "do" is never called, then "Close" will block forever on:
>
> <-t.doneDoing.
>
> One solution would be to create "doneDoing" and then close it immediately.
> Seems crazy to me; however, It's fairly simple so perhaps it isn't crazy?
>
> func NewDoerCloser3() DoerCloser {
> doneDoing := make(chan struct{})
> defer close(doneDoing)
>
> return {
> closed:make(chan struct{}),
> doneDoing: doneDoing,
> }
> }
>
> Another solution would be to "kick off" the "Do" functionality, but have
> it wait to start processing until "Do" is explicitly called. This seems
> much more complex than the "create and close immediately" idea.
>
> func NewDoerCloser() DoerCloser {
> dc := {
> closed:   make(chan struct{}),
> doCalled: make(chan struct{}),
> }
>
> go dc.do()
>
> return dc
> }
>
> func (t *doerCloser) do() {
> t.doneDoing = make(chan struct{})
> defer close(t.doneDoing)
>
> select {
> case <-t.closed:
> return
> case <-t.doCalled:
> }
>
> // Let's start doing!
>
> for {
> select {
> case <-t.closed:
> return
> case <-time.After(time.Millisecond):
> fmt.Println("Doing a thing!")
> }
> }
> }
>
>
> https://play.golang.org/p/qA3_oFF_EP
>
> Any other options? Am I totally crazy? Is this overcomplicated and there
> is a much simpler solution I'm spacing on?
>
> Thank's everyone!
>
> Evan
>
> --
> 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.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.