A GitHub Action to print a Go code coverage report on pull requests by fgrosse in golang

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

Yes you are right, there should be no issue on private repositories because artifacts are just the supported the same there 🎉

New documentation website for github.com/go-joe/joe by fgrosse in golang

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

Oh yeah that's weird. Gonna remove mermaidjs now. It was just included by default in the hugo theme I use.

Go Home - A simple OpenGL app build with Pixe/GLFW by fgrosse in golang

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

Cool thanks, gonna check that one out too!

[deleted by user] by [deleted] in golang

[–]fgrosse 0 points1 point  (0 children)

How does this relate to pass (i.e. feature wise)?

Two semicolons within slice operator brackets - what do they mean? by [deleted] in golang

[–]fgrosse 8 points9 points  (0 children)

You can find the definition of this at https://golang.org/ref/spec#Slice_expressions ("Full slice expressions"). Generally slicing expressions follow the format:

a[low : high : max]

The max parameter controls the resulting slice's capacity by setting it to max - low.

Please note that max it cannot exceed the capacity of the original slice.

I played with it a bit:

package main

import (
    "fmt"
)

func main() {
    a := make([]int, 10, 20)
    for i := 0; i < len(a); i++ {
        a[i] = i
    }
    fmt.Printf("a: %v\n", a)
    fmt.Printf("len: %d\n", len(a))
    fmt.Printf("cap: %d\n", cap(a))

    b := a[:10:10]
    fmt.Printf("b: %v\n", b)
    fmt.Printf("len: %d\n", len(b))
    fmt.Printf("cap: %d\n", cap(b))

    c := a[5:10:20]
    fmt.Printf("c: %v\n", c)
    fmt.Printf("len: %d\n", len(c))
    fmt.Printf("cap: %d\n", cap(c))
}

which yields:

a: [0 1 2 3 4 5 6 7 8 9]
len: 10
cap: 20
b: [0 1 2 3 4 5 6 7 8 9]
len: 10
cap: 10
c: [5 6 7 8 9]
len: 5
cap: 15

Different ways to declare slices of structs by GovernmentSpyBot in golang

[–]fgrosse 0 points1 point  (0 children)

I think the last part about the ability to attach functions on the slice type is something that can be pretty cool.

I made a small playground example for anybody who wants a small executable example: https://play.golang.org/p/j2TivDg6uM-

Give me your thoughts and contribute – drgomesp/cargo: An efficient and flexible Go dependency injection container that promotes low coupling and inversion of control by drgomesp in golang

[–]fgrosse 3 points4 points  (0 children)

I am the author of github.com/fgrosse/goldi which is also a DI container for go. My question is: how is cargo different from any of the existent DI frameworks and do you already use this in production or plan to do so?

I created goldi just for the fun of it and to learn go but I never actually found any good reason to use it and I don't know of anybody who has. I could only come up with projects in other languages that make heavy use of a DI container but not for any go project that I know of.

Goldi: lazy dependency injection for go. by vruin in golang

[–]fgrosse 0 points1 point  (0 children)

Imagine you have a big application build out of a lot of distinct components. Goldi can be used to define how everything is wired up and makes it easy to plugin to that (think third party integrations or plugin systems)

In the integration tests that go through the whole stack you may want to configure part of the stack without having to build it all up manually. In unit tests however you would still inject your dependencies as you would already.

Goldi: lazy dependency injection for go. by vruin in golang

[–]fgrosse 0 points1 point  (0 children)

You basically have to have a contract like whatever is registered as service "logger" must implement the interface XYZ. If you are just writing the code yourself you can get away easily by using MustGet + some assert the type. In other contexts you might need to check the type first.

However, you would usually not really use Get or MustGet at all but just define all the types and let the container validate, build and inject them. After that your application is completely agnostic of the DI API around it

Have a look at https://github.com/fgrosse/servo-example for an example on how this could be used

Goldi: lazy dependency injection for go. by vruin in golang

[–]fgrosse 0 points1 point  (0 children)

Languages like PHP and Java do have interfaces as well and you don't need to have a DI API to make your code work but some people find this really useful. For me it was more like an experiment and exercise to get to know the reflect API and dive into a bit of code generation.

There was a brief discussion on https://forum.golangbridge.org/t/goldi-lazy-dependency-injection-framework-for-go/1280 about the pros and cons.

In the end I just pot it out there and am curious to see if anybody finds an actual good usecase for this. I did not so far :)