Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need better handling for arrays #79

Closed
d-enk opened this issue May 13, 2024 · 0 comments · Fixed by samber/go-type-to-string#5
Closed

Need better handling for arrays #79

d-enk opened this issue May 13, 2024 · 0 comments · Fixed by samber/go-type-to-string#5
Milestone

Comments

@d-enk
Copy link

d-enk commented May 13, 2024

package main

import (
	"fmt"

	"github.com/samber/do/v2"
	typeStr "github.com/samber/go-type-to-string" // v1.3.0
)

func main() {
	i := do.New()

	fmt.Println(typeStr.GetType[[1]int]()) // []int
	fmt.Println(do.NameOf[[1]int]())       // []int

	// but
	fmt.Println(reflect.TypeOf([1]int{1}).String()) // [1]int

	do.ProvideValue(i, [1]int{})
	fmt.Println(do.InvokeAs[[3]int](i)) // could not find service satisfying interface `[]int`, available services: `[]int`
	fmt.Println(do.InvokeAs[[]int](i))  // could not find service satisfying interface `[]int`, available services: `[]int`
	fmt.Println(do.InvokeAs[[]int](i))  // could not find service satisfying interface `[]int`, available services: `[]int`

	do.ProvideValue(i, []int{}) // panic: DI: service `[]int` has already been declared
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants