-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
45 lines (37 loc) · 892 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package main
import (
"flag"
"fmt"
"io/ioutil"
)
var (
inFile string
outFile string
before int
after int
)
func init() {
flag.StringVar(&inFile, "infile", "", "input file, eg: -infile XXX")
flag.StringVar(&outFile, "outfile", "", "output file, eg: -outfile XXX")
flag.IntVar(&before, "before", 0, "before offset bytes, eg: -before 10")
flag.IntVar(&after, "after", 0, "after offset bytes, eg: -after 10")
}
func main() {
flag.Parse()
inf, err := ioutil.ReadFile(inFile)
if err != nil {
fmt.Println(err)
return
}
bufLen := len(inf)
exBuf := inf[before:(bufLen - after)]
err = ioutil.WriteFile(outFile, exBuf, 0644)
if err != nil {
fmt.Println("write error ", err)
return
}
fmt.Println("Original File Size:", bufLen)
fmt.Println("Anterior Offset Bytes:", before)
fmt.Println("Back Offset Bytes:", after)
fmt.Println("Write Byte Size:", len(exBuf))
}