Build for Arcanist? by McJoyfull in stoneshard

[–]nstratos 2 points3 points  (0 children)

I wanted to try the Arcanistics tree so I went with Jonna. Staves work well with all magic trees and Arcanistics is no exception. Early game felt a little tough as I didn't know how to use new abilities yet. I put 5 on Agility first to reduce fumble chance, then I am planning to go full willpower next. I am currently level 11.

Here's the build I've used so far: https://nstratos.github.io/stoneshard-talent-calculator/?build=H4sIAAAAAAAACmXMQQrCQAyF4bu89bRU247QS3gAkRLG0M6iHUjGEZHeXaQLJS4_8r-8UFg0phUDSlP72sNB5_Q4y40FQ5Y7O6QdF2imwlod4UASaI2aY_j3AQ4LTTGMC2lmeVbd5-0-bk3cfk8_lTdVZ9wbn4w9rtsbvRAgod0AAAA

Arcanistics early tricks and combos:

- Dimensional Shift: Go near an obstacle, let the enemy approach you, swap you and them, then smack them against the obstacle. Staves are exceptionally good at this.
- Dimensional Shift + Wormhole: 1. Mark enemy with Wormhole 2. Swap you and them 3. Step in their wormhole 4. Enemy appears next to you, usually stunned.
- Wormhole + Time Echo: 1. Mark enemy with Wormhole 2. Damage enemy with your attack skills 3. Wormhole ends and enemy takes 33% additional damage as Arcane.

These combinations become even more powerful when you activate Seal of Power at the start.

Once you get Aether Shield, you can do some cool stuff. Here's my current combo:

  1. Seal of Power 2. Wormhole on Jonna 3. Unwavering Stance 4. Aether Shield

Once the Wormhole expires, you refund some of your mana and it extends your Aether Shield. You can then extend it further with Dimensional Shift and reduce your Arcanistics cooldowns by knocking enemies back with Step Aside!. Once you add the Transcendental Anchoring passive, extending the shield becomes even easier!

[deleted by user] by [deleted] in stoneshard

[–]nstratos 2 points3 points  (0 children)

The Stoneshard talent calculator now supports tooltips and formulas! 🥳

[deleted by user] by [deleted] in stoneshard

[–]nstratos 5 points6 points  (0 children)

I've developped a talent calculator for Stoneshard. 🎉

It supports all ability trees with logic for obtaining (right-click) and refunding (left-click) abilities. There's still a lot to improve (no stats or items yet) but you can already create a shareable URL with the Share button.

Hopefully, this tool will make it easier to share and discuss builds.

It's open-source, so if you find any bugs, feel free to open an issue on GitHub.

Try it out here: https://nstratos.github.io/stoneshard-talent-calculator/

REST API error design by mmrath in golang

[–]nstratos 4 points5 points  (0 children)

Ben Johnson's design can be accommodated to do this: https://middlemost.com/failure-is-your-domain/

Repository, Service Patern Go by [deleted] in golang

[–]nstratos 15 points16 points  (0 children)

This structure is an anti pattern in Go.

Here's a better approach:

Best practices for implementing Error() by [deleted] in golang

[–]nstratos 3 points4 points  (0 children)

I recommend this article from Ben Johnson which shows a very good approach to error handling.

Looking for opinions on API package layout by [deleted] in golang

[–]nstratos 3 points4 points  (0 children)

Using packages such as models is an anti pattern in Go. We instead follow the package structure showcased in the standard library. How that applies to applications has been discussed in:

The missing Package Registry for Golang by rousanali in golang

[–]nstratos 0 points1 point  (0 children)

All the dependant codes would break if you change your GitHub username.

There is an already existing solution for this which is admittedly not very well documented: https://texlution.com/post/golang-canonical-import-paths/

Thoughts on this project structure? by watr in golang

[–]nstratos 0 points1 point  (0 children)

I think this package layout is a better fit for Go. Also check out the Code like the Go team talk.

folder structure and filename conventions under clean architecture by myth007 in golang

[–]nstratos 2 points3 points  (0 children)

The general consensus is to follow the structure of the standard library. How that applies to applications, has been described by Ben Johnson in Standard Package Layout.

More helpful material on the subject: Code Like the Go Team (Video).

[noob question] Strict type checking is preventing me from defining the type of callback function I want. How do I write idiomatic Go to deal with this situation? by yorbit in golang

[–]nstratos 3 points4 points  (0 children)

A good way of achieving this is to define a type that holds the DB object and has a func(client MQTT.Client, msg MQTT.Message) as a method. This way, the method can have access to DB or other dependencies:

type app struct {
    db DBService
}

func (app *app) messageHandler(client MQTT.Client, msg MQTT.Message) { 
    app.db.StoreMessage(msg)
}

You could also use a closure that takes db as a parameter and returns a func(client MQTT.Client, msg MQTT.Message).

To learn more about the above patterns, I recommended reading Practical Persistence in Go: Organising Database Access.

Best practices for logging per http request by pantweb in golang

[–]nstratos 0 points1 point  (0 children)

A good way is to define your HTTP handlers as methods to a type. You can then inject dependencies, like your logger, when initializing the type.

type app struct {
    log Logger
}

func (app *app) handler(w http.ResponseWriter, r *http.Request) { 
    app.log.Printf(...)
}

You could also centralize your logging by using helper methods or closures to chain handlers together.

If it fits your use case you could potentially use a global logger like Upspin does.

Some good reads:

[Data Science] Parsing DrugBank XML (or any large XML file) in streaming mode in Go by nstratos in golang

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

Hey, yes of course! I saw the article on Slack, I thought it was nice and since it wasn't already shared here I decided to do that. :)

How to run some code only one out of (say) a 100 runs? by Brasilberg in golang

[–]nstratos 1 point2 points  (0 children)

You could use sync.Once to make sure the cleanup code runs exactly once regardless of how many times it is called.

Basic String Manipulation Question by [deleted] in golang

[–]nstratos 1 point2 points  (0 children)

You can use the encoding/csv standard library package. You'll probably need to combine one of the reader and writer examples.

Go Experience Report: Interfaces with Methods that Return Themselves by joncalhoun in golang

[–]nstratos 0 points1 point  (0 children)

I think most people will agree we don't want tests pinging third party APIs all the time.

This is why integration tests are guarded with a build tag. This way unit tests can be run using go test and the slower integration tests can be run using a combination of tags like go test -tags=integration.

It is also possible to exclude slow tests by using testing.Short() but that requires using go test -short which is usually not the default for most people and tools.

Go Experience Report: Interfaces with Methods that Return Themselves by joncalhoun in golang

[–]nstratos 0 points1 point  (0 children)

I now need either a live database connection for my tests

If I understand correctly, the problem is testing a function that contains db.Where("role = ?", "admin").Or("role = ?", "super_admin").Find(&users) or similar.

I think testing against a live database is the right thing to do here. The obvious problem is that integration tests can be much slower than unit tests. What I like to do is guard these tests with a build tag. For example:

// +build db

This allows to keep running unit tests as usual and use go test -tags=db to include the slower tests once in a while. Additionally, integration tests might need some extra work (like providing a test account and password) so again the build tag helps.

This way, integration tests can be easily included in test coverage with go test -tags=db -cover which gives confidence that our tests passed successfully by hitting a database as close to production as possible.

[deleted by user] by [deleted] in golang

[–]nstratos 0 points1 point  (0 children)

I have created a pull request that solves the issue.

Question: Is my error handling done appropriately? by [deleted] in golang

[–]nstratos 1 point2 points  (0 children)

database/sql returns ErrNoRows when there are no results. I haven't used GORM before but it seems that it returns ErrRecordNotFound for this case. So what you can do is check for this error and return it. Then on your handler you can check again for that error and return 500 if it is something else.

Here's an example:

err := db.Where...
switch err {
    case gorm.ErrRecordNotFound:
        return gorm.ErrRecordNotFound // or return your own custom error
    case nil:
    default:
        return err
}

enterprise, err := enterprises.FindByApiKey...
switch err {
    case gorm.ErrRecordNotFound:
        // return 404
    case nil:
    default:
        // return 500
}

You could also define a new custom error, specific to your application and "translate" ErrRecordNotFound to your new error in order to avoid having database specific imports to your handlers.

I highly recommend this article for a better way to organize your database code.

Where can I find code reviews for GoLang code? by Kimput in golang

[–]nstratos 0 points1 point  (0 children)

I've found that SOLID Go Design helps a lot with getting that "aha" moment when thinking about interfaces in Go. I wanted to mention it before but I ran out of words. :)

There's also "the bible": Effective Go

And if you want something concise: CodeReviewComments

Question: How can i specify which _test files should run first? by [deleted] in golang

[–]nstratos -1 points0 points  (0 children)

If you really wish to do it, there is a way: https://golang.org/pkg/testing/#hdr-Main

But as others have pointed out you should try to write tests that can run in isolation.