diff --git a/go.mod b/go.mod index 46ce3ad..db36fa2 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module player-protocol +module github.com/tgdrive/player-protocol go 1.22.0 diff --git a/main.go b/main.go index fb916ba..9d8c138 100644 --- a/main.go +++ b/main.go @@ -1,4 +1,3 @@ -// main.go package main import ( @@ -7,6 +6,8 @@ import ( "os" "os/exec" "strings" + + player_path "github.com/tgdrive/player-protocol/pkg/path" ) func main() { @@ -46,7 +47,7 @@ func main() { link, _ = url.QueryUnescape(link) } - playerPath, err := findPlayerPath(player) + playerPath, err := player_path.FindPlayerPath(player) if err != nil { fmt.Printf("Error finding %s path: %v\n", player, err) os.Exit(1) diff --git a/linux.go b/pkg/path/path_unix.go similarity index 85% rename from linux.go rename to pkg/path/path_unix.go index 5005349..9822d55 100644 --- a/linux.go +++ b/pkg/path/path_unix.go @@ -1,7 +1,6 @@ //go:build linux -// +build linux -package main +package path import ( "fmt" @@ -9,7 +8,7 @@ import ( "path/filepath" ) -func findPlayerPath(player string) (string, error) { +func FindPlayerPath(player string) (string, error) { if player == "potplayer" { return "", fmt.Errorf("PotPlayer is not supported on Linux") } diff --git a/windows.go b/pkg/path/path_windows.go similarity index 94% rename from windows.go rename to pkg/path/path_windows.go index 4f4d5b5..2bd2145 100644 --- a/windows.go +++ b/pkg/path/path_windows.go @@ -1,7 +1,6 @@ //go:build windows -// +build windows -package main +package path import ( "fmt" @@ -11,7 +10,7 @@ import ( "golang.org/x/sys/windows/registry" ) -func findPlayerPath(player string) (string, error) { +func FindPlayerPath(player string) (string, error) { path, err := findPathInRegistry(player) if err == nil { return path, nil