cue icon indicating copy to clipboard operation
cue copied to clipboard

how to use cue mod ?

Open opvexe opened this issue 3 years ago • 0 comments

Cue Version

╰─± cue version
cue version v0.4.3 darwin/arm64

Steps for usage

cue mod init test.io/cuelang
go mod init test.io/cuelang
-------------------------------
╰─± cat new.go 
package code

import (
        "cuelang.org/go/encoding/gocode/gocodec"
)

type Restaturant struct {
        Cuisine string      `json:"cuisine"`
        Tables  []*NewTable `json:"tables,omitempty"`
}

type NewTable struct {
        Seats int  `json:"seats,omitempty" cue:">=0 & <= 10"`
        View  bool `json:"view,omitempty"`
}

func (t NewTable) Validate() error {
        return gocodec.Validate(t)
}
-----------------------------
╰─± ls
cue.mod     go.mod      go.sum      new.go      new_test.go

Get Error

╰─± cue get go . --local
error loading embedded cuelang.org/go/cmd/cue/cmd/interfaces package:
        -: go build cuelang.org/go/cmd/cue/cmd/interfaces: loading compiled Go files from cache: reading srcfiles list: cache entry not found: open /Users/taoshumin_vendor/Library/Caches/go-build/7b/7bda6e8a282f995feb4f00c988eb39bc32badd0dd64cfce174d662134e1b0b5d-a: no such file or directory

Wondering how to use cue.mod and cue get go command, any examples?

opvexe avatar Jul 24 '22 10:07 opvexe