Free Trial
10 days, no credit_card

<< More Tutorials

How to use rethumb in Go?

To use rethumb in Go try the following code:

package main

import (
	"net/http";
	"io/ioutil"
)

func main() {
	resp, err := http.Get("http://api.rethumb.com/v1/width/100/http://factor45.org/images/beach.jpg")
	check(err)
	defer resp.Body.Close()
	
	body, err := ioutil.ReadAll(resp.Body)
	check(err)

	err = ioutil.WriteFile("beach.thumb.jpg", body, 0644)
	check(err)
}

func check(e error) {
	if e != nil {
		panic(e)
	}
}

Start using this example now

Use the following commands to get started:

$ git clone https://github.com/rethumb/rethumb-go-examples.git
$ cd rethumb-go-examples
$ go build generic.go
$ ./generic

More examples using Go