go2: rm -rf
This commit is contained in:
parent
83872ee1c0
commit
a05ba67a36
17 changed files with 31 additions and 78 deletions
|
|
@ -13,10 +13,11 @@ import (
|
|||
|
||||
"oss.terrastruct.com/diff"
|
||||
|
||||
"oss.terrastruct.com/util-go/go2"
|
||||
|
||||
"oss.terrastruct.com/d2/d2ast"
|
||||
"oss.terrastruct.com/d2/d2format"
|
||||
"oss.terrastruct.com/d2/d2parser"
|
||||
"oss.terrastruct.com/d2/lib/go2"
|
||||
)
|
||||
|
||||
func TestRange(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -6,12 +6,13 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"oss.terrastruct.com/util-go/go2"
|
||||
|
||||
"oss.terrastruct.com/d2/d2ast"
|
||||
"oss.terrastruct.com/d2/d2format"
|
||||
"oss.terrastruct.com/d2/d2graph"
|
||||
"oss.terrastruct.com/d2/d2oracle"
|
||||
"oss.terrastruct.com/d2/d2target"
|
||||
"oss.terrastruct.com/d2/lib/go2"
|
||||
)
|
||||
|
||||
func GenDSL(maxi int) (_ string, err error) {
|
||||
|
|
|
|||
|
|
@ -8,12 +8,13 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
|
||||
"oss.terrastruct.com/util-go/go2"
|
||||
|
||||
"oss.terrastruct.com/d2/d2ast"
|
||||
"oss.terrastruct.com/d2/d2format"
|
||||
"oss.terrastruct.com/d2/d2graph"
|
||||
"oss.terrastruct.com/d2/d2parser"
|
||||
"oss.terrastruct.com/d2/d2target"
|
||||
"oss.terrastruct.com/d2/lib/go2"
|
||||
)
|
||||
|
||||
// TODO: should Parse even be exported? guess not. IR should contain list of files and
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
|
||||
"oss.terrastruct.com/util-go/go2"
|
||||
|
||||
"oss.terrastruct.com/d2/d2ast"
|
||||
"oss.terrastruct.com/d2/d2format"
|
||||
"oss.terrastruct.com/d2/d2parser"
|
||||
|
|
@ -15,7 +17,6 @@ import (
|
|||
"oss.terrastruct.com/d2/d2target"
|
||||
"oss.terrastruct.com/d2/d2themes"
|
||||
"oss.terrastruct.com/d2/lib/geo"
|
||||
"oss.terrastruct.com/d2/lib/go2"
|
||||
"oss.terrastruct.com/d2/lib/textmeasure"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package d2graph
|
|||
import (
|
||||
"encoding/json"
|
||||
|
||||
"oss.terrastruct.com/d2/lib/go2"
|
||||
"oss.terrastruct.com/util-go/go2"
|
||||
)
|
||||
|
||||
type SerializedGraph struct {
|
||||
|
|
|
|||
|
|
@ -13,10 +13,11 @@ import (
|
|||
|
||||
"oss.terrastruct.com/xdefer"
|
||||
|
||||
"oss.terrastruct.com/util-go/go2"
|
||||
|
||||
"oss.terrastruct.com/d2/d2graph"
|
||||
"oss.terrastruct.com/d2/d2target"
|
||||
"oss.terrastruct.com/d2/lib/geo"
|
||||
"oss.terrastruct.com/d2/lib/go2"
|
||||
"oss.terrastruct.com/d2/lib/label"
|
||||
"oss.terrastruct.com/d2/lib/log"
|
||||
"oss.terrastruct.com/d2/lib/shape"
|
||||
|
|
|
|||
|
|
@ -15,10 +15,11 @@ import (
|
|||
|
||||
"oss.terrastruct.com/xdefer"
|
||||
|
||||
"oss.terrastruct.com/util-go/go2"
|
||||
|
||||
"oss.terrastruct.com/d2/d2graph"
|
||||
"oss.terrastruct.com/d2/d2target"
|
||||
"oss.terrastruct.com/d2/lib/geo"
|
||||
"oss.terrastruct.com/d2/lib/go2"
|
||||
"oss.terrastruct.com/d2/lib/label"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -6,9 +6,10 @@ import (
|
|||
"math"
|
||||
"sort"
|
||||
|
||||
"oss.terrastruct.com/util-go/go2"
|
||||
|
||||
"oss.terrastruct.com/d2/d2graph"
|
||||
"oss.terrastruct.com/d2/lib/geo"
|
||||
"oss.terrastruct.com/d2/lib/go2"
|
||||
"oss.terrastruct.com/d2/lib/label"
|
||||
"oss.terrastruct.com/d2/lib/shape"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -11,13 +11,14 @@ import (
|
|||
|
||||
"oss.terrastruct.com/xrand"
|
||||
|
||||
"oss.terrastruct.com/util-go/go2"
|
||||
|
||||
"oss.terrastruct.com/d2/d2ast"
|
||||
"oss.terrastruct.com/d2/d2compiler"
|
||||
"oss.terrastruct.com/d2/d2format"
|
||||
"oss.terrastruct.com/d2/d2graph"
|
||||
"oss.terrastruct.com/d2/d2parser"
|
||||
"oss.terrastruct.com/d2/d2target"
|
||||
"oss.terrastruct.com/d2/lib/go2"
|
||||
)
|
||||
|
||||
func Create(g *d2graph.Graph, key string) (_ *d2graph.Graph, newKey string, err error) {
|
||||
|
|
|
|||
|
|
@ -13,12 +13,13 @@ import (
|
|||
|
||||
"oss.terrastruct.com/diff"
|
||||
|
||||
"oss.terrastruct.com/util-go/go2"
|
||||
|
||||
"oss.terrastruct.com/d2/d2compiler"
|
||||
"oss.terrastruct.com/d2/d2format"
|
||||
"oss.terrastruct.com/d2/d2graph"
|
||||
"oss.terrastruct.com/d2/d2oracle"
|
||||
"oss.terrastruct.com/d2/d2target"
|
||||
"oss.terrastruct.com/d2/lib/go2"
|
||||
)
|
||||
|
||||
// TODO: make assertions less specific
|
||||
|
|
|
|||
|
|
@ -9,8 +9,9 @@ import (
|
|||
"unicode"
|
||||
"unicode/utf8"
|
||||
|
||||
"oss.terrastruct.com/util-go/go2"
|
||||
|
||||
"oss.terrastruct.com/d2/d2ast"
|
||||
"oss.terrastruct.com/d2/lib/go2"
|
||||
)
|
||||
|
||||
type ParseOptions struct {
|
||||
|
|
|
|||
|
|
@ -20,12 +20,13 @@ import (
|
|||
"github.com/alecthomas/chroma/lexers"
|
||||
"github.com/alecthomas/chroma/styles"
|
||||
|
||||
"oss.terrastruct.com/util-go/go2"
|
||||
|
||||
"oss.terrastruct.com/d2/d2renderers/d2fonts"
|
||||
"oss.terrastruct.com/d2/d2renderers/d2latex"
|
||||
"oss.terrastruct.com/d2/d2target"
|
||||
"oss.terrastruct.com/d2/lib/color"
|
||||
"oss.terrastruct.com/d2/lib/geo"
|
||||
"oss.terrastruct.com/d2/lib/go2"
|
||||
"oss.terrastruct.com/d2/lib/label"
|
||||
"oss.terrastruct.com/d2/lib/shape"
|
||||
"oss.terrastruct.com/d2/lib/textmeasure"
|
||||
|
|
|
|||
|
|
@ -5,9 +5,10 @@ import (
|
|||
"net/url"
|
||||
"strings"
|
||||
|
||||
"oss.terrastruct.com/util-go/go2"
|
||||
|
||||
"oss.terrastruct.com/d2/d2themes"
|
||||
"oss.terrastruct.com/d2/lib/geo"
|
||||
"oss.terrastruct.com/d2/lib/go2"
|
||||
"oss.terrastruct.com/d2/lib/label"
|
||||
"oss.terrastruct.com/d2/lib/shape"
|
||||
)
|
||||
|
|
|
|||
4
go.mod
generated
4
go.mod
generated
|
|
@ -16,7 +16,6 @@ require (
|
|||
github.com/stretchr/testify v1.8.1
|
||||
github.com/yuin/goldmark v1.5.3
|
||||
go.uber.org/multierr v1.8.0
|
||||
golang.org/x/exp v0.0.0-20221126150942-6ab00d035af9
|
||||
golang.org/x/image v0.1.0
|
||||
golang.org/x/net v0.2.0
|
||||
golang.org/x/text v0.4.0
|
||||
|
|
@ -25,7 +24,7 @@ require (
|
|||
nhooyr.io/websocket v1.8.7
|
||||
oss.terrastruct.com/cmdlog v0.0.0-20221201100934-012c01b3431c
|
||||
oss.terrastruct.com/diff v1.0.2-0.20221116222035-8bf4dd3ab541
|
||||
oss.terrastruct.com/util-go v0.0.0-20221201180807-58edfec77805
|
||||
oss.terrastruct.com/util-go v0.0.0-20221201184644-70a234206a9a
|
||||
oss.terrastruct.com/xcontext v0.0.0-20221018000442-50fdafb12f4f
|
||||
oss.terrastruct.com/xdefer v0.0.0-20221017222355-6f3b6e4d1557
|
||||
oss.terrastruct.com/xjson v0.0.0-20221018000420-4986731c4c4a
|
||||
|
|
@ -57,6 +56,7 @@ require (
|
|||
go.opencensus.io v0.24.0 // indirect
|
||||
go.uber.org/atomic v1.7.0 // indirect
|
||||
golang.org/x/crypto v0.3.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20221126150942-6ab00d035af9 // indirect
|
||||
golang.org/x/sys v0.2.0 // indirect
|
||||
golang.org/x/term v0.2.0 // indirect
|
||||
google.golang.org/genproto v0.0.0-20220822174746-9e6da59bd2fc // indirect
|
||||
|
|
|
|||
4
go.sum
generated
4
go.sum
generated
|
|
@ -802,8 +802,8 @@ oss.terrastruct.com/cmdlog v0.0.0-20221201100934-012c01b3431c h1:C1DDLzj2NrVi1YJ
|
|||
oss.terrastruct.com/cmdlog v0.0.0-20221201100934-012c01b3431c/go.mod h1:C8u/lYTvQWc1xC7rHpgFfpScfQC4NMeGGMmlKVZZUXM=
|
||||
oss.terrastruct.com/diff v1.0.2-0.20221116222035-8bf4dd3ab541 h1:I9B1O1IJ6spivIQxbFRZmbhAwVeLwrcQRR1JbYUOvrI=
|
||||
oss.terrastruct.com/diff v1.0.2-0.20221116222035-8bf4dd3ab541/go.mod h1:ags2QDy/T6jr69hT6bpmAmhr2H98n9o8Atf3QlUJPiU=
|
||||
oss.terrastruct.com/util-go v0.0.0-20221201180807-58edfec77805 h1:DaMNXVEa+ZapP2U2gBVehedPdFsT7GGsGM+d7erCGAY=
|
||||
oss.terrastruct.com/util-go v0.0.0-20221201180807-58edfec77805/go.mod h1:AN5T0bJ89/Q6ZebXIdPGpwAqVhK9PkDpgygWJaT2JzQ=
|
||||
oss.terrastruct.com/util-go v0.0.0-20221201184644-70a234206a9a h1:4+7aYDQhnJa+lM0VpQ9xn4EsyBc5T09ry7d2YXnVekM=
|
||||
oss.terrastruct.com/util-go v0.0.0-20221201184644-70a234206a9a/go.mod h1:l3FJb1Ne4egFfJRbdLJAk4hLZ61nr9kMm0thv2+SvCw=
|
||||
oss.terrastruct.com/xcontext v0.0.0-20221018000442-50fdafb12f4f h1:7voRCwKM7TZkTo9u7hj+uV/zXoVB8czWrTq6MVIh3dg=
|
||||
oss.terrastruct.com/xcontext v0.0.0-20221018000442-50fdafb12f4f/go.mod h1:Y0coTLsWwX0q3a+/Ndq797t+vWyxm42T49Ik3bzaDKY=
|
||||
oss.terrastruct.com/xdefer v0.0.0-20221017222355-6f3b6e4d1557 h1:rPbhJbN1q7B4tnppSPoAMwq0t6Pk5SrQDQ5S6uoNNHg=
|
||||
|
|
|
|||
|
|
@ -1,60 +0,0 @@
|
|||
// Package go2 contains general utility helpers that should've been in Go. Maybe they'll be in Go 2.0.
|
||||
package go2
|
||||
|
||||
import (
|
||||
"hash/fnv"
|
||||
"math"
|
||||
|
||||
"golang.org/x/exp/constraints"
|
||||
)
|
||||
|
||||
func Pointer[T any](v T) *T {
|
||||
return &v
|
||||
}
|
||||
|
||||
func Min[T constraints.Ordered](a, b T) T {
|
||||
if a < b {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func Max[T constraints.Ordered](a, b T) T {
|
||||
if a > b {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func StringToIntHash(s string) int {
|
||||
h := fnv.New32a()
|
||||
h.Write([]byte(s))
|
||||
return int(h.Sum32())
|
||||
}
|
||||
|
||||
func Contains[T comparable](els []T, el T) bool {
|
||||
for _, el2 := range els {
|
||||
if el2 == el {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func Filter[T any](els []T, fn func(T) bool) []T {
|
||||
out := []T{}
|
||||
for _, el := range els {
|
||||
if fn(el) {
|
||||
out = append(out, el)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func IntMax(x, y int) int {
|
||||
return int(math.Max(float64(x), float64(y)))
|
||||
}
|
||||
|
||||
func IntMin(x, y int) int {
|
||||
return int(math.Min(float64(x), float64(y)))
|
||||
}
|
||||
|
|
@ -10,8 +10,9 @@ import (
|
|||
goldmarkHtml "github.com/yuin/goldmark/renderer/html"
|
||||
"golang.org/x/net/html"
|
||||
|
||||
"oss.terrastruct.com/util-go/go2"
|
||||
|
||||
"oss.terrastruct.com/d2/d2renderers/d2fonts"
|
||||
"oss.terrastruct.com/d2/lib/go2"
|
||||
)
|
||||
|
||||
var markdownRenderer goldmark.Markdown
|
||||
|
|
|
|||
Loading…
Reference in a new issue