[go-nuts] Why is type inference still so rudimentary?

2023-08-04 Thread Nate Finch
If I have a struct type User struct { Name string ID int } type Group struct { Leader User } Why is it that the go tool can't infer what type I'm constructing for the Leader field here? g := Group{ Leader: { Name: "Jamie", ID: 5, }, } Cleary, the

[go-nuts] Mage release v1.11.0 - Argument support!

2020-12-28 Thread Nate Finch
Mage v1.11.0 supports taking positional arguments for targets that have arguments of type int, bool, string, or time.Duration. For example, if your magefile contains this target: func Build(what string) { fmt.Printf("building the %s...\n", what) } you can run it by running $ mage build

[go-nuts] Help test arg support in Mage

2020-12-28 Thread Nate Finch
Mage (magefile.org and github.com/magefile/mage) is getting support for arguments in targets and dependencies. I'd love some people running the PR branch through its paces to make sure I haven't missed anything before landing it, since this is kind

[go-nuts] Re: political fundraising on golang.org!

2020-06-16 Thread Nate Finch
Raise your hand if you think black lives don't matter? Raise your hand if you think "[providing] legal representation to prisoners who may have been wrongly convicted of crimes, poor prisoners without effective representation, and others who may have been denied a fair trial." is a bad thing?

[go-nuts] Re: select on slice of channels

2019-09-14 Thread Nate Finch
You're better off funnelling everything into a single channel. There's little real difference between reading from one channel that N things write to, and reading from N channels that have one writer each. -- You received this message because you are subscribed to the Google Groups

Re: [go-nuts] Type inference inside struct literals? Pretty Please?

2019-09-13 Thread Nate Finch
Thanks! Yes, let's do that :) On Thursday, September 12, 2019 at 6:28:02 PM UTC-4, Ian Lance Taylor wrote: > > On Thu, Sep 12, 2019 at 2:02 PM Nate Finch > wrote: > > > > I wish go's type inference worked inside struct literals. Filling out > config structs

[go-nuts] Type inference inside struct literals? Pretty Please?

2019-09-12 Thread Nate Finch
I wish go's type inference worked inside struct literals. Filling out config structs would be so much easier if this worked: type Config struct { Runtime struct { Debug bool } } c := Config{ Runtime: { Debug: true, }, } ^^ why can't this work? It seems unambiguous. The

[go-nuts] A counter proposal to the try proposal - catch

2019-06-27 Thread Nate Finch
I really don't like the try proposal , because I think it hurts readabiity of the code. But I think the fix is not too hard, so I made a counter proposal, catch: https://github.com/golang/go/issues/32811 Catch works just like try, except it has to

Re: [go-nuts] [Job] remote Go developer at Mattel (fulltime, US-only)

2019-06-19 Thread Nate Finch
I live outside the US but this really makes me want to work for > Mattel. Sounds like a great place to work. > > On Tue, Jun 18, 2019, 22:07 Nate Finch > > wrote: > >> Want to work with me at Mattel on a Go platform? >> >> Mattel’s Connected Products Platform team i

[go-nuts] [Job] remote Go developer at Mattel (fulltime, US-only)

2019-06-18 Thread Nate Finch
Want to work with me at Mattel on a Go platform? Mattel’s Connected Products Platform team is *the model* of where Mattel is going with its products. It is a service platform expanding to be used by teams all across the whole 30,000 person company. We’re looking for a senior backend developer

Re: [go-nuts] Re: Starlight - run python inside Go to extend your applications - easily

2018-12-10 Thread Nate Finch
Justin got this 100% correct. Starlight and Starlark are not intended to be used to just run existing python code. there's a ton they don't support, so pretty much any non-trivial python program would not be compatible. It's really more of a way to give users the ability to write small to

[go-nuts] Starlight - run python inside Go to extend your applications - easily

2018-12-07 Thread Nate Finch
I’d like to announce starlight - https://github.com/starlight-go/starlight. Starlight wraps google’s Go implementation of the starlark python dialect (most notably found in the Bazel build tool). Starlight makes it super easy for users to extend your

[go-nuts] Re: What am I missing here? FYI, I'm completely new to golang xD

2018-09-04 Thread Nate Finch
Others covered this, but let me try to explain. In Go, plain = just assigns to an already existing variable var x bool // declares a variable, it starts with the zero value for the type x = true // assigns a value to the variable y := true // declares the variable and assigns it a value

[go-nuts] Mage v1.2.4 is the latest release

2018-09-03 Thread Nate Finch
Mage (https://github.com/magefile/mage) had not been using semantic versioning, and this caused problems with go modules. To support go modules, I have ripped out the v2.x tags, and keps mage on v1. This is semantically correct, since mage has always been backwards compatible. It also

[go-nuts] [ANN] Mage 2.3.0 - Now with Go Modules Support

2018-09-02 Thread Nate Finch
Please check it out, and let me know if there are any problems with modules support. https://github.com/magefile/mage https://magefile.org *About Mage* I don't think I've posted here about Mage, so for those that haven't seen it, it's a Make replacement, sort of like Ruby's Rake, except

[go-nuts] Re: vgo and vanity imports

2018-05-23 Thread Nate Finch
FYI, this was answered my Russ on Twitter, for a while the format was not in the spec, but it has returned now. -- 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

[go-nuts] vgo and vanity imports

2018-05-22 Thread Nate Finch
Forgive me if this has been answered somewhere. I tried to divine it from Russ' documents, but I couldn't really tell. Do vanity imports change dramatically with vgo? Currently, all I have to do to support a vanity import is to return a page at https://gnorm.org/gnorm that has a meta element

[go-nuts] Re: Go 1.10 Beta 1 is released

2017-12-08 Thread Nate Finch
"ResolveReference now preseves" *preserves -- 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

[go-nuts] Re: Flagging lazy-loaded fields as being unsafe to access directly

2017-11-19 Thread Nate Finch
Just use a comment. That's usually fine. // this is lazy loaded, use getBar() instead of directly accessing. "Don't do that" is a surprisingly feasible solution to a lot of programming problems. Not everything has to be enforced by tooling. On Sunday, November 19, 2017 at 9:08:47 PM UTC-5,

[go-nuts] Re: Cross compiled binary caches goroot?

2017-10-16 Thread Nate Finch
ch is does, but not the *current* environment. On Monday, October 16, 2017 at 11:59:30 PM UTC-4, Nate Finch wrote: > > So I figured out I was looking for the error in the wrong place. The > place it was failing was in go/types when it tries to parse the files, > using the go/build.Default context.

[go-nuts] Re: Cross compiled binary caches goroot?

2017-10-16 Thread Nate Finch
So I figured out I was looking for the error in the wrong place. The place it was failing was in go/types when it tries to parse the files, using the go/build.Default context. Which is created here: https://github.com/golang/go/blob/master/src/go/build/build.go#L285 It uses either the GOROOT

Re: [go-nuts] Re: Cross compiled binary caches goroot?

2017-10-16 Thread Nate Finch
t; by constants or functions in this package, but they do not influence the > execution of the run-time system. > > I'd first be inclined to think Mage source has done something to cause the > GOROOT constant to influence run-time execution. > > On Mon, Oct 16, 2017 at 11:27 AM Nate Fin

[go-nuts] Re: Cross compiled binary caches goroot?

2017-10-16 Thread Nate Finch
well now, that's weird. I just tried this in a minimal use case, compiled a linux command on my mac and ran it on my ubuntu box that just did the below... and it worked. Now I'm wondering what the difference is. On Monday, October 16, 2017 at 10:55:02 AM UTC-4, Nate Finch wrote: > > Nop

[go-nuts] Re: Cross compiled binary caches goroot?

2017-10-16 Thread Nate Finch
:= c.Run() It should probably even work without setting GOROOT explicitly, but it definitely should if I do (presuming GOROOT is correct, of course) On Monday, October 16, 2017 at 12:07:06 AM UTC-4, Nate Finch wrote: > > Reporting back: this worked perfectly. > > On Sunday, Oct

[go-nuts] Re: Cross compiled binary caches goroot?

2017-10-15 Thread Nate Finch
Reporting back: this worked perfectly. On Sunday, October 15, 2017 at 7:43:47 PM UTC-4, Dave Cheney wrote: > > Thank should work. > > On Monday, 16 October 2017 10:30:45 UTC+11, Nate Finch wrote: >> >> hmm... I really don't want people to have to build Mage, since mage is

[go-nuts] Re: Cross compiled binary caches goroot?

2017-10-15 Thread Nate Finch
hmm... I really don't want people to have to build Mage, since mage is a build tool. Would it be horrible to just run go env GOROOT and use that to set GOROOT in the environs for the command that runs go build? On Sunday, October 15, 2017 at 5:36:43 PM UTC-4, Dave Cheney wrote: > > My guess

Re: [go-nuts] Cross compiled binary caches goroot?

2017-10-15 Thread Nate Finch
I'm not cross compiling the tool chain. I'm cross compiling a binary(Mage) that just calls os/exec with "go", "build" and passes through os.Environ I'll see if I can repro with a minimal example tonight. -- You received this message because you are subscribed to the Google Groups

[go-nuts] Cross compiled binary caches goroot?

2017-10-15 Thread Nate Finch
I cross compiled using go 1.9 if it matters. -- 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

[go-nuts] Cross compiled binary caches goroot?

2017-10-15 Thread Nate Finch
https://github.com/magefile/mage/issues/69 Mage calls go build via os/exec, explicitly passing through os.Environ to the subprocess. Somehow the cross compiled binary from my osx laptop is referencing the goroot from my laptop when it tries to run go build on a Linux machine. 1. How is

[go-nuts] Re: Magefiles - a makefile replacement using go

2017-09-25 Thread Nate Finch
slack if you want to chat about it :) On Friday, September 22, 2017 at 11:02:33 PM UTC-4, Nate Finch wrote: > > https://github.com/magefile/mage > > A mage file is any regular go file marked with a build target of "mage" > and in package main. > > // +build mage >

[go-nuts] Magefiles - a makefile replacement using go

2017-09-22 Thread Nate Finch
https://github.com/magefile/mage A mage file is any regular go file marked with a build target of "mage" and in package main. // +build mage package main You may have any number of magefiles in the same directory. Mage doesn't care what they're named aside from normal go filename rules. All

[go-nuts] Proposal: Just Use GitHub

2017-09-20 Thread Nate Finch
https://github.com/golang/go/issues/21956 Wherein I suggest that not using GitHub for PRs and Reviews for the Go Project itself is hurting the language and the community. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this

[go-nuts] Re: append() gotcha!

2017-08-16 Thread Nate Finch
Wrote it up as an issue: https://github.com/golang/go/issues/21482 and I agree that using append to assign to a different variable than the one in the append call is almost always going cause surprising behavior but it's less clearly a mistake than append with only a single argument. On

[go-nuts] Re: Full Time Job Opportunity at Mattel: Remote inside US OK

2017-08-16 Thread Nate Finch
Just in case it's not clear, since I've gotten a few responses from contractors: We're looking for full time employees only. Not contractors. You must live and be authorized to work in the United States. Thanks! -Nate -- You received this message because you are subscribed to the Google

[go-nuts] Re: Full Time Job Opportunity at Mattel: Remote inside US OK

2017-08-15 Thread Nate Finch
Thanks! I get a lot of the same questions, so I figure it's best to just put it all out there, and besides, if it gets just a few more people to respond, it's worth it. :) On Tuesday, August 15, 2017 at 11:13:22 AM UTC-4, Martin Ostrovsky wrote: > > I'm not interested in the job but just

[go-nuts] Full Time Job Opportunity at Mattel: Remote inside US OK

2017-08-15 Thread Nate Finch
Mattel (yes the toy company) is hiring full time Go devs to work on its IoT & identity server platform. Remote is OK if you're within the US. Both I and my manager (who would be your manager) are remote. I'm in Massachusetts, manager is in Ohio. Another dev in SF. Office is in San

Re: [go-nuts] Anyone using https://github.com/knq/xo?

2017-07-20 Thread Nate Finch
o have one less dependency. > > -- > Michael Banzon > https://michaelbanzon.com/ > > Den 20. jul. 2017 kl. 06.04 skrev Nate Finch <nate@gmail.com > >: > > We're thinking of dropping gorm and switching to plain old database/sql... > but I don't really want to gene

[go-nuts] Anyone using https://github.com/knq/xo?

2017-07-19 Thread Nate Finch
We're thinking of dropping gorm and switching to plain old database/sql... but I don't really want to generate all that boilerplate myself. xo looks like it does a reasonable job of generating the boilerplate for you, so I was wondering if anyone had any experience using it in production.

[go-nuts] An idea about motivating the community

2017-07-17 Thread Nate Finch
(sorry for the duplicate post, the other one disappeared) I wrote a tweet after Gophercon about making a resolution to write more blog posts. I used the hashtag #GopherResolution with the hope that other people might pick up the idea and run with it. So far, however, only one other person

[go-nuts] Deleted post?

2017-07-17 Thread Nate Finch
I guess my previous post was deleted? Can a mod contact me about it please? -- 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

[go-nuts] Re: REST API - Request Logging on Server

2017-07-17 Thread Nate Finch
Basically any log package will be pretty quick. None of them will be zero overhead, that's impossible, but most will not affect the time of your requests terribly significantly. I personally like logrus (https://github.com/sirupsen/logrus) for structured logging, it has a lot of adapters

[go-nuts] An idea about motivating the community

2017-07-17 Thread Nate Finch
I wrote a tweet after Gophercon about making a resolution to write more blog posts. I used the hashtag #GopherResolution with the hope that other people might pick up the idea and run with it. So far, however, only one other person has used the tag. There are studies on the effects of

[go-nuts] http://github.com/golang/protobuf has been broken for like 2 months?

2017-02-09 Thread Nate Finch
This bug has been open since mid-December https://github.com/golang/protobuf/issues/270 Maybe people who had it checked out before still have code there in their gopath, but for me, I get go get -u github.com/golang/protobuf/... package google.golang.org/genproto/protobuf: no buildable Go

[go-nuts] Re: Go is two times slower than python code?

2016-12-01 Thread Nate Finch
Generally, the answer is, don't use regular expressions. This is good advice in any language and for almost any problem. In this specific case, if you care about speed, write some more specific code that does what you need instead of falling back on regular expressions. On Wednesday,

[go-nuts] Re: Deleting the /r/golang subreddit

2016-11-25 Thread Nate Finch
Please note that Brad has since posted on Hacker News that he no longer wants to delete r/golang, but simply make it unofficial: https://news.ycombinator.com/item?id=13037636 I think this is perfectly fine. Honestly, I don't think many people felt that anything on reddit was official. --

[go-nuts] Re: Deleting the /r/golang subreddit

2016-11-24 Thread Nate Finch
Yes, the CEO did a really shitty thing. If we burned down the website of every company where someone in power did something shitty, we'd have no websites left. If you don't want to moderate, step down. Let the current moderators choose replacements. If you want to maintain the ability to

[go-nuts] Re: stop go run from printing "exit status 1"?

2016-11-05 Thread Nate Finch
Cool, thanks, done: https://github.com/golang/go/issues/17813 On Saturday, November 5, 2016 at 8:05:00 PM UTC-4, adon...@google.com wrote: > > > It does seem a little bit arbitrary and contrary to UNIX tool design > principles. It's unlikely that this is a compatibility concern for anyone. >

[go-nuts] stop go run from printing "exit status 1"?

2016-11-04 Thread Nate Finch
If the script you run with go run returns a non-zero exit status, go run prints "exit status N" and itself then returns with exit code 1. Now, this seems like a double mistake - first off, the only time go run should print anything out is if it had some problem actually running the code, i.e.

[go-nuts] Re: New to golang and have problem with packages

2016-11-04 Thread Nate Finch
make sure the thing you want to import is exported (i.e. starts with a capital letter). What is the exact error message you're getting? "Does not work" is fairly general, and makes it harder for us to help. On Friday, November 4, 2016 at 11:07:11 AM UTC-4, Merzouki M'heni wrote: > > Hy,

[go-nuts] Re: ActiveState seeking Go community feedback

2016-11-03 Thread Nate Finch
I'm curious to know what Activestate plans to bring to the table that isn't already a part of the go distributions people can download off of golang.org. I see it mentions the distribution including "popular modules" (I presume it means packages)... but given how easy it is to just go-get

[go-nuts] Re: [slightly OT] Is this a known virus written in Go?

2016-11-01 Thread Nate Finch
I have definitely heard of more than one virus being written in Go. For some reason, Go programs are just different enough from non-go prorgams, that virus scanners have a hard time categorizing them well, so many just don't try... evidently one of them is going the opposite direction and

[go-nuts] Re: Stalking people online for thought crimes! This is what the Go project has succumbed to!

2016-10-27 Thread Nate Finch
It seems like most of the problem with this whole situation comes from the wording of the "warning" Please consider this a warning from the Code of Conduct working group. > "consider this a warning" can be interpreted as a threat (though the "Please" in front should soften it somewhat). I

[go-nuts] Re: Stalking people online for thought crimes! This is what the Go project has succumbed to!

2016-10-27 Thread Nate Finch
We should know what is a violation by reading the code of conduct. Making the process public would make it a way to shame people, and also might discourage people from reporting for fear of reprisal. The intent is to inform people when they have said something that others find insulting or

Re: [go-nuts] Re: Golang should have a center packages index hosting like npm, rust crates

2016-10-26 Thread Nate Finch
Listing versions on godoc is an awesome idea. Peer pressure goes a long way toward changing individual minds and eventually a community. Something as simple as sorting projects with tagged versions higher and displaying them prominently on the project's godoc page (with the ability to look at

Re: [go-nuts] allow {3}, {true} etc

2016-10-24 Thread Nate Finch
And unless you have structs that use builtin type names, {5} won't currently compile. On Monday, October 24, 2016 at 3:45:29 PM UTC-4, rog wrote: > > How would new syntax be better than a built-in function with exactly the > semantics you are after and shorter to type to boot? > > On

[go-nuts] Re: Golang should have a center packages index hosting like npm, rust crates

2016-10-24 Thread Nate Finch
I, for one, really like that there's no central repository for go packages. I don't like the idea of a central authority telling me how and what I'm allowed to publish. I like that there's no one between a package I authored and a project using it except git clone (and, evidently, some DNS

Re: [go-nuts] allow {3}, {true} etc

2016-10-22 Thread Nate Finch
Go ever got generics, this would probably be trivial to write > generically, for example: > > func Ref[T](x T) *T { return } > > I don't think I'd object if we added a new builtin function called "ref" > with the above semantics. It worked pretty well in Limbo as a

Re: [go-nuts] allow {3}, {true} etc

2016-10-22 Thread Nate Finch
Which is effectively the same as my proposal, except horrible. On Sat, Oct 22, 2016, 12:18 PM Ian Lance Taylor wrote: > > You can, of course, write > p3 := &({5}).i > > Ian > -- You received this message because you are subscribed to the Google Groups "golang-nuts"

Re: [go-nuts] allow {3}, {true} etc

2016-10-21 Thread Nate Finch
com> wrote: > On Fri, Oct 21, 2016 at 9:20 PM Nate Finch <nate.fi...@gmail.com> wrote: > > > And, I would argue, it actually makes the language slightly more > regular, since now {v} works for just about everything (possibly > everything?). > > Taking the address of

Re: [go-nuts] allow {3}, {true} etc

2016-10-21 Thread Nate Finch
That's fair. But I think it's a worthwhile (and fairly minor) complexity to add to the spec to make the language a lot easier to use in some very common use cases. And, I would argue, it actually makes the language slightly more regular, since now {v} works for just about everything

Re: [go-nuts] allow {3}, {true} etc

2016-10-21 Thread Nate Finch
I don't think it's ambiguous at all. We already do different things for different T in T{v}. For slices, the slice is constructed and then each value is an item in the slice. For structs, the struct is constructed and then the fields are filled out in declaration order. We're just adding

Re: [go-nuts] allow {3}, {true} etc

2016-10-21 Thread Nate Finch
I had missed that, thanks. The one response does not really fit the problem, though. There are a lot of times when POS (plain old structs) make a really nice UX (or would, if they weren't a pain to handle). I like option types like Dave said, but that's really a whole different beast that

[go-nuts] allow {3}, {true} etc

2016-10-21 Thread Nate Finch
One of the problems with working with serialization of any kind is dealing with unset vs the zero value. The usual way to get around this is to use a pointer, nil is unset, non-nil is set. But this gets annoying when trying to make literal values, because you can't take the address of a

[go-nuts] Hosting Vanity imports on your Hugo static HTML blog

2016-10-17 Thread Nate Finch
Have a hugo blog? Want to give your go packages a custom import url (e.g. import "npf.io/gorram/run")? You can do it with just a few lines of templates / frontmatter. It took some figuring out to get this working, but once you know how to do it, it's pretty easy.

Re: [go-nuts] Re: [ANN] gorram: like go run for any* function in stdlib or GOPATH

2016-10-11 Thread Nate Finch
Next on my list is adding versioning to the generated scripts so you never have to worry about whether a script is old or not. Also note that I added -t so you can print out different parts of the respond if you want, e.g. $ gorram -t {{.Status}} net/http Get https://golang.org 200 OK On

Re: [go-nuts] Re: [ANN] gorram: like go run for any* function in stdlib or GOPATH

2016-10-07 Thread Nate Finch
...and now it works like you'd hope :) $ gorram net/http Get https://npf.io/gorram/run https://npf.io/gorram/"/>https://npf.io/gorram/; /> or if you want to get fancy: $ gorram net/http Get https://npf.io/gorram/run | gorram github.com/yosssi/gohtml Format https://npf.io/gorram/"/>

Re: [go-nuts] Re: [ANN] gorram: like go run for any* function in stdlib or GOPATH

2016-10-07 Thread Nate Finch
st admit it's the first thing I tried as it would have been a > gorram fun replacement for curl. > > > On 5 October 2016 at 19:56, Nate Finch <nate@gmail.com > > wrote: > > Glad you think so :) Suggestions and bugs welcome. It's under active > > devel

[go-nuts] github.com/juju/deputy has moved to npf.io/deputy

2016-10-06 Thread Nate Finch
https://github.com/juju/deputy has moved to https://httphttps:"//://http npf.io/deputy (code at https://github.com/natefinch/deputy) This is code I wrote at work, but that we ended up never using. It was rotting in the github organization, so I moved it to my personal namespace (with

[go-nuts] Re: [ANN] gorram: like go run for any* function in stdlib or GOPATH

2016-10-05 Thread Nate Finch
of being idiomatic in Go, not to mention implicit interfaces, that we can make a heck of a lot of things Just Work™. On Wednesday, October 5, 2016 at 12:53:24 PM UTC-4, setha...@gmail.com wrote: > > That is... awesome... > > On Monday, October 3, 2016 at 5:00:34 PM UTC-4, Nate Finch wrot

[go-nuts] Re: Cookies lose data when round tripped through net/http/cookiejar.Jar

2016-10-05 Thread Nate Finch
and Value, so that String() returns the right format. Thus, you *can't* round trip from SetCookie to GetCookies and back to SetCookie. Which is really unfortunate, but not something that can be fixed in the go1 timeframe. On Tuesday, October 4, 2016 at 9:23:43 PM UTC-4, Nate Finch wrote: > &g

[go-nuts] Cookies lose data when round tripped through net/http/cookiejar.Jar

2016-10-04 Thread Nate Finch
See here: https://play.golang.org/p/E4_8NiodmK Is this intended? The cookies returned from cookiejar.Jar.Cookies() don't include the domain, which is part of the key that they're stored under, so they're no longer "the same" cookies. -- You received this message because you are subscribed to

[go-nuts] [ANN] gorram: like go run for any* function in stdlib or GOPATH

2016-10-03 Thread Nate Finch
get it via the canonical import path: go get npf.io/gorram Code is at https://github.com/natefinch/gorram Still a work in progress, but fun to play around with right now. Lets you do things like this: $ echo 12345 | gorram encoding/base64.StdEncoding.EncodeToString MTIzNDU2Cg== or $

[go-nuts] Re: go/types equality rules are incredibly confusing

2016-10-01 Thread Nate Finch
That's a tutorial, not documentation. It would have been useful to have that information in the godoc. I agree it was a mistake to use a Type as a map key, but the fact that it does work for some Types was what was confusing (along with same types from different loaders not being Identical).

Re: [go-nuts] go/types - creating a Type from whole cloth?

2016-09-28 Thread Nate Finch
Oh yes, that's smart, just use go/types to parse the bytes package. Great, thanks! On Wednesday, September 28, 2016 at 9:27:20 AM UTC-4, Sebastien Binet wrote: > > > > On Wed, Sep 28, 2016 at 2:57 PM, > wrote: > >> You need to actually get the type of a *bytes.Buffer with

[go-nuts] Re: Mocking os.Open and related calls for more code coverage

2016-09-28 Thread Nate Finch
freeformz had a good suggestion to try to make your function take an io.Reader, which is good not just for testing, but for future flexibility... but of course, you still need some place that opens the file... that's inescapable. The way I test those sorts of things is to use a variable to

Re: [go-nuts] go/types - creating a Type from whole cloth?

2016-09-28 Thread Nate Finch
Sorry, I wasn't clear. I'm using the go/types package to read go code and generate wrapper code for it. And I need to generate different code based on the types of parameters a function takes. So like if a function takes a *bytes.Buffer to write to and I am generating a wrapper that wants

[go-nuts] go/types - creating a Type from whole cloth?

2016-09-27 Thread Nate Finch
I want to, for example, compare a Type from code I'm ingesting to see if it's a *bytes.Buffer is there a way I can make my own Type from a value or type definition in my code so that I can compare the two Types? Or do I have to do something ugly like comparing the String() output of the

Re: [go-nuts] Why does context.CancelFunc exist?

2016-08-29 Thread Nate Finch
So, just a note... the CancelFunc type doesn't prevent you from passing in any old func(), since those are considered effectively literals (IIRC), so they can be automatically converted to the CancelFunc type. For example: https://play.golang.org/p/QNbVXorlEQ The only time the compiler will

[go-nuts] Why does context.CancelFunc exist?

2016-08-25 Thread Nate Finch
The type seems unnecessary. It doesn't actually do anything different than a regular func(). Does it just exist to give a place for common documentation for each of the methods that use it? IMO, the With* functions would be more clear if they didn't use a named type for func(), because now

[go-nuts] Re: Initialize Variables in case clause of a switch

2016-08-09 Thread Nate Finch
I actually just tried to do this the other day. Forgot it wasn't possible. Seems like it would make the language more consistent to allow it. As it is, it's rather surprising that it doesn't work. -- You received this message because you are subscribed to the Google Groups "golang-nuts"

[go-nuts] Re: Go is for everyone

2016-07-19 Thread Nate Finch
Great post, and I agree wholeheartedly. Go is far simpler to learn than any other production-ready language (excluding languages that are only used for teaching, like Scratch)... but AFAIK, there's no "intro to programming, which happens to use Go". I think this is pretty easily doable (and I

[go-nuts] Re: Strange results from append

2016-07-15 Thread Nate Finch
it is almost always a bad idea to use append and assign the result to a different value than the thing you're appending to. i.e. always do this: ns = append(ns, foo...) and don't do this: bar := append(ns, foo...) The thing is, that in that last line, like in your code, bar and ns *might*

Re: [go-nuts] Unmarshalling and tags

2016-06-21 Thread Nate Finch
I'd like to see something like this: type Payment struct { ActionType paypal.ActionType `xml,yaml,json:"actionType,omitempty"` ReceiverList paypal.ReceiverList `xml,yaml,json:"actionType,omitempty"` } -- You received this message because you are subscribed to the Google Groups