Created
July 31, 2020 08:43
-
-
Save skanehira/df914c386aa4f6918a1c3ef6134a2a3b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"os" | |
) | |
func main() { | |
if len(os.Args) < 2 { | |
return | |
} | |
name := os.Args[1] | |
f, err := os.Open(name) | |
if err != nil { | |
log.Fatal(err) | |
} | |
var b [2]byte | |
if _, err := f.Read(b[:]); err != nil { | |
log.Fatal(err) | |
} | |
if string(b[:]) == "PK" { | |
println("is zip") | |
} else { | |
println("not zip") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment