func main() {
	if len(os.Args) != 2 {
		log.Fatalf("usage: %s [SWID file]\n", os.Args[0])
	}

	xmlFile := os.Args[1]

	xml, err := ioutil.ReadFile(xmlFile)
	if err != nil {
		log.Fatal(err)
	}

	var tag swid.SoftwareIdentity

	err = tag.FromXML(xml)
	if err != nil {
		log.Fatalf("reading SWID from %s: %v", xmlFile, err)
	}

	cbor, err := tag.ToCBOR()
	if err != nil {
		log.Fatal(err)
	}

	if saveCBORFile {
		cborFile := strings.TrimSuffix(xmlFile, filepath.Ext(xmlFile)) + ".cbor"

		err := ioutil.WriteFile(cborFile, cbor, 0644)
		if err != nil {
			log.Fatal(err)
		}
	}

	delta := percentDelta(len(xml), len(cbor))

	log.Printf("Delta XML->CBOR: %f%% [%s]", delta, xmlFile)
}
// IN: a swid.xml file
// OUT: CoSWID compression factor
a swid.xml file
OUT: CoSWID compression factor
// IN : a swid . xml file // OUT : CoSWID compression factor
func main() {
	if len(os.Args) != 2 {
		log.Fatalf("usage: %s [SWID file]\n", os.Args[0])
	}
	xmlFile := os.Args[1]
	xml, err := ioutil.ReadFile(xmlFile)
	if err != nil {
		log.Fatal(err)
	}
	var tag swid.SoftwareIdentity
	err = tag.FromXML(xml)
	if err != nil {
		log.Fatalf("reading SWID from %s: %v", xmlFile, err)
	}
	cbor, err := tag.ToCBOR()
	if err != nil {
		log.Fatal(err)
	}
	if saveCBORFile {
		cborFile := strings.TrimSuffix(xmlFile, filepath.Ext(xmlFile)) + ".cbor"
		err := ioutil.WriteFile(cborFile, cbor, 0644)
		if err != nil {
			log.Fatal(err)
		}
	}
	delta := percentDelta(len(xml), len(cbor))
	log.Printf("Delta XML->CBOR: %f%% [%s]", delta, xmlFile)
}
func main ( ) { if len ( os . Args ) != 2 { log . Fatalf ( " \n " , os . Args [ 0 ] ) } xmlFile := os . Args [ 1 ] xml , err := ioutil . ReadFile ( xmlFile ) if err != nil { log . Fatal ( err ) } var tag swid . SoftwareIdentity err = tag . FromXML ( xml ) if err != nil { log . Fatalf ( " " , xmlFile , err ) } cbor , err := tag . ToCBOR ( ) if err != nil { log . Fatal ( err ) } if saveCBORFile { cborFile := strings . TrimSuffix ( xmlFile , filepath . Ext ( xmlFile ) ) + " " err := ioutil . WriteFile ( cborFile , cbor , 0644 ) if err != nil { log . Fatal ( err ) } } delta := percentDelta ( len ( xml ) , len ( cbor ) ) log . Printf ( " " , delta , xmlFile ) }
a swid.xml file
OUT: CoSWID compression factor
a swid . xml file OUT : CoSWID compression factor