Using a Go Traefik package in custom code

Hello,
Please note that my question is not really about a plugin, I didn't find a more suitable tag.
I'm developing a separate program and I wish to use the pkg/muxer/http package included in the Traefik source code as a library in order to parse routing rules.
Here an example of my use case:

package main

import (
	"fmt"
	httpMuxer "github.com/traefik/traefik/v3/pkg/muxer/http"
)

func main() {
	domains, err := httpMuxer.ParseDomains("Host(`test.com`)")
	if err != nil {
		fmt.Println(err)
		return
	}
	for domain := range domains {
		fmt.Println(domains[domain])
	}
}

Unfortunately I get the following message which as nothing to do with my code:

go run .
# github.com/traefik/traefik/v3/pkg/muxer/http
../../../go/pkg/mod/github.com/traefik/traefik/v3@v3.4.4/pkg/muxer/http/matcher_v2.go:31:28: mux.NewRouter().UseRoutingPath undefined (type *mux.Router has no field or method UseRoutingPath)
../../../go/pkg/mod/github.com/traefik/traefik/v3@v3.4.4/pkg/muxer/http/matcher_v2.go:57:28: mux.NewRouter().UseRoutingPath undefined (type *mux.Router has no field or method UseRoutingPath)
../../../go/pkg/mod/github.com/traefik/traefik/v3@v3.4.4/pkg/muxer/http/mux.go:119:41: undefined: mux.RoutingPathKey
../../../go/pkg/mod/github.com/traefik/traefik/v3@v3.4.4/pkg/muxer/http/mux.go:164:8: undefined: mux.RoutingPathKey

It seems Go is having trouble with dependencies in a weird way. go mod tidy and anything I could find online did not help.
I was able to run my code successfully by downloading the entire Traefik repo, modifying the specific package into a "main" package and adding my custom code.

I do not have experience with Go, I have no idea where to go from this, any ideas ?

Found it: the problem was with the GitHub - gorilla/mux: Package gorilla/mux is a powerful HTTP router and URL matcher for building Go web servers with 🦍 dependency, which is replaced in go.mod by GitHub - containous/mux: A powerful URL router and dispatcher for golang.. I did not specify the replacement.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.