[go-nuts] Announcing Carotid Artillery, a twin-stick shooter created using ebiten

2021-11-03 Thread Trevor Slocum
Carotid Artillery was created during the 2021 Vampire Themed Game Jam. It is playable in the browser and on Linux and Windows. Code: https://code.rocketnine.space/tslocum/carotidartillery Play: https://itch.io/jam/vampire-themed-game-jam-october-2021/rate/1226993 -- You received this message b

[go-nuts] cgo error I don't understand

2021-11-03 Thread Robert Solomon
I'm setting up a new Windows10 computer. I installed Go 1.17.2 and mingw64 for cgo. When I tried to compile a project that uses cgo, I got this error: cgo: exec gcc: gcc resolves to executable relative to current directory (.\\msys64\mingw64\bin\gcc.exe) This is a program that compiles fine

Re: [go-nuts] How GC trace stack objects

2021-11-03 Thread Ian Lance Taylor
On Wed, Nov 3, 2021 at 8:56 AM Ge wrote: > > Hi, recently I was trying to figure out how GC marks stack objects and found > some places of the implementation detail over my head. > > source: > ``` > package main > > import "runtime" > > func main() { > x := make([]byte, 256*1024*1024) > ru

Re: [go-nuts] Anyway to wrap or tweak a test file before running go test?

2021-11-03 Thread 'Axel Wagner' via golang-nuts
On Wed, Nov 3, 2021 at 10:44 PM Matt Mueller wrote: > Hey, thanks. I'm aware of this approach. > > I'm hoping for some technique that automatically injects, since it can be > cumbersome to inject all your dependencies by hand. > I don't understand what you mean. Obviously, how to connect to a da

Re: [go-nuts] Anyway to wrap or tweak a test file before running go test?

2021-11-03 Thread Matt Mueller
Hey, thanks. I'm aware of this approach. I'm hoping for some technique that automatically injects, since it can be cumbersome to inject all your dependencies by hand. Similar to google/wire, but without the generated file sitting in the filesystem next to your test. Matt On Wednesday, Nove

Re: [go-nuts] Anyway to wrap or tweak a test file before running go test?

2021-11-03 Thread ben...@gmail.com
> func connectToDB(t *testing.T) *postgres.DB { > t.Helper() > // set up the connection, using t.Fatalf if an error occurs > return conn > } > > func UserTest(t *testing.T) { > db := connectToDB(t) > } > Yeah, that's a good way. And if you want to avoid re-connecting to the db e

Re: [go-nuts] Anyway to wrap or tweak a test file before running go test?

2021-11-03 Thread 'Axel Wagner' via golang-nuts
I tend to do this using a helper, such as func connectToDB(t *testing.T) *postgres.DB { t.Helper() // set up the connection, using t.Fatalf if an error occurs return conn } func UserTest(t *testing.T) { db := connectToDB(t) } This doesn't seem significantly worse in terms of conv

[go-nuts] Re: Go on AWS Lambda?

2021-11-03 Thread Matt Mueller
I'd say you pay a bit less for the memory you consume. Generally it runs faster than the more common JS or Python serverless functions, so you also pay less there. I'd argue the main reason to use Go on Serverless is because you'd like to deploy to a Serverless environment and you prefer writin

[go-nuts] Anyway to wrap or tweak a test file before running go test?

2021-11-03 Thread Matt Mueller
I'm looking for a way to inject test dependencies into a test suite. Something like: ``` package user_test func UserTest(t *testing.T, db *postgres.DB) { fmt.Println("running user test", New("Alice Wonderland")) } ``` ``` go_test ./user_test.go ``` Where go_test would either manipulate the f

[go-nuts] How GC trace stack objects

2021-11-03 Thread Ge
Hi, recently I was trying to figure out how GC marks stack objects and found some places of the implementation detail over my head. source: ``` package main import "runtime" func main() { x := make([]byte, 256*1024*1024) runtime.GC() ←t1 x[0] = 2 runtime.GC()←t2

[go-nuts] Average of two integers

2021-11-03 Thread jfcg...@gmail.com
Hi, I thought averaging strings was the non-trivial case. I knew (x+y)/2 for averaging integers would have overflow problems and not work for all inputs. It turns out there is a short but non-trivial expression for averaging signed/unsigned integers for 'all' inputs. I've also added Mean*() fo

[go-nuts] Re: List embedded dependencies in a Go binary

2021-11-03 Thread jfcg...@gmail.com
try "go version -m" On Tuesday, November 2, 2021 at 8:18:15 PM UTC+3 Michel Casabianca wrote: > Hi gophers, > > I would like to know which dependencies are embedded in generated Go > binary, along with their version. I though at first that they were listed > in *go.sum* file, but it seems that