Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: getaddrinfow: The specified class was not found. #25553

Closed
jeffkayser2 opened this issue May 25, 2018 · 5 comments

Comments

Projects
None yet
4 participants
@jeffkayser2
Copy link

commented May 25, 2018

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

D:\Users\jeff.kayser\Desktop>go version
go version go1.10.2 windows/amd64

D:\Users\jeff.kayser\Desktop>

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

D:\Users\jeff.kayser\Desktop>go env
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\jeff.kayser\AppData\Local\go-build
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=d:\users\jeff.kayser\workspace\gobook
set GORACE=
set GOROOT=C:\Go
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fm
e-length=0 -fdebug-prefix-map=C:\Users\JEFF~1.KAY\AppData\Local\Temp\go-bui
424142=/tmp/go-build -gno-record-gcc-switches

D:\Users\jeff.kayser\Desktop>

What did you do?

Tried to write an IMAP client based on:
https://github.com/emersion/go-imap

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

package main

import (
"bufio"
"fmt"
"log"
"os"

    "github.com/emersion/go-imap/client"
    "github.com/emersion/go-imap"

)

func main() {

    var serverport, username, password string

    reader := bufio.NewReader(os.Stdin)

    log.Println("Connecting to server...")
    // Connect to server
    // c, err := client.DialTLS("mail.example.org:993", nil)
    fmt.Printf("server:port> ")
    serverport, _ = reader.ReadString('\n')
    fmt.Printf("connecting to: %s...\n", serverport)
    c, err := client.DialTLS(serverport, nil)
    if err != nil {
            log.Fatal(err)
    }
    log.Println("Connected")

    // Don't forget to logout
    defer c.Logout()

    // Login
    // if err := c.Login("username", "password"); err != nil {
    fmt.Printf("username: ")
    username, _ = reader.ReadString('\n')
    fmt.Printf("password: ")
    password, _ = reader.ReadString('\n')
    fmt.Printf("logging in as: %s...\n", username)
    if err := c.Login(username, password); err != nil {
            log.Fatal(err)
    }
    log.Println("Logged in")

    // List mailboxes
    mailboxes := make(chan *imap.MailboxInfo, 10)
    done := make(chan error, 1)
    go func () {
            done <- c.List("", "*", mailboxes)
    }()

    log.Println("Mailboxes:")
    for m := range mailboxes {
            log.Println("* " + m.Name)
    }

    if err := <-done; err != nil {
            log.Fatal(err)
    }

    // Select INBOX
    mbox, err := c.Select("INBOX", false)
    if err != nil {
            log.Fatal(err)
    }
    log.Println("Flags for INBOX:", mbox.Flags)

    // Get the last 4 messages
    from := uint32(1)
    to := mbox.Messages
    if mbox.Messages > 3 {
            // We're using unsigned integers here, only substract if the result is > 0
            from = mbox.Messages - 3
    }
    seqset := new(imap.SeqSet)
    seqset.AddRange(from, to)

    messages := make(chan *imap.Message, 10)
    done = make(chan error, 1)
    go func() {
            done <- c.Fetch(seqset, []imap.FetchItem{imap.FetchEnvelope}, messages)
    }()

    log.Println("Last 4 messages:")
    for msg := range messages {
            log.Println("* " + msg.Envelope.Subject)
    }

    if err := <-done; err != nil {
            log.Fatal(err)
    }

    log.Println("Done!")

}

What did you expect to see?

I expected the program to connect to the IMAP server.

What did you see instead?

D:\Users\jeff.kayser\Desktop>main.exe
2018/05/24 17:03:46 Connecting to server...
server:port> mail.jibeconsulting.com:143
connecting to: mail.jibeconsulting.com:143
...
2018/05/24 17:03:55 dial tcp: lookup tcp/143
: getaddrinfow: The specified class was not found.

D:\Users\jeff.kayser\Desktop>

@mattn

This comment has been minimized.

Copy link
Member

commented May 25, 2018

I don't make sure but probably, the serverport contain spaces or \r.

@andybons

This comment has been minimized.

Copy link
Member

commented May 25, 2018

This seems like a better question for the https://github.com/emersion/go-imap project. Closing for now. Please let me know if I should re-open due to a Go-specific issue.

@andybons andybons closed this May 25, 2018

@Dextroz

This comment has been minimized.

Copy link

commented Jun 1, 2018

Issue: "getaddrinfow: The specified class was not found."

I believe the error might possibly be related to net.Dial("tcp", address string)
I am passing in a var called "addr_port" (which would be a string) into net.Dial() like so: net.Dial("tcp", addr_port) and am receiving this error. I have checked the variable and it is of type string so I am confused as to why this error is occurring. When I place the string directly into net.Dial("tcp", "www.hackthissite.org:80") is works as expected.
Am I missing something strikingly obvious here or is this some sort of bug?

My Code:

https://github.com/Dextroz/pscan.go/blob/master/pscan.go

Go Version

go version go1.10.2 windows/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\danie\AppData\Local\go-build
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\danie\go
set GORACE=
set GOROOT=C:\Go
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\danie\AppData\Local\Temp\go-build886849918=/tmp/go-build -gno-record-gcc-switches

@andybons andybons changed the title Windows: getaddrinfow: The specified class was not found. net: getaddrinfow: The specified class was not found. Jun 4, 2018

@andybons

This comment has been minimized.

Copy link
Member

commented Jun 4, 2018

Indeed @mattn is correct. According to the ReadString documentation:

ReadString reads until the first occurrence of delim in the input, returning a string containing the data up to and including the delimiter.

This means that if you enter google.com:80 and press return then addr_port will be google.com:80\n. You have to trim off the newline to get your desired behavior.

@Dextroz

This comment has been minimized.

Copy link

commented Jun 4, 2018

@mattn @andybons Ahh, this makes complete sense. I will rectify my code. Thank you your the help and insight guys!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.