Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
leighmacdonald committed Jul 21, 2020
1 parent 2d9418f commit 96f4fca
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Basic flags for connecting. Host and password must be set. If the host does not
-v, --version version for rcon

If you do not specify a command a simple REPL shell will open instead as shown below

$ rcon -H tf2-server.com -p asdf
rcon> status
hostname: Uncletopia | San Francisco
Expand All @@ -41,25 +41,26 @@ If you do not specify a command a simple REPL shell will open instead as shown b

## Library Usage

package main

import (
"context"
"github.com/leighmacdonald/rcon/rcon"
)

func main() {
// Connect
conn, err := rcon.Dial(context.Background(), "localhost:27015", "P@SSW0RD", 10*time.Second)
if err != nil {
log.Fatalf("Failed to dial server")
}
// Exec your command
resp, err := conn.Exec("status")
if err != nil {
log.Fatalf("Failed to exec command: %v", err)
}
// Do something with the response
fmt.Printf("%s\n", resp)
}
```go
package main

import (
"context"
"github.com/leighmacdonald/rcon/rcon"
)

func main() {
// Connect
conn, err := rcon.Dial(context.Background(), "localhost:27015", "P@SSW0RD", 10*time.Second)
if err != nil {
log.Fatalf("Failed to dial server")
}
// Exec your command
resp, err := conn.Exec("status")
if err != nil {
log.Fatalf("Failed to exec command: %v", err)
}
// Do something with the response
fmt.Printf("%s\n", resp)
}
```

0 comments on commit 96f4fca

Please sign in to comment.