gopher/README.md

84 lines
1.5 KiB
Markdown

# Gopher protocol library for Golang
[![Build Status](https://travis-ci.org/prologic/go-gopher.svg)](https://travis-ci.org/prologic/go-gopher)
[![GoDoc](https://godoc.org/github.com/prologic/go-gopher?status.svg)](https://godoc.org/github.com/prologic/go-gopher)
This is a standards compliant Gopher library for the Go programming language
implementing the RFC 1436 specification. The library includes both client and
server handling and examples of each.
## Installation
```#!bash
$ go get github.com/prologic/go-gopher/...
```
## Usage
```#!go
import "github.com/prologic/go-gopher"
```
Or run the builtin (*very simple*) server:
```#!bash
$ gopherd
```
## Example
### Client
```#!go
package main
import (
"fmt"
"github.com/prologic/go-gopher"
)
func main() {
res, _ := gopher.Get("gopher://gopher.floodgap.com/")
bytes, _ = res.Dir.ToText()
fmt.Println(string(bytes))
}
```
### Server
```#!go
package main
import (
"log"
"github.com/prologic/go-gopher"
)
func hello(w gopher.ResponseWriter, r *gopher.Request) {
w.WriteInfo("Hello World!")
}
func main() {
gopher.HandleFunc("/hello", hello)
log.Fatal(gopher.ListenAndServe("localhost:70", nil))
}
```
## Related
Related projects:
- [gopherproxy](https://github.com/prologic/gopherproxy)
gopherproxy is Gopher to HTTP proxy that uses go-gopher
for all of its core functionality.
- [gopherclient](https://github.com/prologic/gopherclient)
gopherclient is a cross-platform QT/QML GUI Gopher Client
using the gopherproxy library as its backend.
## License
MIT