8000 GitHub - Tensai75/nntp: NNTP package for go (golang)
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Tensai75/nntp

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nntp.go

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

Updates

  • added IHAVE command
  • use XOVER if OVER is unrecognized
  • set overview.Bytes to 0 if bytes value is empty
  • set overview.Lines to 0 if lines value is empty

Example

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

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

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

	// fetch an article
	id := "<4c1c18ec$0$8490$c3e8da3@news.astraweb.com>"
	article, err := conn.Article(id)
	if err != nil {
		log.Fatalf("Could not fetch article %s: %v", id, err)
	}

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

About

NNTP package for go (golang)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%
0