Merge branch 'jcarr' of gitea.wit.com:jcarr/wit-utils into jcarr
This commit is contained in:
commit
edfe36358a
|
@ -14,6 +14,7 @@ go-clone-test/go-clone-test
|
||||||
go-clone-test/goclonetest
|
go-clone-test/goclonetest
|
||||||
go-clone-test/goclonetesttest
|
go-clone-test/goclonetesttest
|
||||||
going2git/going2git
|
going2git/going2git
|
||||||
|
blobby/blobby
|
||||||
cf-r2/cf-r2
|
cf-r2/cf-r2
|
||||||
cf-r2/download
|
cf-r2/download
|
||||||
cf-r2/upload
|
cf-r2/upload
|
||||||
|
|
3
Makefile
3
Makefile
|
@ -4,3 +4,6 @@ all:
|
||||||
make -C zoopb-example
|
make -C zoopb-example
|
||||||
make -C testGui
|
make -C testGui
|
||||||
make -C going2git # actually builds against git2go using libgit2 v1.8.4
|
make -C going2git # actually builds against git2go using libgit2 v1.8.4
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f go.*
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
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
|
|
@ -0,0 +1,58 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gocloud.dev/blob"
|
||||||
|
// _ "gocloud.dev/blob/<driver>"
|
||||||
|
|
||||||
|
_ "github.com/go-sql-driver/mysql"
|
||||||
|
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
_ "gocloud.dev/blob/mysql"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
bucket, err := blob.OpenBucket(context.Background(), "<driver-url>")
|
||||||
|
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 <key> will be translated to "a/subfolder/<key>".
|
||||||
|
|
||||||
|
// 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 <key> will be translated to "a/subfolder/<key>".
|
||||||
|
}
|
|
@ -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
|
Loading…
Reference in New Issue