These are chat archives for gin-gonic/gin

15th
Jun 2017
tw1t611
@tw1t611
Jun 15 2017 14:06
hey all, I have got a problem with Sprintf (I think).
I want to format a cmd for bash to execute: zcash-cli z_sendmany "t1fcT3FfqPXCvZZ6FHq4RxgpNSB7t1pTuPE" "[{\"address\": \"t1bCfoVmKwYa2hLqxVftTbp6zhCbWK8UNJ9\", \"amount\": 0.000020}]" 4. the command works fine, if I copy it manually. But when I want to format it with Sprintf, it throws an errror like this: 2017/06/15 15:59:47 &{zcash-cli z_sendmany "t1fcT3FfqPXCvZZ6FHq4RxgpNSB7t1pTuPE" "[{\"address\": \"t1bCfoVmKwYa2hLqxVftTbp6zhCbWK8UNJ9\", \"amount\": 0.000020}]" 4 0 [zcash-cli z_sendmany "t1fcT3FfqPXCvZZ6FHq4RxgpNSB7t1pTuPE" "[{\"address\": \"t1bCfoVmKwYa2hLqxVftTbp6zhCbWK8UNJ9\", \"amount\": 0.000020}]" 4 0] [] <nil> <nil> <nil> [] <nil> <nil> <nil> <nil> 0xc42010a540 false [] [] [] [] <nil> <nil>}
Did anyone got sth like that before?
kebeeyong
@kebeeyong
Jun 15 2017 21:44
Hi all
i'm trying to build a rest api with go gin and mgo
but i'm having issues with displaying items from the mongo db
please im pretty new here
help me
kebeeyong
@kebeeyong
Jun 15 2017 22:19
how do i query with mongo and go gin
kebeeyong
@kebeeyong
Jun 15 2017 22:30

type Poll struct {
ID string json:"id,omitempty"
Firstname string json:"firstname,omitempty"
Lastname string json:"lastname,omitempty"
Poll string json:"poll,omitempty"
// Address *Address json:"address,omitempty"
}

var (
// Session stores mongo session
Session *mgo.Session

// Mongo stores the mongodb connection string information
Mongo *mgo.DialInfo

)

const (
// MongoDBUrl is the default mongodb url that will be used to connect to the
// database.
MongoDBUrl = "mongodb://localhost:27017/smartpoll"
)

// Connect connects to mongodb
func Connect() {
uri := os.Getenv("MONGODB_URL")

if len(uri) == 0 {
    uri = MongoDBUrl
}

mongo, err := mgo.ParseURL(uri)
s, err := mgo.Dial(uri)
if err != nil {
    fmt.Printf("Can't connect to mongo, go error %v\n", err)
    panic(err.Error())
}
s.SetSafe(&mgo.Safe{})
fmt.Println("Connected to", uri)
Session = s
Mongo = mongo

}

func init() {
Connect()
}

func main() {
port := os.Getenv("PORT")

if port == "" {
    log.Fatal("$PORT must be set")
}
func allPolls(c gin.Context) {
db := c.MustGet("db").(
mgo.Database)
polls := []Poll{}
err := Context.Find().All(&polls)
if err != nil {
c.Error(err)
}
new help with d query
thabks in advance
func allPolls(c gin.Context) {
db := c.MustGet("db").(
mgo.Database)
polls := []Poll{}
err := Context.Find().All(&polls)
if err != nil {
c.Error(err)
}