func GetImageUrls(synset string) ([]string, error) {
    url := "http://image-net.org/api/text/imagenet.synset.geturls?wnid=" + synset
    resp, err := http.Get(url)
    if err != nil {
        return nil, err
    }
    defer resp.Body.Close()
    data, err := ioutil.ReadAll(resp.Body)
    if err != nil {
        return nil, err
    }
    return strings.Split(string(data), "\n"), nil
}
e.g. n02107683 = Berner mountain dog
package main
import (
    "archive/tar"
    "fmt"
    "io/ioutil"
    "net/http"
    "os"
    "strings"
    "time"
)
var outDir = "./raw"  
func main() {
    if len(os.Args) != 2 {
        fmt.Fprintf(os.Stderr, "Usage: imgnet_gather_synset <id>\n")
        os.Exit(1)
    }
    err := GatherSynset(os.Args[1])
    if err != nil {
        fmt.Fprintf(os.Stderr, "%s\n", err.Error())
    }
}
func GatherSynset(synset string) error {
    tmo, err := time.ParseDuration("1m")
    if err != nil {
        return err
    }
    http.DefaultClient.Timeout = tmo
    urls, err := GetImageUrls(synset)
    if err != nil {
        return err
    }
    lfn := synset + ".log"
    lfp, err := os.Create(lfn)
    if err != nil {
        return err
    }
    defer lfp.Close()
    tfn := outDir + "/" + synset + ".tar"
    tfp, err := os.Create(tfn)
    if err != nil {
        return err
    }
    defer tfp.Close()
    tw := tar.NewWriter(tfp)
    defer tw.Close()    
    var meta []string
    total := 0
    index := 0
    for _, url := range urls {
        if len(url) == 0 {
            continue
        }
        url := strings.TrimSpace(url)
        var sfx string
        switch {
        case strings.HasSuffix(url, ".jpg") || strings.HasSuffix(url, ".JPG") || 
                strings.HasSuffix(url, ".jpeg") || strings.HasSuffix(url, ".JPEG"):
            sfx = "jpg"
        case strings.HasSuffix(url, ".png") || strings.HasSuffix(url, ".PNG"):
            sfx = "png"
        default:
            fmt.Fprintf(lfp, "Unsupported image type: %s\n", url)
            continue
        }
        total++
        fmt.Fprintf(lfp, "Loading %s\n", url)
        data, err := GetImage(url)
        if err != nil {
            fmt.Fprintf(lfp, "%s\n", err.Error())
            continue
        }
        sdata := string(data)
        if strings.Contains(sdata, "html>") || strings.Contains(sdata, "HTML>") {
            fmt.Fprintf(lfp, "HTML response detected\n")
            continue
        }
        index++
        meta = append(meta, fmt.Sprintf("%04d.%s %s", index, sfx, url))
        err = WriteTarImage(tw, synset, index, sfx, data)
        if err != nil {
            return err
        }
    }
    fmt.Fprintf(lfp, "Synset %s: have %d of %d\n", synset, index, total)
    mfn := synset + ".meta"
    mfp, err := os.Create(mfn)
    if err != nil {
        return err
    }
    defer mfp.Close()
    for _, ml := range meta {
        fmt.Fprintf(mfp, "%s\n", ml)
    }
    return nil
}