File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -47,21 +47,26 @@ func (lib *Library) ShouldBuild() bool {
4747 return slices .Contains (lib .Platform , runtime .GOOS )
4848}
4949
50+ // archiveExtensions maps file suffixes to canonical archive type names.
51+ var archiveExtensions = map [string ]string {
52+ ".tar.gz" : "tar.gz" ,
53+ ".tgz" : "tar.gz" ,
54+ ".tar.bz2" : "tar.bz2" ,
55+ ".tbz2" : "tar.bz2" ,
56+ ".tar.xz" : "tar.xz" ,
57+ ".txz" : "tar.xz" ,
58+ ".zip" : "zip" ,
59+ }
60+
5061// ArchiveType derives the archive type from the URL
5162func (lib * Library ) ArchiveType () string {
5263 url := strings .ToLower (lib .URL )
53- switch {
54- case strings .HasSuffix (url , ".tar.gz" ), strings .HasSuffix (url , ".tgz" ):
55- return "tar.gz"
56- case strings .HasSuffix (url , ".tar.bz2" ), strings .HasSuffix (url , ".tbz2" ):
57- return "tar.bz2"
58- case strings .HasSuffix (url , ".tar.xz" ), strings .HasSuffix (url , ".txz" ):
59- return "tar.xz"
60- case strings .HasSuffix (url , ".zip" ):
61- return "zip"
62- default :
63- return ""
64+ for ext , archiveType := range archiveExtensions {
65+ if strings .HasSuffix (url , ext ) {
66+ return archiveType
67+ }
6468 }
69+ return ""
6570}
6671
6772// Build performs the complete build process for this library
You can’t perform that action at this time.
0 commit comments