-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
73 lines (57 loc) · 1.84 KB
/
main.go
File metadata and controls
73 lines (57 loc) · 1.84 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
main.go
Given a programming language type and parameter types, Black Hayate searches a directory and retrieves matching functions.
Black Hayate is the name of Riza's dog from Fullmetal Alchemist
Author: Justin Chen
2.12.2017
Boston University
Computer Science
Dependencies: exuberant ctags, and mongodb driver for go (http://labix.org/mgo)
Operating systems: GNU Linux, OS X
Supported languages: C, C++, C#, Erlang, Lisp, Lua, Java, Javascript, and Python
*/
package main
import (
"os"
"flag"
"search"
"utils"
"hash/fnv"
"runtime"
)
type Test struct {
Id uint32
Name string
}
func hash(s string) uint32 {
h := fnv.New32a()
h.Write([]byte(s))
return h.Sum32()
}
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
// Parse args
flag.String("dir", "", "Directory to search")
flag.Parse()
// Store args
options := make(map[string]string)
key := ""
for i, arg := range os.Args {
if i > 0 {
if i % 2 != 0 {
key = arg[1:]
} else {
options[key] = arg
}
}
}
// Search directory for functions of desired types
searchDir := options["dir"]
extension := ".java"
// User-defined map to detect valid types. Valid if the key exists. Desired if that key/val is true.
funcTypes := map[string]bool{"int":true, "double":true, "float":true, "boolean":true, "long":true,
"short":true, "byte":true, "public":false, "private":false, "protected":false,
"static":false, "strictfp":false, "native":false, "String":false, "void":false}
session := utils.ConnectDB()
search.SearchAndSaveFunc(session, searchDir, extension, funcTypes)
}