Skip to content

wyattanderson/nntp

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nntp.go

An NNTP (news) Client package for go (golang). Forked from nntp-go to bring it up to date.

Example

    // connect to news server
    conn, err := nntp.Dial("tcp", "news.example.com:119")
    if err != nil {
        fmt.Fatalf("connection failed: %v", err)
    }

    // auth
    if err := conn.Authenticate("user", "pass"); err != nil {
        fmt.Fatalf("Could not authenticate")
    }

    // connect to a news group
    grp := "alt.binaries.pictures"
	_, l, _, err := conn.Group(grp)
	if err != nil {
		fmt.Fatalff("Could not connect to group %s: %v %d", grp, err, l)
	}

	// fetch an article
    id := "<[email protected]>"
	article, err := conn.Article(id)
	if err != nil {
		fmt.Fatalf("Could not fetch article %s: %v", id, err)
	}

    // read the article contents
	body, err := ioutil.ReadAll(article.Body)
	if err != nil {
		fmt.Fatalf("error reading reader: %v", err)
	}

About

NNTP package for go (golang)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published