From 8f9b66f6c8565f08e18098e330dfe73c22592b9f Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 19 Dec 2024 10:31:42 -0600 Subject: blobby --- blobby/main.go | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 blobby/main.go (limited to 'blobby/main.go') diff --git a/blobby/main.go b/blobby/main.go new file mode 100644 index 0000000..5b6f89f --- /dev/null +++ b/blobby/main.go @@ -0,0 +1,55 @@ +package main + +import ( + "gocloud.dev/blob" + // _ "gocloud.dev/blob/" + "context" + "fmt" + + _ "gocloud.dev/blob/mysql" +) + +func main() { + bucket, err := blob.OpenBucket(context.Background(), "") + if err != nil { + return fmt.Errorf("could not open bucket: %v", err) + } + defer bucket.Close() + // bucket is a *blob.Bucket; see usage below + + // You can wrap a *blob.Bucket to always operate on a subfolder of the bucket using blob.PrefixedBucket: + + // import "gocloud.dev/blob" + + // Wrap the bucket using blob.PrefixedBucket. + // The prefix should end with "/", so that the resulting bucket operates + // in a subfolder. + bucket = blob.PrefixedBucket(bucket, "a/subfolder/") + + // The original bucket is no longer usable; it has been closed. + // The wrapped bucket should be closed when done. + defer bucket.Close() + + // Bucket operations on will be translated to "a/subfolder/". + + // Alternatively, you can configure the prefix directly in the blob.OpenBucket URL: + + /* + import ( + "context" + "gocloud.dev/blob" + ) + */ + + // Connect to a bucket using a URL, using the "prefix" query parameter to + // target a subfolder in the bucket. + // The prefix should end with "/", so that the resulting bucket operates + // in a subfolder. + b, err := blob.OpenBucket(ctx, "mem://?prefix=a/subfolder/") + if err != nil { + return err + } + defer b.Close() + + // Bucket operations on will be translated to "a/subfolder/". +} -- cgit v1.2.3 From ef537830309b310a59650500e158d5b4a9b3902d Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 6 Jan 2025 07:28:25 -0600 Subject: stuff Signed-off-by: Jeff Carr --- Makefile | 3 +++ blobby/main.go | 3 +++ cf-r2/Makefile | 30 ++++++++++++++++++++++++++++++ cf-r2/download.go | 8 ++++---- going2git/Makefile | 28 ---------------------------- 5 files changed, 40 insertions(+), 32 deletions(-) create mode 100644 cf-r2/Makefile delete mode 100644 going2git/Makefile (limited to 'blobby/main.go') diff --git a/Makefile b/Makefile index 50dd036..205dc6e 100644 --- a/Makefile +++ b/Makefile @@ -4,3 +4,6 @@ all: make -C zoopb-example make -C testGui make -C going2git # actually builds against git2go using libgit2 v1.8.4 + +clean: + rm -f go.* diff --git a/blobby/main.go b/blobby/main.go index 5b6f89f..fda762b 100644 --- a/blobby/main.go +++ b/blobby/main.go @@ -3,6 +3,9 @@ package main import ( "gocloud.dev/blob" // _ "gocloud.dev/blob/" + + _ "github.com/go-sql-driver/mysql" + "context" "fmt" diff --git a/cf-r2/Makefile b/cf-r2/Makefile new file mode 100644 index 0000000..2b57a99 --- /dev/null +++ b/cf-r2/Makefile @@ -0,0 +1,30 @@ +VERSION = $(shell git describe --tags) +GUIVERSION = $(shell git describe --tags) +BUILDTIME = $(shell date +%s) + +all: build + +build: goimports go.mod + go build -v upload.go + go build -v download.go + go build -v main.go + +raw: + GO111MODULE=off go build -v \ + -ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}" + +vet: + GO111MODULE=off go vet + +goimports: + goimports -w *.go + # // to globally reset paths: + # // gofmt -w -r '"go.wit.com/gui/gadgets" -> "go.wit.com/lib/gadgets"' *.go + +go.mod: + go mod init + go mod tidy + +clean: + rm -f go.* + rm -f upload download main diff --git a/cf-r2/download.go b/cf-r2/download.go index b2f4184..887ac99 100644 --- a/cf-r2/download.go +++ b/cf-r2/download.go @@ -10,10 +10,10 @@ import ( ) const ( - r2Endpoint = ".r2.cloudflarestorage.com" // Replace with your R2 endpoint - r2AccessKey = "" // Replace with your Access Key - r2SecretKey = "" // Replace with your Secret Key - r2BucketName = "example-bucket" // Replace with your bucket name + r2Endpoint = ".r2.cloudflarestorage.com" // Replace with your R2 endpoint + r2AccessKey = "" // Replace with your Access Key + r2SecretKey = "" // Replace with your Secret Key + r2BucketName = "example-bucket" // Replace with your bucket name ) func main() { diff --git a/going2git/Makefile b/going2git/Makefile deleted file mode 100644 index 07bcba5..0000000 --- a/going2git/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -VERSION = $(shell git describe --tags) -GUIVERSION = $(shell git describe --tags) -BUILDTIME = $(shell date +%s) - -all: build - -build: goimports - GO111MODULE=off go build -v \ - -ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}" - -vet: - GO111MODULE=off go vet - -goimports: - goimports -w *.go - # // to globally reset paths: - # // gofmt -w -r '"go.wit.com/gui/gadgets" -> "go.wit.com/lib/gadgets"' *.go - -gocui: build - reset - ./go-clone-test --gui gocui - -install: goimports - GO111MODULE=off go install \ - -ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}" - -force: build - ./go-clone-test --force -- cgit v1.2.3