NOTICE: See cyverse/go-irodsclient for the maintained pure go iRODS client implementation.
Golang binding for iRODS C API. Compatible with golang version >= 1.5
Install GoRODS (assuming GOPATH is setup)
$ export CGO_LDFLAGS_ALLOW=.*
$ go get github.com/jjacquay712/GoRODS
Clone repository and run:
$ docker build -t gorods .
$ docker run -it gorods -irods.host=192.168.1.147 -irods.username=rods -irods.password=mypassword
package main
import (
"fmt"
"log"
"github.com/jjacquay712/GoRODS"
)
func main() {
client, conErr := gorods.New(gorods.ConnectionOptions{
Type: gorods.UserDefined,
Host: "localhost",
Port: 1247,
Zone: "tempZone",
Username: "rods",
Password: "password",
})
// Ensure the client initialized successfully and connected to the iCAT server
if conErr != nil {
log.Fatal(conErr)
}
// Open a collection reference for /tempZone/home/rods
if openErr := client.OpenCollection(gorods.CollectionOptions{
Path: "/tempZone/home/rods",
}, func(col *gorods.Collection, con *gorods.Connection) {
// Output collection's string representation
fmt.Printf("String(): %v \n", col)
// Loop over the data objects in the collection, print the file name
col.EachDataObj(func(obj *gorods.DataObj) {
fmt.Printf("%v \n", obj.Name())
})
// Loop over the subcollections in the collection, print the name
col.EachCollection(func(subcol *gorods.Collection) {
fmt.Printf("%v \n", subcol.Name())
})
}); openErr != nil {
log.Fatal(openErr)
}
}
Output:
package main
import (
"github.com/jjacquay712/GoRODS"
"log"
"net/http"
)
func main() {
client, conErr := gorods.New(gorods.ConnectionOptions{
Type: gorods.UserDefined,
Host: "localhost",
Port: 1247,
Zone: "tempZone",
Username: "rods",
Password: "password",
})
// Ensure the client initialized successfully and connected to the iCAT server
if conErr != nil {
log.Fatal(conErr)
}
mountPath := "/irods/"
// Setup the GoRODS FileServer
fs := gorods.FileServer(gorods.FSOptions{
Path: "/tempZone/home/rods",
Client: client,
Download: true,
StripPrefix: mountPath,
})
// Create the URL router
mux := http.NewServeMux()
// Serve the iRODS collection at /irods/
mux.Handle(mountPath, http.StripPrefix(mountPath, fs))
// Start HTTP server on port 8080
log.Fatal(http.ListenAndServe(":8080", mux))
}
Output:
Send me a pull request!
Copyright (c) 2016, University of Florida Research Foundation, Inc. and The BioTeam, Inc. All Rights Reserved.
GoRODS is released under a 3-clause BSD License. For more information please refer to the LICENSE.md file