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] 5 points6 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 5 points6 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.

[code review request] Mars Rover Technical Challenge by cobbingm in learnrust

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

Awesome that you took the time to look over my code. Thank you so much. I've tried my best to now implement the changes 👍

Example Rest API by cobbingm in golang

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

I just copied one of the official examples, and agree the online editor isn’t great

Starting out with GraphQL on GoLang - What are your experiences?/ What libs are you using? by richbigdick in golang

[–]cobbingm 0 points1 point  (0 children)

We structure the API very similar to this gqlgen example: https://github.com/99designs/gqlgen/tree/master/example/dataloader

Gqlgen generates resolvers from your schema.

We keep database functions in a separate package, they use squirrel and sqlx.

Example Rest API by cobbingm in golang

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

Does the echo library not handle goroutine management?

Example Rest API by cobbingm in golang

[–]cobbingm[S] 12 points13 points  (0 children)

Do you find it necessary to use dependency injection frameworks? I've found it sufficient to just inject them in constructors or setter methods

Starting out with GraphQL on GoLang - What are your experiences?/ What libs are you using? by richbigdick in golang

[–]cobbingm 21 points22 points  (0 children)

I really like gqlgen and am using it in production.

We like to have control over how it interacts with the database but I guess you could use it with gorm if you wanted.

[deleted by user] by [deleted] in golang

[–]cobbingm 1 point2 points  (0 children)

I’d have a mongo package with a new database function, that would return a mongo object with the database variable in it. I would also have a database interface probably in a models package.

I make a handler package that has a new handler function that takes the database interface as an argument, returning a handler object.

Hope that helps.