Skip to content

Commit

Permalink
move main to subpackage
Browse files Browse the repository at this point in the history
  • Loading branch information
oleggator committed Jul 22, 2023
1 parent ffdcad7 commit eb6f2c6
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ARG TARGETARCH

COPY . .
RUN --mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -ldflags="-s -w" -o /usr/bin/discobot discobot
CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -ldflags="-s -w" -o /usr/bin/discobot discobot/cmd/discobot


FROM alpine:3.17
Expand Down
9 changes: 1 addition & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,4 @@
- ffmpeg

## Docker image is compilable for the next platforms

- x86_64
- x86
- aarch64
- armhf
- s390x
- armv7
- ppc64le
x86_64, x86, aarch64, armhf, s390x, armv7, ppc64le
22 changes: 13 additions & 9 deletions main.go → cmd/discobot/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,32 @@ import (
"os"
"os/signal"
"syscall"

"discobot"
)

var token = os.Getenv("TOKEN")

func main() {
ctx, cancel := context.WithCancel(context.Background())

bot := NewDiscoBot(token)
bot := discobot.NewDiscoBot(token)
if err := bot.Open(ctx); err != nil {
log.Fatalln(err)
}
defer bot.Close()

go func() {
if err := bot.RunPlayer(ctx); err != nil {
log.Println(err)
}
sc := make(chan os.Signal, 1)
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)

fmt.Println("Press CTRL-C to exit.")

<-sc
cancel()
}()

fmt.Println("Press CTRL-C to exit.")
sc := make(chan os.Signal, 1)
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)
<-sc
cancel()
if err := bot.RunPlayer(ctx); err != nil {
log.Println(err)
}
}
2 changes: 1 addition & 1 deletion discobot.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package discobot

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion playback.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package discobot

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion queue.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package discobot

import (
"context"
Expand Down

0 comments on commit eb6f2c6

Please sign in to comment.