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

Import Cycle Not Allowed #132

Open
asponzan opened this issue Jan 25, 2024 · 1 comment
Open

Import Cycle Not Allowed #132

asponzan opened this issue Jan 25, 2024 · 1 comment

Comments

@asponzan
Copy link

I'm new to Golang so I may have missed or messed up but I'm recieving a import cycle not allowed error when trying to use this packge with the decode example

Error I'm receiving:

package command-line-arguments
        imports github.com/CycloneDX/cyclonedx-go
        imports github.com/CycloneDX/cyclonedx-go: import cycle not allowed
// main.go
package main

import (
	"fmt"
	"net/http"

	cdx "github.com/CycloneDX/cyclonedx-go"
)

func main() {
	// Acquire a BOM (e.g. by downloading it)
	res, err := http.Get("https://github.com/DependencyTrack/dependency-track/releases/download/4.1.0/bom.json")
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()

	// Decode the BOM
	bom := new(cdx.BOM)
	decoder := cdx.NewBOMDecoder(res.Body, cdx.BOMFileFormatJSON)
	if err = decoder.Decode(bom); err != nil {
		panic(err)
	}

	fmt.Printf("Successfully decoded BOM of %s\n", bom.Metadata.Component.PackageURL)
	fmt.Printf("- Generated: %s with %s\n", bom.Metadata.Timestamp, (*bom.Metadata.Tools.Tools)[0].Name)
	fmt.Printf("- Components: %d\n", len(*bom.Components))

}
//go.mod
module github.com/CycloneDX/cyclonedx-go

go 1.21.6
@jamietanna
Copy link

jamietanna commented Apr 9, 2024

Your go.mod shouldn't be set to github.com/CycloneDX/cyclonedx-go as you want to be able to pull this library from it

I.e rename it to module example or module gitlab.com/path/to/your/repo and try again

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

No branches or pull requests

2 participants