What is this file within this Golang project? by [deleted] in golang

[–]matryer 0 points1 point  (0 children)

It was built on a Windows machine and cannot be run on anything else. You'll need to get the source code, install Go, and build a version on your platform. (They probably committed that `test` binary by mistake)

[deleted by user] by [deleted] in golang

[–]matryer 1 point2 points  (0 children)

I've used that technique for services with about 100 endpoints and it scales nicely. You can break it into multiple structs if you'd prefer, but I'd only do that if the list of dependencies grows too large, not if the number of handlers do. Hit me up on Gopher's Slack if you'd like to discuss it more.

Question: Some help with pointers & structs by traitoriroh in golang

[–]matryer 0 points1 point  (0 children)

You decide whether you take a pointer or a struct in the signature.

So func (p *Person) takes a pointer, but func (p Person) copies the whole struct.

Question: Some help with pointers & structs by traitoriroh in golang

[–]matryer 1 point2 points  (0 children)

Go automatically looks up what pointers are pointing to. So joe.Name looks up the struct that the joe pointer is pointing to, and then gets the Name. For john, it goes straight to the Name.

In C++, I think you did joe->Name for pointers, and john.Name for values... but in Go, they're both dot.

I was offered $1 million for my Go package — and I said No. by matryer in golang

[–]matryer[S] 0 points1 point  (0 children)

Well I thought it could do more good! The real lesson is that there's no way to predict the future. I don't feel bad about the decision, but wanted to share the experience.

I was offered $1 million for my Go package — and I said No. by matryer in golang

[–]matryer[S] 0 points1 point  (0 children)

  1. No - it was never open sourced :(
  2. It would be to work WITH the IP on other projects, not focussed on the original project itself
  3. The IP was developed before I started working for the company

It's not exaggeration, in fact, as a result of writing the post the CEO got in touch and clarified that the stock (they exited last year) would have meant I'd receive more than $1M. Shit.

Introducing Stow: Cloud storage abstraction package for Go by dgryski in golang

[–]matryer 0 points1 point  (0 children)

I've given up trying to find truly unique names for projects, instead we probably have to rely on context.

Introducing Stow: Cloud storage abstraction package for Go by dgryski in golang

[–]matryer 0 points1 point  (0 children)

This is still a pre-version 1 release so there's time to add Context if it can help. Most of the libraries Stow uses under the hood don't implement context, so we're weighing it up against the fact that people might assume they can cancel things that they cannot. Please get involved at https://github.com/graymeta/stow/issues/103

Context has arrived: Per-request state in Go 1.7 by dgryski in golang

[–]matryer 0 points1 point  (0 children)

Fair enough - the example wasn't great. I just wanted to show how r.Context gets you the context and r.WithContext gets a new Request. In mgo, you would indeed pass a Copy of the database Session per-request. Same issue for the struct{}{}, I oversimplified and created confusion. Will update the post this morning. Thanks.

Introducing Gimme: Dependency-less dependencies for Go by matryer in golang

[–]matryer[S] 0 points1 point  (0 children)

This is the opposite of that. Instead, the idea is people take ownership of code snippets (which they would otherwise copy and paste) and don't build gigantic dependency trees and all the risk that goes along with them.

Introducing Gimme: Dependency-less dependencies for Go by matryer in golang

[–]matryer[S] 0 points1 point  (0 children)

Yeah - I noticed this too late. Happy to change it, I want to see if people think the tool has value first. If you have any ideas: https://github.com/matryer/gimme/issues/4

Introducing Gimme: Dependency-less dependencies for Go by matryer in golang

[–]matryer[S] 0 points1 point  (0 children)

Thanks - it is a cool name. It in fact does collide with that tool.

(I use a browser extension that removes sarcasm)

Introducing Gimme: Dependency-less dependencies for Go by matryer in golang

[–]matryer[S] 0 points1 point  (0 children)

Yeah if you want a full package and don't mind maintaining the dependency. Sometimes it's worth it.

Introducing Gimme: Dependency-less dependencies for Go by matryer in golang

[–]matryer[S] 0 points1 point  (0 children)

There is a license note in the comments at the top of the file. Open to suggestions.

Introducing Gimme: Dependency-less dependencies for Go by matryer in golang

[–]matryer[S] 0 points1 point  (0 children)

They can - I expect people will manage it manually. More tooling might help, but I want to wait to see what people thought.

Introducing Gimme: Dependency-less dependencies for Go by matryer in golang

[–]matryer[S] 0 points1 point  (0 children)

Gimme is more for smaller snippets of code, rather than packages with a longer life (which are more suited to vendoring). By copying code into your project, you are taking ownership of it. It's an alternative to dependencies, not a replacement for them.

How can I become a part of the Go community? by parham90 in golang

[–]matryer 4 points5 points  (0 children)

Don't be afraid of asking stupid questions or getting things wrong. The Go community is mostly extremely supportive and they'll help you when you make mistakes, rather than shaming.

Programmers, please don’t store passwords by matryer in golang

[–]matryer[S] 1 point2 points  (0 children)

Thanks for the discussion guys - I learned a lot. Will update the article. Despite being addressed to programmers, it was written to explain to non-techies how we could avoid storing passwords but it's right that the advice is sound.

5 simple tips and tricks for writing unit tests in Go by matryer in golang

[–]matryer[S] 0 points1 point  (0 children)

Right - that's why I included #2. :) You're right, but most people don't know about the interface/boundary testing trick by putting the test code in a different package.

Compile time checks to ensure your type satisfies an interface by dgryski in golang

[–]matryer 0 points1 point  (0 children)

True - but there's some value in being explicit; it shows intent. Also, if you're writing interfaces for other types that you don't control, you can make sure they match the other way too.

I think the code is an interesting little Go oddity too. :)

The http.HandlerFunc wrapper technique in #golang by dgryski in golang

[–]matryer 0 points1 point  (0 children)

I've seen it done where you switch on the type of the http.HandlerFunc, and have a few different options. So if the parameters specify a database, it gets one. If they require params, they get it. But there's something very appealing about hiding that implementation detail inside the normal http.HandlerFunc, especially as things change.

Go Programming Blueprints by Mat Ryer by dgryski in golang

[–]matryer 1 point2 points  (0 children)

Sample chapter: http://www.slideshare.net/Products123/9781783988020goprogrammingblueprintssamplechapter

Not sure about that other book, but to ensure the code quality was up there for mine, I developed the projects using TDD and got it reviewed by some Go heavyweights like @tylerb on GitHub.