Преименовано в Go-translator

Этот коммит содержится в:
Softonik 2021-10-03 06:19:09 +03:00 коммит произвёл Nobody
родитель 60237ca055
коммит 618f7f0859
5 изменённых файлов: 141 добавлений и 23 удалений

134
Magefile.go Обычный файл
Просмотреть файл

@ -0,0 +1,134 @@
// +build mage
package main
import (
// mage:import
. "magefile/docker"
"github.com/magefile/mage/mg"
)
var (
GolangVolume = "golang.my"
MyGoImageName = "my/go"
)
func init() {
AppName = "go-translator"
ImageName = "my/go"
BuildFn = build
}
func Imports() {
Bash(`sudo docker run -ti --rm \
-h host \
--net=bridge \
-v /etc/localtime:/etc/localtime:ro \
-v ` + GolangVolume + `:/usr/local/go:ro \
\
-v /gopath:/gopath:rw \
-v ${PWD}:/app \
\
-e GOPATH=/gopath \
-e HOME=/home/user \
\
-w /app \
-u 1000 \
\
--entrypoint=/bin/bash \
\
\
` + ImageName + " -c '" +
`go get \
github.com/onsi/ginkgo/ginkgo \
github.com/onsi/gomega/... \
github.com/davecgh/go-spew \
github.com/h12w/go-socks5 \
h12.io/socks \
github.com/vishvananda/netns \
github.com/milosgajdos/tenus \
github.com/docker/libcontainer/netlink \
github.com/go-ping/ping \
github.com/sirupsen/logrus \
github.com/songgao/water \
github.com/aerogo/packet \
github.com/undefinedlabs/go-mpatch \
github.com/buger/goreplay \
github.com/google/gopacket \
&& go list -m -json ... >/dev/null
'`)
}
func ModTidy() {
Bash(`sudo docker run -ti --rm \
-h host \
--net=bridge \
-v /etc/localtime:/etc/localtime:ro \
-v ` + GolangVolume + `:/usr/local/go:ro \
\
-v /d1/d/gopath/_data:/gopath:rw \
-v ${PWD}:/app \
\
-e GOPATH=/gopath \
-e HOME=/home/user \
\
-w /app \
-u 1000 \
\
--entrypoint=/usr/local/go/bin/go \
\
\
` + ImageName + " " +
`mod tidy`)
Imports()
}
func Test() {
mg.Deps(TestLib)
}
func TestLib() {
Bash(`sudo docker run -ti --rm \
-h host \
--net=none \
-v /etc/localtime:/etc/localtime:ro \
-v ` + GolangVolume + `:/usr/local/go:ro \
\
-v /gopath:/gopath:rw \
-v ${PWD}:/app \
\
-e GOPATH=/gopath \
-e HOME=/home/user \
\
-w /app/transpile \
-u 0 \
\
--entrypoint=/usr/local/go/bin/go \
\
` + ImageName + " " +
`test -gcflags=-l`)
}
func build() {
Bash(`sudo docker run -ti --rm \
-h host \
--net=none \
-v /etc/localtime:/etc/localtime:ro \
-v ` + GolangVolume + `:/usr/local/go:ro \
\
-v /gopath:/gopath:rw \
-v ${PWD}:/app \
\
-e GOPATH=/gopath \
-e HOME=/home/user \
\
-w /app/cmd/go-tr \
-u 0 \
\
--entrypoint=/usr/local/go/bin/go \
\
` + ImageName + " " +
`install`)
}

Просмотреть файл

@ -1,15 +0,0 @@
TS=$(shell date -u '+%Y/%m/%d %H:%M:%S')
all: install test
install:
@echo $(TS) Installing...
@go get -u github.com/andygeiss/assert
@go get -u github.com/andygeiss/esp32-controller
@go get -u github.com/andygeiss/esp32-transpiler
@echo $(TS) Done.
test:
@echo $(TS) Testing ...
@go test -v ./...
@echo $(TS) Done.

Просмотреть файл

@ -3,7 +3,7 @@ package main
import ( import (
"flag" "flag"
"fmt" "fmt"
"github.com/andygeiss/esp32-transpiler/transpile" "my/go-translator/transpile"
"os" "os"
) )

4
go.mod
Просмотреть файл

@ -1,3 +1,3 @@
module github.com/andygeiss/esp32-transpiler module my/go-translator
go 1.14 go 1.17

Просмотреть файл

@ -1,8 +1,7 @@
package transpile_test package transpile
import ( import (
"bytes" "bytes"
"github.com/andygeiss/esp32-transpiler/transpile"
"reflect" "reflect"
"strings" "strings"
"testing" "testing"
@ -22,7 +21,7 @@ func Trim(s string) string {
func Validate(source, expected string, t *testing.T) { func Validate(source, expected string, t *testing.T) {
var in, out bytes.Buffer var in, out bytes.Buffer
in.WriteString(source) in.WriteString(source)
service := transpile.NewService(&in, &out) service := NewService(&in, &out)
err := service.Start() err := service.Start()
got := out.String() got := out.String()
tgot, texpected := Trim(got), Trim(expected) tgot, texpected := Trim(got), Trim(expected)