MCPcopy
hub / github.com/tmrts/go-patterns / main

Function main

structural/proxy/main.go:11–29  ·  view source on GitHub ↗

For example: we must a execute some command so before that we must to create new terminal session and provide our user name and command

()

Source from the content-addressed store, hash-verified

9// so before that we must to create new terminal session
10// and provide our user name and command
11func main() {
12 // Create new instance of Proxy terminal
13 t, err := NewTerminal("gopher")
14 if err != nil {
15 // panic: User cant be empty
16 // Or
17 // panic: You (badUser) are not allowed to use terminal and execute commands
18 panic(err.Error())
19 }
20
21 // Execute user command
22 excResp, excErr := t.Execute("say_hi") // Proxy prints to STDOUT -> PROXY: Intercepted execution of user (gopher), asked command (say_hi)
23 if excErr != nil {
24 fmt.Printf("ERROR: %s\n", excErr.Error()) // Prints: ERROR: I know only how to execute commands: say_hi, man
25 }
26
27 // Show execution response
28 fmt.Println(excResp) // Prints: gopher@go_term$: Hi gopher
29}
30
31/*
32 From that it's can be different terminals realizations with different methods, propertys, yda yda...

Callers

nothing calls this directly

Calls 2

ExecuteMethod · 0.95
NewTerminalFunction · 0.85

Tested by

no test coverage detected