We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
` package main
import ( "encoding/json" "fmt" "io/ioutil" "net/http" "os" "path/filepath" "strings" )
type Dependency struct { ModulePath string json:"module_path" Version string json:"version" }
json:"module_path"
json:"version"
func main() { if len(os.Args) != 2 { fmt.Println("Usage: go run main.go ") os.Exit(1) }
repo := os.Args[1] // Determine the module path based on the repository URL. modulePath := strings.TrimSuffix(repo, ".git") modulePath = strings.TrimPrefix(modulePath, "https://github.com/") modulePath = strings.ReplaceAll(modulePath, "/", "%2F") // Download the go.mod file. goModUrl := fmt.Sprintf("https://raw.githubusercontent.com/%s/main/go.mod", repo) resp, err := http.Get(goModUrl) if err != nil { fmt.Println("Error downloading go.mod:", err) os.Exit(1) } defer resp.Body.Close() // Read the contents of the go.mod file. body, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println("Error reading go.mod:", err) os.Exit(1) } // Parse the contents of the go.mod file. dependencies := make([]Dependency, 0) for _, line := range strings.Split(string(body), "\n") { if strings.HasPrefix(line, "require ") { parts := strings.Split(line[8:], " ") modulePath := parts[0] version := parts[1] dependencies = append(dependencies, Dependency{ModulePath: modulePath, Version: version}) } } // Print the dependencies. fmt.Println(dependencies)
} `
The text was updated successfully, but these errors were encountered:
No branches or pull requests
`
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os"
"path/filepath"
"strings"
)
type Dependency struct {
ModulePath string
json:"module_path"
Version string
json:"version"
}
func main() {
if len(os.Args) != 2 {
fmt.Println("Usage: go run main.go ")
os.Exit(1)
}
}
`
The text was updated successfully, but these errors were encountered: