packageized

This commit is contained in:
Jeffrey Paul 2019-11-04 18:57:48 -08:00
parent c0987f06e6
commit f98f22d9cc
3 changed files with 14 additions and 6 deletions

View File

@ -38,8 +38,8 @@ clean:
build: ./$(FN)
./$(FN): *.go
go build -o $@ $(GOFLAGS) .
./$(FN): *.go cmd/*/*.go
cd cmd/$(FN) && go build -o ../../$(FN) $(GOFLAGS) .
fmt:
go fmt *.go
@ -49,7 +49,7 @@ test: build-docker-image
is_uncommitted:
git diff --exit-code >/dev/null 2>&1
build-docker-image: is_uncommitted
build-docker-image: is_uncommitted clean
docker build -t $(IMAGENAME):$(VERSION) -t $(IMAGENAME):latest -t $(IMAGENAME):$(BUILDTIMETAG) .
dist: build-docker-image
@ -63,3 +63,5 @@ upload-docker-image: build-docker-image
docker push $(IMAGENAME):$(VERSION)
docker push $(IMAGENAME):$(BUILDTIMETAG)
docker push $(IMAGENAME):latest
.PHONY: build fmt test is_uncommitted build-docker-image dist hub upload-docker-image clean run rundebug default

4
api.go
View File

@ -13,6 +13,10 @@ type TootArchiverAPIServer struct {
archiver *TootArchiver
}
func (self *TootArchiverAPIServer) SetArchiver(archiver *TootArchiver) {
self.archiver = archiver
}
func (a *TootArchiverAPIServer) Serve() {
if a.archiver == nil {
panic("must have archiver from which to serve stats")

View File

@ -8,6 +8,8 @@ import "github.com/rs/zerolog"
import "github.com/rs/zerolog/log"
import "golang.org/x/crypto/ssh/terminal"
import "github.com/sneak/feta"
func main() {
os.Exit(app())
}
@ -30,10 +32,10 @@ func app() int {
zerolog.SetGlobalLevel(zerolog.DebugLevel)
}
archiver := NewTootArchiver()
archiver := feta.NewTootArchiver()
api := new(TootArchiverAPIServer)
api.archiver = archiver
api := new(feta.TootArchiverAPIServer)
api.SetArchiver(archiver)
var wg sync.WaitGroup