Sample Go app that fetches files

So no problem with Rclone, I've used it to upload/check millions of files, all good there.

I have to write a Go app that fetches them with a wildcard, I know the first piece of the filename, but need to get one or 2 in a range. Does anyone have a starting point for me what a Go app would look like in github etc... I've done Java for 20 years, Go is new to me.... similar but not.

Many thanks

Do you want to use the rclone internals for this?

Here is something to get you going

package main

import (
	"context"
	"fmt"
	"log"

	//_ "github.com/rclone/rclone/backend/drive"
	_ "github.com/rclone/rclone/backend/all"
	"github.com/rclone/rclone/fs"
)

func main() {
	f, err := fs.NewFs("drive:")
	if err != nil {
		log.Fatal(err)
	}
	entries, err := f.List(context.Background(), "")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(entries)
	for i, o := range entries {
		fmt.Printf("object[%i] = (%T) %v\n", i, o, o)
	}
}

If you want to get a feel for go, then I recommend the go tour for experienced programmers

Thanks Nick, very helpful info!

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.