Merge pull request #34 from littlecxm/dev/misc

feat: misc
pull/37/head
ROC 3 years ago committed by GitHub
commit cd945ec850
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

6
.gitignore vendored

@ -1,5 +1,7 @@
.idea
.vscode
__debug_bin
!*.example
dist/
config.yaml
*.log
paopao-api
paopao-ce*

@ -15,7 +15,7 @@ ENV TZ=Asia/Shanghai
RUN apk update && apk add --no-cache ca-certificates && update-ca-certificates
COPY --from=build-env /paopao-ce/paopao-ce /usr/bin/paopao-ce
COPY --from=build-env /paopao-ce/comic.ttf /comic.ttf
COPY --from=build-env /paopao-ce/assets/comic.ttf /assets/comic.ttf
COPY --from=build-env /paopao-ce/configs /configs
EXPOSE 8000

@ -0,0 +1,26 @@
.PHONY: all build clean fmt help
BUILD_VERSION := $(shell cat version)
BUILD_DATE := $(shell date +'%Y-%m-%d %H:%M:%S')
SHA_SHORT := $(shell git rev-parse --short HEAD)
all: fmt build
build:
@go mod download
@echo Build paopao-ce
bash build.sh paopao-ce
clean:
@go clean
@find ./dist -type f -exec rm -r {} +
@find ./tmp -type f -exec rm -r {} +
fmt:
@echo Formatting...
@go fmt ./global/...
@go fmt ./internal/...
@go fmt ./pkg/...
@go vet -composites=false ./global/...
@go vet -composites=false ./internal/...
@go vet -composites=false ./pkg/...
help:
@echo "make: make"
@echo "make build: build executables"
.EXPORT_ALL_VARIABLES:
GO111MODULE = on

@ -0,0 +1,35 @@
#!/usr/bin/env bash
# shellcheck disable=SC2155
set -e
DIST_PREFIX=${1}
DEBUG_MODE=${2}
TARGET_DIR="dist"
PLATFORMS="darwin/arm64 linux/amd64 windows/amd64"
rm -rf ${TARGET_DIR}
mkdir ${TARGET_DIR}
for pl in ${PLATFORMS}; do
export CGO_ENABLED=0
export GOOS=$(echo "${pl}" | cut -d'/' -f1)
export GOARCH=$(echo "${pl}" | cut -d'/' -f2)
export TARGET=${TARGET_DIR}/${DIST_PREFIX}_${GOOS}_${GOARCH}
if [ "${GOOS}" == "windows" ]; then
export TARGET=${TARGET_DIR}/${DIST_PREFIX}_${GOOS}_${GOARCH}.exe
fi
echo "build => ${TARGET}"
if [ "${DEBUG_MODE}" == "debug" ]; then
go build -trimpath -gcflags "all=-N -l" -o "${TARGET}" \
-ldflags "-X 'main.version=${BUILD_VERSION}' \
-X 'main.buildDate=${BUILD_DATE}' \
-X 'main.commitID=${SHA_SHORT}'\
-w -s"
else
go build -trimpath -o "${TARGET}" \
-ldflags "-X 'main.version=${BUILD_VERSION}' \
-X 'main.buildDate=${BUILD_DATE}' \
-X 'main.commitID=${SHA_SHORT}'\
-w -s"
fi
done

@ -9,6 +9,7 @@ require (
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/disintegration/imaging v1.6.2
github.com/ethereum/go-ethereum v1.10.16
github.com/fatih/color v1.13.0
github.com/fbsobreira/gotron-sdk v0.0.0-20211102183839-58a64f4da5f4
github.com/gin-contrib/cors v1.3.1
github.com/gin-gonic/gin v1.7.7
@ -16,7 +17,6 @@ require (
github.com/go-redis/redis/v8 v8.11.4
github.com/go-resty/resty/v2 v2.7.0
github.com/gofrs/uuid v3.3.0+incompatible
github.com/golang/protobuf v1.5.2
github.com/google/go-cmp v0.5.7 // indirect
github.com/satori/go.uuid v1.2.0 // indirect
github.com/sirupsen/logrus v1.8.1
@ -28,6 +28,7 @@ require (
golang.org/x/image v0.0.0-20220413100746-70e8d0d3baa9 // indirect
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5 // indirect
google.golang.org/protobuf v1.27.1
gopkg.in/natefinch/lumberjack.v2 v2.0.0
gopkg.in/resty.v1 v1.12.0
gorm.io/driver/mysql v1.3.2

@ -201,6 +201,7 @@ github.com/ethereum/go-ethereum v1.10.16 h1:3oPrumn0bCW/idjcxMn5YYVCdK7VzJYIvwGZ
github.com/ethereum/go-ethereum v1.10.16/go.mod h1:Anj6cxczl+AHy63o4X9O8yWNHuN5wMpfb8MAnHkWn7Y=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
github.com/fbsobreira/gotron-sdk v0.0.0-20211102183839-58a64f4da5f4 h1:zlN+of+l+or/Y6CYgpX99wwaTf4zN0myVj6YAXiE3xk=
@ -485,6 +486,7 @@ github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope
github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40=
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
github.com/mattn/go-ieproxy v0.0.0-20190610004146-91bb50d98149/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc=
github.com/mattn/go-ieproxy v0.0.0-20190702010315-6dee0af9227d/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc=

@ -44,7 +44,7 @@ func SyncSearchIndex(c *gin.Context) {
func GetCaptcha(c *gin.Context) {
cap := captcha.New()
if err := cap.SetFont("comic.ttf"); err != nil {
if err := cap.SetFont("assets/comic.ttf"); err != nil {
panic(err.Error())
}

@ -4,9 +4,15 @@ import (
"fmt"
"net/http"
"github.com/fatih/color"
"github.com/gin-gonic/gin"
"github.com/rocboss/paopao-ce/global"
"github.com/rocboss/paopao-ce/internal/routers"
"github.com/rocboss/paopao-ce/pkg/util"
)
var (
version, buildDate, commitID string
)
func main() {
@ -21,6 +27,9 @@ func main() {
MaxHeaderBytes: 1 << 20,
}
fmt.Printf("\x1b[36m%s\x1b[0m\n", "PaoPao service listen on http://"+global.ServerSetting.HttpIp+":"+global.ServerSetting.HttpPort)
util.PrintHelloBanner(fmt.Sprintf("paopao %s (build:%s %s)", version, commitID, buildDate))
fmt.Fprintf(color.Output, "PaoPao service listen on %s\n",
color.GreenString(fmt.Sprintf("http://%s:%s", global.ServerSetting.HttpIp, global.ServerSetting.HttpPort)),
)
s.ListenAndServe()
}

@ -6,8 +6,8 @@ import (
"time"
"github.com/fbsobreira/gotron-sdk/pkg/proto/core"
"github.com/golang/protobuf/proto"
"github.com/rocboss/paopao-ce/pkg/crypto"
"google.golang.org/protobuf/proto"
)
// SignTransaction 签名交易

@ -0,0 +1,12 @@
package util
import "fmt"
func PrintHelloBanner(text string) {
fmt.Println(" ____ __ __ ____ __ __ ")
fmt.Println("( _ \\ / _\\ / \\( _ \\ / _\\ / \\ ")
fmt.Println(" ) __// \\( O )) __// \\( O )")
fmt.Println("(__) \\_/\\_/ \\__/(__) \\_/\\_/ \\__/ ")
fmt.Println(text)
}
Loading…
Cancel
Save