Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
waffle enthusiast
Nov 16, 2007



MALE SHOEGAZE posted:

My main complain about go these days is that the community is full of luddites who are hostile towards both useful language features and anyone introducing a new library that attempts to do...anything. My main experiences are on the golang reddit, though, which is no longer an official community. So maybe it's not representative of the real go community.

I don't think the /r/golang was ever a real community to begin with. Not very many people, and most of the content was just hotlinks to random projects. The fact that they "killed" it because of the Reddit CEO's thing was just silly.

The Golang Slack is a pretty good resource.

Adbot
ADBOT LOVES YOU

Coffee Mugshot
Jun 26, 2010

by Lowtax
Go would love to have a good debugger, but it turns out debugging is hard. I think people take my favorite program, gdb, for granted.

Bozart
Oct 28, 2006

Give me the finger.

Coffee Mugshot posted:

Go would love to have a good debugger, but it turns out debugging is hard. I think people take my favorite program, gdb, for granted.

That is what I put in the go user survey as something go could use. (Also I put multi-dimensional arrays but hey, that poo poo ain't coming anytime soon)

bonds0097
Oct 23, 2010

I would cry but I don't think I can spare the moisture.
Pillbug

Bozart posted:

That is what I put in the go user survey as something go could use. (Also I put multi-dimensional arrays but hey, that poo poo ain't coming anytime soon)

What do you mean by multi-dimensional arrays? You can do slices of slices to arbitrary depth, right?

Bozart
Oct 28, 2006

Give me the finger.

bonds0097 posted:

What do you mean by multi-dimensional arrays? You can do slices of slices to arbitrary depth, right?

If you want to bounds check every single sub-slice, and not be able to rely on matrices being rectangular, sure.

e: there is a related benefit to having matrices laid out in memory in a specific way

Bozart fucked around with this message at 03:40 on Dec 15, 2016

Hadlock
Nov 9, 2004

I've been using VS Code 1.7+ with the golang plugin and hot drat am I ever a happy camper. It's bare bones but it's a very streamlined bare bones.

Cerberus911
Dec 26, 2005
Guarding the damned since '05
This was just announced

https://www.jetbrains.com/go/

Setting up was easy and there seems to be a working debugger.

Coffee Mugshot
Jun 26, 2010

by Lowtax
The debugger is delve and delve is good but not sufficient IMO. Derek Parker doesn't have enough real life time to make it much better, either, unfortunately.

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

Coffee Mugshot posted:

The debugger is delve and delve is good but not sufficient IMO. Derek Parker doesn't have enough real life time to make it much better, either, unfortunately.

If only Golang had a large corporate backer with the resources and motivation to develop a functional go debugger.

And of course, if Google were to release one, it would be balked at by the Go community as "over complicated." This would be followed by blog posts explaining why printf debugging is actually good, because it's easy to understand, and debuggers are bad because no one can understand how they work.

Coffee Mugshot
Jun 26, 2010

by Lowtax

MALE SHOEGAZE posted:

If only Golang had a large corporate backer with the resources and motivation to develop a functional go debugger.

And of course, if Google were to release one, it would be balked at by the Go community as "over complicated." This would be followed by blog posts explaining why printf debugging is actually good, because it's easy to understand, and debuggers are bad because no one can understand how they work.

We've written a few go debuggers and funded some other ones, look at the Cloud Debugger on GCP and Jetbrains Go debugger, respectively, but those are application specific debuggers. I think y'all are seriously underestimating how good gdb is and how hard it is to make anything close to as good as that. Delve is a good attempt but no one has real time to work on it and gdb works well enough for smallish programs without a million goroutines flying around.

mdxi
Mar 13, 2006

to JERK OFF is to be close to GOD... only with SPURTING

Go is being ported to RISC-V, partly by people at Google and partly by volunteers.

Slides and video from the 5th RISC-V workshop are available.

This is pretty neat, but it'll be pretty neat-er if RISC-V ever manages to become real hardware.

twitch125
Mar 11, 2003

Bull in the China Shop

Hadlock posted:

I've been using VS Code 1.7+ with the golang plugin and hot drat am I ever a happy camper. It's bare bones but it's a very streamlined bare bones.

I love VS Code, I use it at work with js and at home.. this extension: https://marketplace.visualstudio.com/items?itemName=lukehoban.Go has been awesome, is this the one you are referring to? It installed gocode and a few other helpful things also, even though like MSSQL, I've found I never end up using the intellisense stuff, but the syntax help is awesome, like when it tells me I don't have to specify a string type because it can be inferred. I figure those are things Ill learn as I go more into it, but for now it is great. Loving Go so far! Im pretty dogmatic about syntax style, to the point my colleagues poke fun at me, and Go has been sort of reinforcing for me in that regard, haha.

Hadlock
Nov 9, 2004

Will have to double check when I get home, I have a list of about 11 plugins I run that gets my workflow done.

And yeah, go linter in vscode go plugin is the poo poo, everything I do now goes through a linter. There's a ton of brittle legacy code that someone wrote, basically in notepad, and years later people are still running in to null issues that would have never happened had they been using a linter to catch all those gross mistakes.

bonds0097
Oct 23, 2010

I would cry but I don't think I can spare the moisture.
Pillbug

Hadlock posted:

Will have to double check when I get home, I have a list of about 11 plugins I run that gets my workflow done.

And yeah, go linter in vscode go plugin is the poo poo, everything I do now goes through a linter. There's a ton of brittle legacy code that someone wrote, basically in notepad, and years later people are still running in to null issues that would have never happened had they been using a linter to catch all those gross mistakes.

Yeah, I made go vet and go lint Jenkins build status checks on all PRs. Also, there's one guy at the company who doesn't use goimports consistently and I will probably have to kill him.

I love the tooling in go.

Mao Zedong Thot
Oct 16, 2008


.............

Mao Zedong Thot fucked around with this message at 17:56 on Jun 27, 2017

Furism
Feb 21, 2006

Live long and headbang
Is there a really good book about learning Go?

overeager overeater
Oct 16, 2011

"The cosmonauts were transfixed with wonderment as the sun set - over the Earth - there lucklessly, untethered Comrade Todd on fire."



The Go Programming Language

Coffee Mugshot
Jun 26, 2010

by Lowtax

Furism posted:

Is there a really good book about learning Go?

Brian Kerrigan and Alan Donovan's book is really good, but speaking, personally, from the Go Team's perspective, we'd still prefer the tour to be the landing page for learning Go rather than the spectacular book. If only because it will be easier to add a section on type aliases there than to print another rev of the book. Also, I think a casual look over the language spec is a good learning tool.

Furism
Feb 21, 2006

Live long and headbang
Thanks for the tips. Going over the specs and doing the tour will definitively be a part of my self-learning. But I found that, for me anyway, you just can't beat the quality of a really good book :)

Twerk from Home
Jan 17, 2009

This avatar brought to you by the 'save our dead gay forums' foundation.
The impression that I get about Go is that it's excellent at concurrency and bad at parallelism, somewhat like a strongly-typed NodeJS. Am I wrong? I've been looking for a chance to do some real work using Golang but the project I'm about to start has a serious need for parallel computation so I'm thinking I'll just try C# on .NET Core or Kotlin.

Coffee Mugshot
Jun 26, 2010

by Lowtax

Twerk from Home posted:

The impression that I get about Go is that it's excellent at concurrency and bad at parallelism, somewhat like a strongly-typed NodeJS. Am I wrong? I've been looking for a chance to do some real work using Golang but the project I'm about to start has a serious need for parallel computation so I'm thinking I'll just try C# on .NET Core or Kotlin.

I'm not sure if Go is particularly bad at parallelism, but the language is designed around concurrency. You would probably find it easy to write "natural code" that can take advantage of parallelism in Go, but I don't know about anything similar to OpenMP targeted particularly at parallelism. C# and Kotlin seem pretty good for parallel computation with all of the primitives they provide.

skul-gun
Dec 24, 2001
I got this account for Xmas.

Twerk from Home posted:

The impression that I get about Go is that it's excellent at concurrency and bad at parallelism, somewhat like a strongly-typed NodeJS. Am I wrong? I've been looking for a chance to do some real work using Golang but the project I'm about to start has a serious need for parallel computation so I'm thinking I'll just try C# on .NET Core or Kotlin.

I guess that depends on how you mean "bad at parallelism." Go programs aren't stuck to being single-threaded as with node. There is a setting (GOMAXPROCS) that controls how many OS threads can be used to execute goroutines. GOMAXPROCS used to default to 1, but now defaults to the logical number of CPUs.

But if you're looking for built-in utilities like java.util.concurrent, no, go doesn't have those.

I hope that helps.

Twerk from Home
Jan 17, 2009

This avatar brought to you by the 'save our dead gay forums' foundation.

skul-gun posted:

I guess that depends on how you mean "bad at parallelism." Go programs aren't stuck to being single-threaded as with node. There is a setting (GOMAXPROCS) that controls how many OS threads can be used to execute goroutines. GOMAXPROCS used to default to 1, but now defaults to the logical number of CPUs.

But if you're looking for built-in utilities like java.util.concurrent, no, go doesn't have those.

I hope that helps.

Well, thanks for opening my eyes guys. I had found some older documentation that indicated that GOMAXPROCS defaulted to 1 and best practice was to leave it there. I'm certainly more familiar with multithreaded C# / Java and using Goldman Sachs Collections from Kotlin looked like a simple solution, but I'm going to take a look at Go before I write it off.

Eela6
May 25, 2007
Shredded Hen
It depends on what you're trying to do with the parallelism. Generally speaking heavy parallelism comes up most in numerics, which for which go is a bad choice of language.

On the other hand if you've just got some work you'd like to spread across multiple processors that's easy enough to do with go. I'm not the biggest fan of go but I find it's concurrency model better than most.

Eela6 fucked around with this message at 18:08 on Jun 30, 2017

Khorne
May 1, 2002

Twerk from Home posted:

Well, thanks for opening my eyes guys. I had found some older documentation that indicated that GOMAXPROCS defaulted to 1 and best practice was to leave it there. I'm certainly more familiar with multithreaded C# / Java and using Goldman Sachs Collections from Kotlin looked like a simple solution, but I'm going to take a look at Go before I write it off.
That's too old. Around Go 1.5 it improved dramatically to the point where on program startup GOMAXPROCS is set to the number of processors your computer tells Go it has.

I've done some AI stuff in Go for fun and the parallelism is respectable. I've mostly only done parallel stuff in C/C++ without boost/openmp/anything and OpenCL/CUDA so I don't know what fluff other languages bolt on. If you are just looking for it to run in parallel with decent performance Go can deliver. If you're looking for it to simplify the process greatly, Go's language features don't vanish but there's nothing beyond that. Which is honestly fine for lots of applications.

Khorne fucked around with this message at 02:46 on Jul 2, 2017

Furism
Feb 21, 2006

Live long and headbang
I finally have some time and a project idea to learn Go. I want to make a True Random Number Generator by reading raw files from a webcam aimed at a nearby tree. I figure I could diff images, hash that, etc.. This probably exists already but oh well.

Any pointers, word of advice, or should I just head into it? I'm not a very good developer, programming is more of a hobby and I'm only average in C#.

Eela6
May 25, 2007
Shredded Hen

Furism posted:

I finally have some time and a project idea to learn Go. I want to make a True Random Number Generator by reading raw files from a webcam aimed at a nearby tree. I figure I could diff images, hash that, etc.. This probably exists already but oh well.

Any pointers, word of advice, or should I just head into it? I'm not a very good developer, programming is more of a hobby and I'm only average in C#.

Go is a bad language for numerics. That said, it's as good a project as any to learn Go with; if it's what you want to do, go for it.

Furism
Feb 21, 2006

Live long and headbang

Eela6 posted:

Go is a bad language for numerics. That said, it's as good a project as any to learn Go with; if it's what you want to do, go for it.

Well honestly the other contender is Rust, but it seemed exceedingly complicated for an amateur like myself. Go is easy, I've been told.

Coffee Mugshot
Jun 26, 2010

by Lowtax
Go and Rust are fine for making some amateur TRNG. Try it out and report back.

Eela6
May 25, 2007
Shredded Hen

Furism posted:

Well honestly the other contender is Rust, but it seemed exceedingly complicated for an amateur like myself. Go is easy, I've been told.

Go is probably the easiest C-family language to pick up. If you want to pick up another statically typed, compiled language, Go is a good choice. Go's biggest advantages are easy compilation to native machine code, better-than-usual concurrency model, and a programming model focused on simplicity: it's lightweight syntax, lack of exceptions, & extremely rigid typing help enforce that what 'what you see is what you get'.

Go's biggest disadvantages are it's lack of generics, it's limited syntax, it's almost complete lack of syntactic sugar, and it's incredibly anemic handling of numerics (the math standard library is almost a joke).

As such, Go tends to excel in highly-concurrent, 'simple' backend work that needs to be deployed across many different environments. It tends to be weakest in scientific & mathematical computing.

Coffee Mugshot posted:

Go and Rust are fine for making some amateur TRNG. Try it out and report back.

:agreed:

Furism
Feb 21, 2006

Live long and headbang
Thanks for the feedback guys. I'll stick to Go then :)

Walked
Apr 14, 2003

So I've been using go a lot lately for toolmaking and it's been pretty great for that.

I've been using VS Code and it's been pretty good, but want to be sure I'm not missing a better Dev environment for go.

Is anything else going to do better than VS Code + plugins?

Eela6
May 25, 2007
Shredded Hen

Walked posted:

So I've been using go a lot lately for toolmaking and it's been pretty great for that.

I've been using VS Code and it's been pretty good, but want to be sure I'm not missing a better Dev environment for go.

Is anything else going to do better than VS Code + plugins?

My coworkers and I are split pretty evenly between vscode, atom, and gogland.

VsCode is my personal favorite of the three, at least for now. I find gogland to be a little slow and buggy for now, though it seems to be rapidly improving.

chutwig
May 28, 2001

BURLAP SATCHEL OF CRACKERJACKS

I've been using Gogland (really the Go plugin in IntelliJ) a lot to write code for inclusion in Kubernetes. My main gripes are:
  • the import autocomplete is really aggressive and any attempts to refactor the import list are met with derision by the IDE as it repeatedly attempts to put back the thing I cut to the clipboard half a second prior
  • Go To functionality is pretty limited still and the terminology remains Java-specific, and it was rarely if ever able to locate the interface that something was implementing
  • tangential to the above point, it loves to complain that thing X can't be used somewhere but never explains why (unlike the compiler which clearly says what you didn't implement), which sends me on an endless adventure of finding the interface in question
  • it was completely unable to handle custom GOPATHs and after fighting it for hours I moved my project under ~/go/src/k8s.io/kubernetes to get it to stop whining about unresolved imports
  • every once in a while my project would poo poo the bed out of the blue and stop showing any project files, but that just seems to be jetbrains.txt
Despite those gripes, I'm glad I have it available, because I would've completely lost my poo poo trying to do anything meaningful in a repo as large and gnarly as Kube's in BBEdit or Vim or whatever.

Eela6
May 25, 2007
Shredded Hen
I'm working with an API that serves JSON in response to GET requests. Great!

The problem is, it represents true as "T" and false as "N".
Go code:
type Restaraunt struct {
	ID        string   `json:"id,omitempty"`
	FoodTypes []string `json:"food_types,omitempty"`
	IsOrganic bool     `json:"is_organic,omitempty"`
}
JavaScript code:
{
    "id": "saddfae09ru234"
    "food_types": ["japanese", "sushi"]
    "is_organic": "N",
}
Is there some way to easily unmarshal these strings into boolean values? Ideally, I would also be able to unmarshal true, false, and nil/empty to the appropriate values.

The logic I want is basically this, but I'm not so good with the json package
Go code:
func booleanVal(b []byte) (val bool, ok bool) {
	switch string(b) {
	case "true", "Y":
		return true, true
	case "false", "N", "":
		return false, true
	default:
		return false, false
	}
}

bonds0097
Oct 23, 2010

I would cry but I don't think I can spare the moisture.
Pillbug
You want to write your own MarshalJSON and UnmarshalJSON functions to implement the Marshaler and Unmarshaler interfaces. This blog post is ok: http://choly.ca/post/go-json-marshalling/

Otherwise, just read the json package and how they implemented marshal/unmarshal, you're basically gonna modify that.

Ghost of Reagan Past
Oct 7, 2003

rock and roll fun
I'm writing a lovely, bare-bones NES emulator for shits and giggles. What's a good library for graphics for someone who doesn't do graphics?

EDIT: Basically I'd just like the ability to draw pixels on a screen. I don't need much, but I also don't know exactly what I need, and I don't work with graphics at all professionally. I ALSO don't really know Go and I'm using this as a way to learn some.

EDIT #2: As a Python programmer I want to scream at some of this. Why is there no 'in' operator? Why does writing a for each loop require extra syntax? Why is gofmt such a dick? Give me the gun to shoot my own face off, please, I'm a competent programmer, I swear.

Ghost of Reagan Past fucked around with this message at 05:02 on Dec 22, 2017

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

Ghost of Reagan Past posted:

I'm writing a lovely, bare-bones NES emulator for shits and giggles. What's a good library for graphics for someone who doesn't do graphics?

EDIT: Basically I'd just like the ability to draw pixels on a screen. I don't need much, but I also don't know exactly what I need, and I don't work with graphics at all professionally. I ALSO don't really know Go and I'm using this as a way to learn some.

EDIT #2: As a Python programmer I want to scream at some of this. Why is there no 'in' operator? Why does writing a for each loop require extra syntax? Why is gofmt such a dick? Give me the gun to shoot my own face off, please, I'm a competent programmer, I swear.

I honestly wouldn't use go for this. Go is great for keeping poo poo simple but if you want to abstract over anything, go use a language with actual features.

Ghost of Reagan Past
Oct 7, 2003

rock and roll fun

MALE SHOEGAZE posted:

I honestly wouldn't use go for this. Go is great for keeping poo poo simple but if you want to abstract over anything, go use a language with actual features.
There's a reason I'm picking Go, and it's because I do need to know it professionally. I wrote a Chip-8 emulator in Rust a while back so I thought I'd step up to a real lovely NES emulator because that was a fun project. Might as well learn doing something I find enjoyable. I mean I could write some database driver or a web service but where's the fun in that?

Adbot
ADBOT LOVES YOU

minato
Jun 7, 2004

cutty cain't hang, say 7-up.
Taco Defender
Go's strengths are in system programming; writing simple servers and file processors. There's very little support for anything GUI, sound, or realtime like you'd want for an emulator. Anything like that you'd probably have to write in C and link in to Go, defeating the purpose of the exercise.

I'd at least try something a little less ambitious first just to get a feel for the language. A URL-shortener is a good example. It's a server, needs a simple UI, some minor config, and needs to talk to either a SQL or key/value storage engine. So you'd learn about:
- the net/http package for the server
- html/template for rendering web pages
- optionally gRPC if you want to offer a programmatic API
- reading and parsing config files
- Google's flags package for handling CLI flags
- The SQL interface + sqlite3 for a backend storage engine, or boltdb if you want to use a durable key/value store.

And the program itself is relatively straightforward to write.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply