_id stringlengths 2 7 | title stringlengths 1 118 | partition stringclasses 3
values | text stringlengths 52 85.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q30800 | NewBatch | train | func NewBatch(container Triangles, pic Picture) *Batch {
b := &Batch{cont: Drawer{Triangles: container, Picture: pic}}
b.SetMatrix(IM)
b.SetColorMask(Alpha(1))
return b
} | go | {
"resource": ""
} |
q30801 | Clear | train | func (b *Batch) Clear() {
b.cont.Triangles.SetLen(0)
b.cont.Dirty()
} | go | {
"resource": ""
} |
q30802 | SetColorMask | train | func (b *Batch) SetColorMask(c color.Color) {
if c == nil {
b.col = Alpha(1)
return
}
b.col = ToRGBA(c)
} | go | {
"resource": ""
} |
q30803 | MakeTriangles | train | func (b *Batch) MakeTriangles(t Triangles) TargetTriangles {
bt := &batchTriangles{
tri: t.Copy(),
tmp: MakeTrianglesData(t.Len()),
dst: b,
}
return bt
} | go | {
"resource": ""
} |
q30804 | MakePicture | train | func (b *Batch) MakePicture(p Picture) TargetPicture {
if p != b.cont.Picture {
panic(fmt.Errorf("(%T).MakePicture: Picture is not the Batch's Picture", b))
}
bp := &batchPicture{
pic: p,
dst: b,
}
return bp
} | go | {
"resource": ""
} |
q30805 | Dirty | train | func (d *Drawer) Dirty() {
d.lazyInit()
for _, t := range d.targets {
t.clean = false
}
} | go | {
"resource": ""
} |
q30806 | Draw | train | func (d *Drawer) Draw(t Target) {
d.lazyInit()
if d.Triangles == nil {
return
}
dt := d.targets[t]
if dt == nil {
dt = &drawerTarget{
pics: make(map[Picture]TargetPicture),
}
d.targets[t] = dt
}
if dt.tris == nil {
dt.tris = t.MakeTriangles(d.Triangles)
dt.clean = true
}
if !dt.clean {
dt.... | go | {
"resource": ""
} |
q30807 | NewGLFrame | train | func NewGLFrame(bounds pixel.Rect) *GLFrame {
gf := new(GLFrame)
gf.SetBounds(bounds)
return gf
} | go | {
"resource": ""
} |
q30808 | SetBounds | train | func (gf *GLFrame) SetBounds(bounds pixel.Rect) {
if bounds == gf.Bounds() {
return
}
mainthread.Call(func() {
oldF := gf.frame
_, _, w, h := intBounds(bounds)
if w <= 0 {
w = 1
}
if h <= 0 {
h = 1
}
gf.frame = glhf.NewFrame(w, h, false)
// preserve old content
if oldF != nil {
ox, oy... | go | {
"resource": ""
} |
q30809 | Color | train | func (gf *GLFrame) Color(at pixel.Vec) pixel.RGBA {
if gf.dirty {
mainthread.Call(func() {
tex := gf.frame.Texture()
tex.Begin()
gf.pixels = tex.Pixels(0, 0, tex.Width(), tex.Height())
tex.End()
})
gf.dirty = false
}
if !gf.bounds.Contains(at) {
return pixel.Alpha(0)
}
bx, by, bw, _ := intBound... | go | {
"resource": ""
} |
q30810 | NewGLTriangles | train | func NewGLTriangles(shader *glhf.Shader, t pixel.Triangles) *GLTriangles {
var gt *GLTriangles
mainthread.Call(func() {
gt = &GLTriangles{
vs: glhf.MakeVertexSlice(shader, 0, t.Len()),
shader: shader,
}
})
gt.SetLen(t.Len())
gt.Update(t)
return gt
} | go | {
"resource": ""
} |
q30811 | Len | train | func (gt *GLTriangles) Len() int {
return len(gt.data) / gt.vs.Stride()
} | go | {
"resource": ""
} |
q30812 | Slice | train | func (gt *GLTriangles) Slice(i, j int) pixel.Triangles {
return &GLTriangles{
vs: gt.vs.Slice(i, j),
data: gt.data[i*gt.vs.Stride() : j*gt.vs.Stride()],
shader: gt.shader,
}
} | go | {
"resource": ""
} |
q30813 | Position | train | func (gt *GLTriangles) Position(i int) pixel.Vec {
px := gt.data[i*gt.vs.Stride()+0]
py := gt.data[i*gt.vs.Stride()+1]
return pixel.V(float64(px), float64(py))
} | go | {
"resource": ""
} |
q30814 | Color | train | func (gt *GLTriangles) Color(i int) pixel.RGBA {
r := gt.data[i*gt.vs.Stride()+2]
g := gt.data[i*gt.vs.Stride()+3]
b := gt.data[i*gt.vs.Stride()+4]
a := gt.data[i*gt.vs.Stride()+5]
return pixel.RGBA{
R: float64(r),
G: float64(g),
B: float64(b),
A: float64(a),
}
} | go | {
"resource": ""
} |
q30815 | Picture | train | func (gt *GLTriangles) Picture(i int) (pic pixel.Vec, intensity float64) {
tx := gt.data[i*gt.vs.Stride()+6]
ty := gt.data[i*gt.vs.Stride()+7]
intensity = float64(gt.data[i*gt.vs.Stride()+8])
return pixel.V(float64(tx), float64(ty)), intensity
} | go | {
"resource": ""
} |
q30816 | RGB | train | func RGB(r, g, b float64) RGBA {
return RGBA{r, g, b, 1}
} | go | {
"resource": ""
} |
q30817 | RGBA | train | func (c RGBA) RGBA() (r, g, b, a uint32) {
r = uint32(0xffff * c.R)
g = uint32(0xffff * c.G)
b = uint32(0xffff * c.B)
a = uint32(0xffff * c.A)
return
} | go | {
"resource": ""
} |
q30818 | Monitors | train | func Monitors() []*Monitor {
var monitors []*Monitor
mainthread.Call(func() {
for _, monitor := range glfw.GetMonitors() {
monitors = append(monitors, &Monitor{monitor: monitor})
}
})
return monitors
} | go | {
"resource": ""
} |
q30819 | Name | train | func (m *Monitor) Name() string {
var name string
mainthread.Call(func() {
name = m.monitor.GetName()
})
return name
} | go | {
"resource": ""
} |
q30820 | PhysicalSize | train | func (m *Monitor) PhysicalSize() (width, height float64) {
var wi, hi int
mainthread.Call(func() {
wi, hi = m.monitor.GetPhysicalSize()
})
width = float64(wi)
height = float64(hi)
return
} | go | {
"resource": ""
} |
q30821 | Position | train | func (m *Monitor) Position() (x, y float64) {
var xi, yi int
mainthread.Call(func() {
xi, yi = m.monitor.GetPos()
})
x = float64(xi)
y = float64(yi)
return
} | go | {
"resource": ""
} |
q30822 | Size | train | func (m *Monitor) Size() (width, height float64) {
var mode *glfw.VidMode
mainthread.Call(func() {
mode = m.monitor.GetVideoMode()
})
width = float64(mode.Width)
height = float64(mode.Height)
return
} | go | {
"resource": ""
} |
q30823 | BitDepth | train | func (m *Monitor) BitDepth() (red, green, blue int) {
var mode *glfw.VidMode
mainthread.Call(func() {
mode = m.monitor.GetVideoMode()
})
red = mode.RedBits
green = mode.GreenBits
blue = mode.BlueBits
return
} | go | {
"resource": ""
} |
q30824 | VideoModes | train | func (m *Monitor) VideoModes() (vmodes []VideoMode) {
var modes []*glfw.VidMode
mainthread.Call(func() {
modes = m.monitor.GetVideoModes()
})
for _, mode := range modes {
vmodes = append(vmodes, VideoMode{
Width: mode.Width,
Height: mode.Height,
RefreshRate: mode.RefreshRate,
})
}
return... | go | {
"resource": ""
} |
q30825 | nearlyEqual | train | func nearlyEqual(a, b float64) bool {
epsilon := 0.000001
if a == b {
return true
}
diff := math.Abs(a - b)
if a == 0.0 || b == 0.0 || diff < math.SmallestNonzeroFloat64 {
return diff < (epsilon * math.SmallestNonzeroFloat64)
}
absA := math.Abs(a)
absB := math.Abs(b)
return diff/math.Min(absA+absB, ma... | go | {
"resource": ""
} |
q30826 | Eq | train | func (u Vec) Eq(v Vec) bool {
return nearlyEqual(u.X, v.X) && nearlyEqual(u.Y, v.Y)
} | go | {
"resource": ""
} |
q30827 | XY | train | func (u Vec) XY() (x, y float64) {
return u.X, u.Y
} | go | {
"resource": ""
} |
q30828 | Add | train | func (u Vec) Add(v Vec) Vec {
return Vec{
u.X + v.X,
u.Y + v.Y,
}
} | go | {
"resource": ""
} |
q30829 | Sub | train | func (u Vec) Sub(v Vec) Vec {
return Vec{
u.X - v.X,
u.Y - v.Y,
}
} | go | {
"resource": ""
} |
q30830 | Floor | train | func (u Vec) Floor() Vec {
return Vec{
math.Floor(u.X),
math.Floor(u.Y),
}
} | go | {
"resource": ""
} |
q30831 | Scaled | train | func (u Vec) Scaled(c float64) Vec {
return Vec{u.X * c, u.Y * c}
} | go | {
"resource": ""
} |
q30832 | ScaledXY | train | func (u Vec) ScaledXY(v Vec) Vec {
return Vec{u.X * v.X, u.Y * v.Y}
} | go | {
"resource": ""
} |
q30833 | Len | train | func (u Vec) Len() float64 {
return math.Hypot(u.X, u.Y)
} | go | {
"resource": ""
} |
q30834 | Rotated | train | func (u Vec) Rotated(angle float64) Vec {
sin, cos := math.Sincos(angle)
return Vec{
u.X*cos - u.Y*sin,
u.X*sin + u.Y*cos,
}
} | go | {
"resource": ""
} |
q30835 | Dot | train | func (u Vec) Dot(v Vec) float64 {
return u.X*v.X + u.Y*v.Y
} | go | {
"resource": ""
} |
q30836 | Cross | train | func (u Vec) Cross(v Vec) float64 {
return u.X*v.Y - v.X*u.Y
} | go | {
"resource": ""
} |
q30837 | Lerp | train | func Lerp(a, b Vec, t float64) Vec {
return a.Scaled(1 - t).Add(b.Scaled(t))
} | go | {
"resource": ""
} |
q30838 | L | train | func L(from, to Vec) Line {
return Line{
A: from,
B: to,
}
} | go | {
"resource": ""
} |
q30839 | Bounds | train | func (l Line) Bounds() Rect {
return R(l.A.X, l.A.Y, l.B.X, l.B.Y).Norm()
} | go | {
"resource": ""
} |
q30840 | Center | train | func (l Line) Center() Vec {
return l.A.Add(l.A.To(l.B).Scaled(0.5))
} | go | {
"resource": ""
} |
q30841 | Closest | train | func (l Line) Closest(v Vec) Vec {
// between is a helper function which determines whether x is greater than min(a, b) and less than max(a, b)
between := func(a, b, x float64) bool {
min := math.Min(a, b)
max := math.Max(a, b)
return min < x && x < max
}
// Closest point will be on a line which perpendicula... | go | {
"resource": ""
} |
q30842 | Contains | train | func (l Line) Contains(v Vec) bool {
return l.Closest(v).Eq(v)
} | go | {
"resource": ""
} |
q30843 | Intersect | train | func (l Line) Intersect(k Line) (Vec, bool) {
// Check if the lines are parallel
lDir := l.A.To(l.B)
kDir := k.A.To(k.B)
if lDir.X == kDir.X && lDir.Y == kDir.Y {
return ZV, false
}
// The lines intersect - but potentially not within the line segments.
// Get the intersection point for the lines if they were ... | go | {
"resource": ""
} |
q30844 | IntersectCircle | train | func (l Line) IntersectCircle(c Circle) Vec {
// Get the point on the line closest to the center of the circle.
closest := l.Closest(c.Center)
cirToClosest := c.Center.To(closest)
if cirToClosest.Len() >= c.Radius {
return ZV
}
return cirToClosest.Scaled(cirToClosest.Len() - c.Radius)
} | go | {
"resource": ""
} |
q30845 | IntersectRect | train | func (l Line) IntersectRect(r Rect) Vec {
// Check if either end of the line segment are within the rectangle
if r.Contains(l.A) || r.Contains(l.B) {
// Use the Rect.Intersect to get minimal return value
rIntersect := l.Bounds().Intersect(r)
if rIntersect.H() > rIntersect.W() {
// Go vertical
return V(0, ... | go | {
"resource": ""
} |
q30846 | Len | train | func (l Line) Len() float64 {
return l.A.To(l.B).Len()
} | go | {
"resource": ""
} |
q30847 | Moved | train | func (l Line) Moved(delta Vec) Line {
return Line{
A: l.A.Add(delta),
B: l.B.Add(delta),
}
} | go | {
"resource": ""
} |
q30848 | Rotated | train | func (l Line) Rotated(around Vec, angle float64) Line {
// Move the line so we can use `Vec.Rotated`
lineShifted := l.Moved(around.Scaled(-1))
lineRotated := Line{
A: lineShifted.A.Rotated(angle),
B: lineShifted.B.Rotated(angle),
}
return lineRotated.Moved(around)
} | go | {
"resource": ""
} |
q30849 | Scaled | train | func (l Line) Scaled(scale float64) Line {
return l.ScaledXY(l.Center(), scale)
} | go | {
"resource": ""
} |
q30850 | ScaledXY | train | func (l Line) ScaledXY(around Vec, scale float64) Line {
toA := around.To(l.A).Scaled(scale)
toB := around.To(l.B).Scaled(scale)
return Line{
A: around.Add(toA),
B: around.Add(toB),
}
} | go | {
"resource": ""
} |
q30851 | R | train | func R(minX, minY, maxX, maxY float64) Rect {
return Rect{
Min: Vec{minX, minY},
Max: Vec{maxX, maxY},
}
} | go | {
"resource": ""
} |
q30852 | Norm | train | func (r Rect) Norm() Rect {
return Rect{
Min: Vec{
math.Min(r.Min.X, r.Max.X),
math.Min(r.Min.Y, r.Max.Y),
},
Max: Vec{
math.Max(r.Min.X, r.Max.X),
math.Max(r.Min.Y, r.Max.Y),
},
}
} | go | {
"resource": ""
} |
q30853 | W | train | func (r Rect) W() float64 {
return r.Max.X - r.Min.X
} | go | {
"resource": ""
} |
q30854 | H | train | func (r Rect) H() float64 {
return r.Max.Y - r.Min.Y
} | go | {
"resource": ""
} |
q30855 | Edges | train | func (r Rect) Edges() [4]Line {
corners := r.Vertices()
return [4]Line{
{A: corners[0], B: corners[1]},
{A: corners[1], B: corners[2]},
{A: corners[2], B: corners[3]},
{A: corners[3], B: corners[0]},
}
} | go | {
"resource": ""
} |
q30856 | ResizedMin | train | func (r Rect) ResizedMin(size Vec) Rect {
return Rect{
Min: r.Min,
Max: r.Min.Add(size),
}
} | go | {
"resource": ""
} |
q30857 | Union | train | func (r Rect) Union(s Rect) Rect {
return R(
math.Min(r.Min.X, s.Min.X),
math.Min(r.Min.Y, s.Min.Y),
math.Max(r.Max.X, s.Max.X),
math.Max(r.Max.Y, s.Max.Y),
)
} | go | {
"resource": ""
} |
q30858 | IntersectionPoints | train | func (r Rect) IntersectionPoints(l Line) []Vec {
// Use map keys to ensure unique points
pointMap := make(map[Vec]struct{})
for _, edge := range r.Edges() {
if intersect, ok := l.Intersect(edge); ok {
pointMap[intersect] = struct{}{}
}
}
points := make([]Vec, 0, len(pointMap))
for point := range pointMap... | go | {
"resource": ""
} |
q30859 | Vertices | train | func (r Rect) Vertices() [4]Vec {
return [4]Vec{
r.Min,
V(r.Min.X, r.Max.Y),
r.Max,
V(r.Max.X, r.Min.Y),
}
} | go | {
"resource": ""
} |
q30860 | C | train | func C(center Vec, radius float64) Circle {
return Circle{
Center: center,
Radius: radius,
}
} | go | {
"resource": ""
} |
q30861 | Area | train | func (c Circle) Area() float64 {
return math.Pi * math.Pow(c.Radius, 2)
} | go | {
"resource": ""
} |
q30862 | Moved | train | func (c Circle) Moved(delta Vec) Circle {
return Circle{
Center: c.Center.Add(delta),
Radius: c.Radius,
}
} | go | {
"resource": ""
} |
q30863 | maxCircle | train | func maxCircle(c, d Circle) Circle {
if c.Radius < d.Radius {
return d
}
return c
} | go | {
"resource": ""
} |
q30864 | minCircle | train | func minCircle(c, d Circle) Circle {
if c.Radius < d.Radius {
return c
}
return d
} | go | {
"resource": ""
} |
q30865 | Union | train | func (c Circle) Union(d Circle) Circle {
biggerC := maxCircle(c.Norm(), d.Norm())
smallerC := minCircle(c.Norm(), d.Norm())
// Get distance between centers
dist := c.Center.To(d.Center).Len()
// If the bigger Circle encompasses the smaller one, we have the result
if dist+smallerC.Radius <= biggerC.Radius {
re... | go | {
"resource": ""
} |
q30866 | Intersect | train | func (c Circle) Intersect(d Circle) Circle {
// Check if one of the circles encompasses the other; if so, return that one
biggerC := maxCircle(c.Norm(), d.Norm())
smallerC := minCircle(c.Norm(), d.Norm())
if biggerC.Radius >= biggerC.Center.To(smallerC.Center).Len()+smallerC.Radius {
return biggerC
}
// Calcu... | go | {
"resource": ""
} |
q30867 | Moved | train | func (m Matrix) Moved(delta Vec) Matrix {
m[4], m[5] = m[4]+delta.X, m[5]+delta.Y
return m
} | go | {
"resource": ""
} |
q30868 | ScaledXY | train | func (m Matrix) ScaledXY(around Vec, scale Vec) Matrix {
m[4], m[5] = m[4]-around.X, m[5]-around.Y
m[0], m[2], m[4] = m[0]*scale.X, m[2]*scale.X, m[4]*scale.X
m[1], m[3], m[5] = m[1]*scale.Y, m[3]*scale.Y, m[5]*scale.Y
m[4], m[5] = m[4]+around.X, m[5]+around.Y
return m
} | go | {
"resource": ""
} |
q30869 | Scaled | train | func (m Matrix) Scaled(around Vec, scale float64) Matrix {
return m.ScaledXY(around, V(scale, scale))
} | go | {
"resource": ""
} |
q30870 | Rotated | train | func (m Matrix) Rotated(around Vec, angle float64) Matrix {
sint, cost := math.Sincos(angle)
m[4], m[5] = m[4]-around.X, m[5]-around.Y
m = m.Chained(Matrix{cost, sint, -sint, cost, 0, 0})
m[4], m[5] = m[4]+around.X, m[5]+around.Y
return m
} | go | {
"resource": ""
} |
q30871 | Chained | train | func (m Matrix) Chained(next Matrix) Matrix {
return Matrix{
next[0]*m[0] + next[2]*m[1],
next[1]*m[0] + next[3]*m[1],
next[0]*m[2] + next[2]*m[3],
next[1]*m[2] + next[3]*m[3],
next[0]*m[4] + next[2]*m[5] + next[4],
next[1]*m[4] + next[3]*m[5] + next[5],
}
} | go | {
"resource": ""
} |
q30872 | BoundsOf | train | func (txt *Text) BoundsOf(s string) pixel.Rect {
dot := txt.Dot
prevR := txt.prevR
bounds := pixel.Rect{}
for _, r := range s {
var control bool
dot, control = txt.controlRune(r, dot)
if control {
continue
}
var b pixel.Rect
_, _, b, dot = txt.Atlas().DrawRune(prevR, r, dot)
if bounds.W()*bounds... | go | {
"resource": ""
} |
q30873 | Clear | train | func (txt *Text) Clear() {
txt.prevR = -1
txt.bounds = pixel.Rect{}
txt.tris.SetLen(0)
txt.dirty = true
txt.Dot = txt.Orig
} | go | {
"resource": ""
} |
q30874 | WriteByte | train | func (txt *Text) WriteByte(c byte) error {
txt.buf = append(txt.buf, c)
txt.drawBuf()
return nil
} | go | {
"resource": ""
} |
q30875 | Draw | train | func (txt *Text) Draw(t pixel.Target, matrix pixel.Matrix) {
txt.DrawColorMask(t, matrix, nil)
} | go | {
"resource": ""
} |
q30876 | DrawColorMask | train | func (txt *Text) DrawColorMask(t pixel.Target, matrix pixel.Matrix, mask color.Color) {
if matrix != txt.mat {
txt.mat = matrix
txt.dirty = true
}
if mask == nil {
mask = pixel.Alpha(1)
}
rgba := pixel.ToRGBA(mask)
if rgba != txt.col {
txt.col = rgba
txt.dirty = true
}
if txt.dirty {
txt.trans.SetL... | go | {
"resource": ""
} |
q30877 | Slice | train | func (td *TrianglesData) Slice(i, j int) Triangles {
s := TrianglesData((*td)[i:j])
return &s
} | go | {
"resource": ""
} |
q30878 | Update | train | func (td *TrianglesData) Update(t Triangles) {
if td.Len() != t.Len() {
panic(fmt.Errorf("(%T).Update: invalid triangles length", td))
}
td.updateData(t)
} | go | {
"resource": ""
} |
q30879 | Copy | train | func (td *TrianglesData) Copy() Triangles {
copyTd := MakeTrianglesData(td.Len())
copyTd.Update(td)
return copyTd
} | go | {
"resource": ""
} |
q30880 | Picture | train | func (td *TrianglesData) Picture(i int) (pic Vec, intensity float64) {
return (*td)[i].Picture, (*td)[i].Intensity
} | go | {
"resource": ""
} |
q30881 | MakePictureData | train | func MakePictureData(rect Rect) *PictureData {
w := int(math.Ceil(rect.Max.X)) - int(math.Floor(rect.Min.X))
h := int(math.Ceil(rect.Max.Y)) - int(math.Floor(rect.Min.Y))
pd := &PictureData{
Stride: w,
Rect: rect,
}
pd.Pix = make([]color.RGBA, w*h)
return pd
} | go | {
"resource": ""
} |
q30882 | PictureDataFromImage | train | func PictureDataFromImage(img image.Image) *PictureData {
rgba := image.NewRGBA(img.Bounds())
draw.Draw(rgba, rgba.Bounds(), img, img.Bounds().Min, draw.Src)
verticalFlip(rgba)
pd := MakePictureData(R(
float64(rgba.Bounds().Min.X),
float64(rgba.Bounds().Min.Y),
float64(rgba.Bounds().Max.X),
float64(rgba.B... | go | {
"resource": ""
} |
q30883 | Image | train | func (pd *PictureData) Image() *image.RGBA {
bounds := image.Rect(
int(math.Floor(pd.Rect.Min.X)),
int(math.Floor(pd.Rect.Min.Y)),
int(math.Ceil(pd.Rect.Max.X)),
int(math.Ceil(pd.Rect.Max.Y)),
)
rgba := image.NewRGBA(bounds)
i := 0
for y := bounds.Min.Y; y < bounds.Max.Y; y++ {
for x := bounds.Min.X; x ... | go | {
"resource": ""
} |
q30884 | Index | train | func (pd *PictureData) Index(at Vec) int {
at = at.Sub(pd.Rect.Min.Map(math.Floor))
x, y := int(at.X), int(at.Y)
return y*pd.Stride + x
} | go | {
"resource": ""
} |
q30885 | Color | train | func (pd *PictureData) Color(at Vec) RGBA {
if !pd.Rect.Contains(at) {
return RGBA{0, 0, 0, 0}
}
return ToRGBA(pd.Pix[pd.Index(at)])
} | go | {
"resource": ""
} |
q30886 | ToJSON | train | func (s *Schema) ToJSON() ([]byte, error) {
result := s.exec(context.Background(), introspectionQuery, "", nil, &resolvable.Schema{
Query: &resolvable.Object{},
Schema: *s.schema,
})
if len(result.Errors) != 0 {
panic(result.Errors[0])
}
return json.MarshalIndent(result.Data, "", "\t")
} | go | {
"resource": ""
} |
q30887 | MustParseSchema | train | func MustParseSchema(schemaString string, resolver interface{}, opts ...SchemaOpt) *Schema {
s, err := ParseSchema(schemaString, resolver, opts...)
if err != nil {
panic(err)
}
return s
} | go | {
"resource": ""
} |
q30888 | Tracer | train | func Tracer(tracer trace.Tracer) SchemaOpt {
return func(s *Schema) {
s.tracer = tracer
}
} | go | {
"resource": ""
} |
q30889 | ValidationTracer | train | func ValidationTracer(tracer trace.ValidationTracer) SchemaOpt {
return func(s *Schema) {
s.validationTracer = tracer
}
} | go | {
"resource": ""
} |
q30890 | Logger | train | func Logger(logger log.Logger) SchemaOpt {
return func(s *Schema) {
s.logger = logger
}
} | go | {
"resource": ""
} |
q30891 | Validate | train | func (s *Schema) Validate(queryString string) []*errors.QueryError {
doc, qErr := query.Parse(queryString)
if qErr != nil {
return []*errors.QueryError{qErr}
}
return validation.Validate(s.schema, doc, s.maxDepth)
} | go | {
"resource": ""
} |
q30892 | UnmarshalGraphQL | train | func (t *Time) UnmarshalGraphQL(input interface{}) error {
switch input := input.(type) {
case time.Time:
t.Time = input
return nil
case string:
var err error
t.Time, err = time.Parse(time.RFC3339, input)
return err
case int:
t.Time = time.Unix(int64(input), 0)
return nil
case float64:
t.Time = tim... | go | {
"resource": ""
} |
q30893 | Resolve | train | func (s *Schema) Resolve(name string) common.Type {
return s.Types[name]
} | go | {
"resource": ""
} |
q30894 | Get | train | func (l FieldList) Get(name string) *Field {
for _, f := range l {
if f.Name == name {
return f
}
}
return nil
} | go | {
"resource": ""
} |
q30895 | Names | train | func (l FieldList) Names() []string {
names := make([]string, len(l))
for i, f := range l {
names[i] = f.Name
}
return names
} | go | {
"resource": ""
} |
q30896 | New | train | func New() *Schema {
s := &Schema{
entryPointNames: make(map[string]string),
Types: make(map[string]NamedType),
Directives: make(map[string]*DirectiveDecl),
}
for n, t := range Meta.Types {
s.Types[n] = t
}
for n, d := range Meta.Directives {
s.Directives[n] = d
}
return s
} | go | {
"resource": ""
} |
q30897 | LogPanic | train | func (l *DefaultLogger) LogPanic(_ context.Context, value interface{}) {
const size = 64 << 10
buf := make([]byte, size)
buf = buf[:runtime.Stack(buf, false)]
log.Printf("graphql: panic occurred: %v\n%s", value, buf)
} | go | {
"resource": ""
} |
q30898 | Validate | train | func Validate(ls JSONLoader, ld JSONLoader) (*Result, error) {
// load schema
schema, err := NewSchema(ls)
if err != nil {
return nil, err
}
return schema.Validate(ld)
} | go | {
"resource": ""
} |
q30899 | Validate | train | func (v *Schema) Validate(l JSONLoader) (*Result, error) {
root, err := l.LoadJSON()
if err != nil {
return nil, err
}
return v.validateDocument(root), nil
} | go | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.