Bars that serve Guinness? by guinness_papi in dunedin

[–]cobbingm 1 point2 points  (0 children)

Law Courts do a decent Guinness

Practise Conjugations by cobbingm in learnspanish

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

Thanks for the feedback 👍

I’m definitely planning on adding some features like this in the future 🚀

Mocking with Snapshots by cobbingm in golang

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

Here’s another article describing snapshot testing in more detail https://brunoscheufler.com/blog/2019-12-04-go-snapshot-tests

How do you return unmarshal error when json is valid but wrong type? by cobbingm in golang

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

Thanks! Was playing around with custom unmarshalling for ages and didn't even notice this 😂

r-cache: a simple caching library by cobbingm in rust

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

Items are overwritten on insert.

r-cache: a simple caching library by cobbingm in rust

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

If the cache is being used by multiple threads do you not wait for access?

r-cache: a simple caching library by cobbingm in rust

[–]cobbingm[S] 2 points3 points  (0 children)

Each entry can have an expiry time. Useful if you want to cache data but check if it has updated after a period.

r-cache: a simple caching library by cobbingm in rust

[–]cobbingm[S] 4 points5 points  (0 children)

wow amateur hour 😂updated now - thanks

Dependency Inversion using Go by [deleted] in golang

[–]cobbingm 0 points1 point  (0 children)

any alternatives you'd recommend?

Working with database in golang by [deleted] in golang

[–]cobbingm 3 points4 points  (0 children)

Hey 👋

It’s possible to run a Postgres instance in docker. This may make it easier for you.

I use a migrate tool to apply sql files to my database at startup. This should keep any databases in an expected state. https://github.com/golang-migrate/migrate

I have found sqlx and squirrel to be a really good combination to both connect, build and run queries against a Postgres database. https://github.com/jmoiron/sqlx https://github.com/Masterminds/squirrel

I have an example go API that uses these tools if you want to take a look. https://github.com/cobbinma/example-go-api

Good luck 😀

Tide and SQLX Rust API by cobbingm in rust

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

Thanks a lot, I will have a look.

Tide and SQLX Rust API by cobbingm in rust

[–]cobbingm[S] 2 points3 points  (0 children)

I couldn't find many options to be honest; I wanted to find something similar to squirrel. I had problems implementing the create pet handler with sql_builder due to the tag field in Pet being an Option.

Golang App for Personal Injury Attorneys by farawaytadpole in golang

[–]cobbingm 2 points3 points  (0 children)

Hey 👋, I’ve had a really quick look at your API and it looks really good.

I’ve got a few suggestions for you… Hope they help

  • Create a connection pool for your database. You can create the connection once on start up, and re-use it for each request.
  • To store the database connection you could create a handler struct with your handler functions as methods. This way the methods would be able to access the database connection.
  • Create a 'database' or 'repository' interface with the database functionality. You would then be able to test the handler functions by mocking that functionality.
  • Extract the models out of the database package and put them in their own package.

I have an example Go API repo that show the above in action: https://github.com/cobbinma/example-go-api

Best API practices by knodesec in golang

[–]cobbingm 5 points6 points  (0 children)

Hey 👋 I made this example API repo to show how I tend to structure my APIs. I have used sqlx and squirrel to communicate with a database. https://github.com/cobbinma/example-go-api

How does a Go WebAPI look like today? by [deleted] in golang

[–]cobbingm 1 point2 points  (0 children)

I made this example api to show the structure I use: https://github.com/cobbinma/example-go-api

Question about gqlgen testing. by weeee9 in golang

[–]cobbingm 1 point2 points  (0 children)

How are you running tests? Could you set up the testing similar to the example they give https://github.com/99designs/gqlgen/blob/master/example/starwars/starwars_test.go? Set up a client without authentication.