MCPcopy Create free account
hub / github.com/nsf/gocode / do_client

Function do_client

client.go:15–61  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13)
14
15func do_client() int {
16 addr := *g_addr
17 if *g_sock == "unix" {
18 addr = get_socket_filename()
19 }
20
21 // client
22 client, err := rpc.Dial(*g_sock, addr)
23 if err != nil {
24 if *g_sock == "unix" && file_exists(addr) {
25 os.Remove(addr)
26 }
27
28 err = try_run_server()
29 if err != nil {
30 fmt.Printf("%s\n", err.Error())
31 return 1
32 }
33 client, err = try_to_connect(*g_sock, addr)
34 if err != nil {
35 fmt.Printf("%s\n", err.Error())
36 return 1
37 }
38 }
39 defer client.Close()
40
41 if flag.NArg() > 0 {
42 switch flag.Arg(0) {
43 case "autocomplete":
44 cmd_auto_complete(client)
45 case "close":
46 cmd_close(client)
47 case "status":
48 cmd_status(client)
49 case "drop-cache":
50 cmd_drop_cache(client)
51 case "set":
52 cmd_set(client)
53 case "options":
54 cmd_options(client)
55 default:
56 fmt.Printf("unknown argument: %q, try running \"gocode -h\"\n", flag.Arg(0))
57 return 1
58 }
59 }
60 return 0
61}
62
63func try_run_server() error {
64 path := get_executable_filename()

Callers 1

mainFunction · 0.85

Calls 10

get_socket_filenameFunction · 0.85
file_existsFunction · 0.85
try_run_serverFunction · 0.85
try_to_connectFunction · 0.85
cmd_auto_completeFunction · 0.85
cmd_closeFunction · 0.85
cmd_statusFunction · 0.85
cmd_drop_cacheFunction · 0.85
cmd_setFunction · 0.85
cmd_optionsFunction · 0.85

Tested by

no test coverage detected