-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
47 lines (37 loc) · 751 Bytes
/
main.go
File metadata and controls
47 lines (37 loc) · 751 Bytes
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
46
47
package main
import (
"WikiIndex/app"
"compress/bzip2"
"fmt"
"log"
"os"
"github.com/jessevdk/go-flags"
)
var options struct {
Filename string `short:"i" long:"input" description:"Wikipedia XML dump (something ending in .xml.bz2)" required:"true"`
Address string `short:"h" long:"http" description:"HTTP address" default:":8080"`
}
func main() {
if err := run(); err != nil {
log.Fatal(err)
}
}
func run() error {
_, err := flags.Parse(&options)
if err != nil {
os.Exit(1)
}
app := app.New()
f, err := os.Open(options.Filename)
if err != nil {
return err
}
r := bzip2.NewReader(f)
go func() {
if err = app.AddWikiIndex(r); err != nil {
fmt.Println(err)
}
f.Close()
}()
return app.Serve(options.Address)
}