Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding custom changes to grammes fork #1

Closed
wants to merge 16 commits into from
15 changes: 8 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
module github.com/northwesternmutual/grammes
module github.com/Kaleidoscope-Inc/grammes

go 1.13

require (
github.com/google/uuid v1.1.0
github.com/gopherjs/gopherjs v0.0.0-20190309154008-847fc94819f9 // indirect
github.com/gorilla/websocket v1.4.0
github.com/pkg/errors v0.8.1 // indirect
github.com/smartystreets/assertions v0.0.0-20190215210624-980c5ac6f3ac // indirect
github.com/northwesternmutual/grammes v1.2.0
github.com/pkg/errors v0.9.1 // indirect
github.com/smartystreets/goconvey v0.0.0-20190306220146-200a235640ff
github.com/stretchr/testify v1.3.0 // indirect
go.uber.org/atomic v1.3.2 // indirect
go.uber.org/multierr v1.1.0 // indirect
github.com/stretchr/testify v1.8.1 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
go.uber.org/zap v1.9.1
)

replace github.com/northwesternmutual/grammes v1.2.0 => github.com/Kaleidoscope-Inc/grammes v1.2.1-0.20230221065140-059981b86c6f

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does this package attempts to refer to an older version of itself?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was an attempt to not change module everywhere since we want it to use our changes but it failed because go has problems with moving on from her ex - i decided to create a separate branch and use this in our code

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see that makes sense. That probably has to do with go's package mechanism + forking. Anyway, LGTM!

44 changes: 25 additions & 19 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,36 +1,42 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/Kaleidoscope-Inc/grammes v1.2.1-0.20230221065140-059981b86c6f h1:8pA4TUmftwBiiD+Oalu80jW37Y6gW2aO7p+IqdcZSxc=
github.com/Kaleidoscope-Inc/grammes v1.2.1-0.20230221065140-059981b86c6f/go.mod h1:Sj+p5edaQt/FUNoNUqQfowy3IUq+WXkoFBEACWSO4AU=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/uuid v1.1.0 h1:Jf4mxPC/ziBnoPIdpQdPJ9OeiomAUHLvxmPRSPH9m4s=
github.com/google/uuid v1.1.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e h1:JKmoR8x90Iww1ks85zJ1lfDGgIiMDuIptTOhJq+zKyg=
github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gopherjs/gopherjs v0.0.0-20190309154008-847fc94819f9/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/jtolds/gls v4.2.1+incompatible h1:fSuqC+Gmlu6l/ZYAoZzx2pyucC8Xza35fpRVWLVmUEE=
github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304 h1:Jpy1PXuP99tXNrhbq2BaPz9B+jNAvH1JPQQpG/9GCXY=
github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/assertions v0.0.0-20190215210624-980c5ac6f3ac h1:wbW+Bybf9pXxnCFAOWZTqkRjAc7rAIwo2e1ArUhiHxg=
github.com/smartystreets/assertions v0.0.0-20190215210624-980c5ac6f3ac/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c h1:Ho+uVpkel/udgjbwB5Lktg9BtvJSh2DT0Hi6LPSyI2w=
github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s=
github.com/smartystreets/goconvey v0.0.0-20190306220146-200a235640ff h1:86HlEv0yBCry9syNuylzqznKXDK11p6D0DT596yNMys=
github.com/smartystreets/goconvey v0.0.0-20190306220146-200a235640ff/go.mod h1:KSQcGKpxUMHk3nbYzs/tIBAM2iDooCn0BmttHOJEbLs=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
go.uber.org/atomic v1.3.2 h1:2Oa65PReHzfn29GpvgsYwloV9AVFHPDk8tYxt2c2tr4=
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ=
go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI=
go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ=
go.uber.org/zap v1.9.1 h1:XCJQEf3W6eZaVwhRBof6ImoYGJSITeKWsyeh3HFu/5o=
go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
4 changes: 2 additions & 2 deletions gremconnect/websocket.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ type WebSocket struct {
func (ws *WebSocket) Connect() error {
var err error
dialer := websocket.Dialer{
WriteBufferSize: 1024 * 8, // Set up for large messages.
ReadBufferSize: 1024 * 8, // Set up for large messages.
WriteBufferSize: 1024 * 256, // Set up for large messages.
ReadBufferSize: 1024 * 256, // Set up for large messages.
Copy link

@MDanialSaleem MDanialSaleem Jan 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should make this configurable.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add another method that takes this as param as input? Otherwise we'll have to modify this signature which might not work for upstream.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for now, we can let it be. There needs to be a more detailed investigation into why we changed what we changed, and if there is a better way to make those changes, before we can merge this to upstream.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i tried this but this needs more parameterizing than it looks so i reverted my changes. i think it's better to open up this issue on grammes and then see how it goes

HandshakeTimeout: 5 * time.Second,
}

Expand Down
10 changes: 9 additions & 1 deletion manager/addvertex.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,15 @@ func (v *addVertexQueryManager) AddVertex(label string, properties ...interface{
query := traversal.NewTraversal().AddV(label)

for i := 0; i < len(properties); i += 2 {
query.AddStep("property", properties[i], properties[i+1])
waleedakramkhan marked this conversation as resolved.
Show resolved Hide resolved
k := properties[i]
v := properties[i+1]
switch v.(type) {
case []interface{}:
waleedakramkhan marked this conversation as resolved.
Show resolved Hide resolved
vInterfaceArray := v.([]interface{})
query.AddSetProperty(k.(string), vInterfaceArray)
default:
query.AddStep("property", k, v)
}
}

return v.AddVertexByString(query.String())
Expand Down
51 changes: 51 additions & 0 deletions model/vertex_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,54 @@ func (v *Vertex) AddProperty(client queryClient, key string, value interface{})

return v.QueryRefresh(client)
}

type EdgeWithPropsAndLabel struct {
Label string
Id interface{}
Properties []interface{}
}

func (v *Vertex) AddEdges(client queryClient, inputEdges []EdgeWithPropsAndLabel) ([]Edge, error) {
if client == nil {
return []Edge{}, gremerror.NewGrammesError("AddEdges", gremerror.ErrNilClient)
}

var query = newTrav().V().HasID(v.ID())

for i, edge := range inputEdges {
if i != 0 {
query = query.OutV()
}
query = query.AddE(edge.Label).To(newTrav().V().HasID(edge.Id).Raw())

if len(edge.Properties)%2 != 0 {
return []Edge{}, gremerror.NewGrammesError("AddEdges", gremerror.ErrOddNumberOfParameters)
}

if len(edge.Properties) > 0 {
for i := 0; i < len(edge.Properties); i += 2 {
query.AddStep("property", edge.Properties[i], edge.Properties[i+1])
waleedakramkhan marked this conversation as resolved.
Show resolved Hide resolved
}
}
}

// Execute the built command.
responses, err := client.ExecuteQuery(query)
if err != nil {
return []Edge{}, gremerror.NewQueryError("AddEdges", query.String(), err)
}

var edges EdgeList
edgeList, err := UnmarshalEdgeList(responses)
if err != nil {
return []Edge{}, err
}

edges.Edges = edgeList

if len(edges.Edges) == 0 {
return []Edge{}, gremerror.NewGrammesError("AddEdges", gremerror.ErrEmptyResponse)
}

return edges.Edges, nil
}
28 changes: 27 additions & 1 deletion model/vertex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func TestAddEdge(t *testing.T) {
Convey("Given a variable that represents the Vertex struct", t, func() {

v := Vertex{Type: "tesType"}
Convey("When 'AddEdges' is called with a string and int", func() {
Convey("When 'AddEdge' is called with a string and int", func() {
var client queryClient
var edge Edge
var tstoutVID int64
Expand All @@ -143,3 +143,29 @@ func TestAddEdge(t *testing.T) {
})
})
}

func TestAddEdges(t *testing.T) {
Convey("Given a variable that represents the Vertex struct", t, func() {

v := Vertex{Type: "tesType"}
Convey("When 'AddEdges' is called with two edges", func() {
var client queryClient
var tstoutVID int64
tstoutVID = 12345
edge1 := EdgeWithPropsAndLabel{
Label: "testLbl",
Id: tstoutVID,
Properties: []interface{}{"tstIntrf1", 7777, "tstIntrf2", 9876},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could probably include a set property with a value of type e.g []int or []string and []interface{} to make sure they are handled correctly.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Properties are a list of interface and we cannot send int as interface, can we?

}
edge2 := EdgeWithPropsAndLabel{
Label: "testLb2",
Id: tstoutVID,
Properties: []interface{}{"tstIntrf1", 8888, "tstIntrf2", 5432},
}
result, _ := v.AddEdges(client, []EdgeWithPropsAndLabel{edge1, edge2})
Convey("Then result should equal two edges", func() {
So(result, ShouldResemble, []Edge{})
})
})
})
}
Empty file modified query/traversal/addproperty.go
100644 → 100755
Empty file.
Empty file modified query/traversal/graph.go
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions query/traversal/pagerank_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ func TestPageRank(t *testing.T) {

Convey("When 'PageRank' is called with one argument", func() {
result := g.PageRank(1.234)
Convey("Then result should equal 'g.pageRank(1.234)'", func() {
So(result.String(), ShouldEqual, "g.pageRank(1.234)")
Convey("Then result should equal 'g.pageRank(1.234000d)'", func() {
So(result.String(), ShouldEqual, "g.pageRank(1.234000d)")
})
})

Expand Down
4 changes: 2 additions & 2 deletions query/traversal/skip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ func TestSkip(t *testing.T) {

Convey("When 'Skip' is called with multiple extraFloat arguments", func() {
result := g.Skip(scope.Local, 1.234)
Convey("Then result should equal 'g.skip(local,1.234)'", func() {
So(result.String(), ShouldEqual, "g.skip(local,1.234)")
Convey("Then result should equal 'g.skip(local,1.234000d)'", func() {
So(result.String(), ShouldEqual, "g.skip(local,1.234000d)")
})
})
})
Expand Down
14 changes: 14 additions & 0 deletions query/traversal/stringstep.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package traversal

// StringStep adds a custom string to the traversal. This is not a gremlin step.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added by @MDanialSaleem will add tests for it

// Added for conveninece when the grammes library does not provide a step.
// Sample usage string_step("count()")
// User is responsible for the correctness of the string.
func (g String) StringStep(traversal string) String {
g.buffer.Reset()

g.buffer.WriteString("." + traversal)

g.string += g.buffer.String()
return g
}
46 changes: 46 additions & 0 deletions query/traversal/stringstep_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright (c) 2018 Northwestern Mutual.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

package traversal

import (
"testing"

. "github.com/smartystreets/goconvey/convey"
)

func TestStringStep(t *testing.T) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests for functionality added by @MDanialSaleem

Convey("Given a ) String { that represents the graph's traversal", t, func() {
g := NewTraversal()
Convey("When 'StringStep' is called with a string step count()", func() {
result := g.StringStep("count()")
Convey("Then result should equal 'g.count()'", func() {
So(result.String(), ShouldEqual, "g.count()")
})
})

Convey("When 'StringStep' is called with a string step values()", func() {
result := g.Values()
Convey("Then result should equal 'g.values()'", func() {
So(result.String(), ShouldEqual, "g.values()")
})
})
})
}
4 changes: 2 additions & 2 deletions query/traversal/timeLimit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ func TestTimeLimit(t *testing.T) {
g := NewTraversal()
Convey("When 'Store' is called", func() {
result := g.TimeLimit(1.234)
Convey("Then result should equal 'g.timeLimit(1.234)'", func() {
So(result.String(), ShouldEqual, "g.timeLimit(1.234)")
Convey("Then result should equal 'g.timeLimit(1.234000d)'", func() {
So(result.String(), ShouldEqual, "g.timeLimit(1.234000d)")
})
})
})
Expand Down
34 changes: 34 additions & 0 deletions query/traversal/util.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ func (g *String) AddStep(step string, params ...interface{}) {
g.buffer.Write(t)
case string:
g.buffer.WriteString("\"" + strings.ReplaceAll(t, "\"", "\\\"") + "\"")
case int64, uint64:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved the change in refactored newer version here

g.buffer.WriteString(fmt.Sprintf("%dL", p))
case float32, float64:
g.buffer.WriteString(fmt.Sprintf("%fd", p))
default:
g.buffer.WriteString(fmt.Sprintf("%v", t))
}
Expand Down Expand Up @@ -118,3 +122,33 @@ func gatherInts(params ...int) string {
return ""
}
}

func (g *String) AddListProperty(k string, v []string) {
g.buffer.Reset()

for _, vv := range v {
g.buffer.WriteString(fmt.Sprintf(".property(list, \"%s\", \"%s\")", k, vv))
}
g.string += g.buffer.String()
}

func (g *String) AddSetProperty(k string, v []interface{}) {
g.buffer.Reset()

for _, vv := range v {
switch value := vv.(type) {
case float64, float32:
g.buffer.WriteString(fmt.Sprintf(`.property(set, "%s", %fd)`, k, value))
case int64:
g.buffer.WriteString(fmt.Sprintf(`.property(set, "%s", %dL)`, k, value))
case int, bool:
g.buffer.WriteString(fmt.Sprintf(".property(set, \"%s\", %v)", k, value))
case string:
g.buffer.WriteString(fmt.Sprintf(".property(set, \"%s\", \"%s\")", k, value))
default:
g.buffer.WriteString(fmt.Sprintf(".property(set, \"%s\", \"%s\")", k, value))
}
}

g.string += g.buffer.String()
}
Loading