github.com/goplus/llgo@v0.8.3/chore/ardump/ardump.go (about) 1 /* 2 * Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package main 18 19 import ( 20 "fmt" 21 "io" 22 "log" 23 "os" 24 25 "github.com/goplus/llgo/xtool/ar" 26 ) 27 28 func main() { 29 if len(os.Args) != 2 { 30 fmt.Fprintln(os.Stderr, "Usage: ardump xxx.a") 31 return 32 } 33 34 f, err := os.Open(os.Args[1]) 35 check(err) 36 defer f.Close() 37 38 r, err := ar.NewReader(f) 39 check(err) 40 for { 41 hdr, err := r.Next() 42 if err != nil { 43 if err != io.EOF { 44 log.Println(err) 45 } 46 break 47 } 48 fmt.Println(hdr.Name) 49 } 50 } 51 52 func check(err error) { 53 if err != nil { 54 panic(err) 55 } 56 }