Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I am trying to send 'hello world' to the telnet server from go client. In the documentation I have found example:

var caller telnet.Caller = telnet.StandardCaller    
telnet.DialToAndCall("localhost:5555", caller)

What is the next step to send 'helloworld' now?

func SetTest() {
    conn, _ := telnet.DialTo("localhost:5555")
    conn.Write([]byte("hello world"))
    conn.Write([]byte("\n"))

In the example below you can see that the CallTELNET uses stdin and stdout to allow the user of the program to communicate through telnet. You can send "hello world" by running the program and typing the desired text you wish to send followed by the enter key.

package main

import (
    "bufio"
    "fmt"
    "log"
    "github.com/reiver/go-oi"
    "github.com/reiver/go-telnet"
type caller struct{}
func (c caller) CallTELNET(ctx telnet.Context, w telnet.Writer, r telnet.Reader) {
    scanner := bufio.NewScanner(os.Stdin)
    for scanner.Scan() {
        oi.LongWrite(w, scanner.Bytes())
        oi.LongWrite(w, []byte("\n"))
func main() {
    fmt.Printf("Dial to %s:%d\n", "localhost", 8080)
    err := telnet.DialToAndCall(fmt.Sprintf("%s:%d", "localhost", 8080), caller{})
    if err != nil {
        log.Fatal(err)

Examples found here and here

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.