Hi everyone,

I'm getting this error:
1)cannot use j (variable of type int) as type string in send
2)cannot use x (variable of type int) as type float32 in argument to 
comppricevalue
3)cannot use k (variable of type int) as type float32 in send

Code:
package main

import (
    "fmt"
    "time"
)

type ClientOrder2 struct {
    Order_id        int
    Account_id      string
    Currency_symbol string
    Pricevalue      float32
    SellorBuystatus string
}

var orders2 = []ClientOrder2{
    ClientOrder2{
        Order_id:        1,
        Account_id:      "yesh123",
        Currency_symbol: "USD/EUR",
        Pricevalue:      70.001,
        SellorBuystatus: "sell",
    },
    ClientOrder2{
        Currency_symbol: "USD/INR",
        Pricevalue:      70.002,
    },
    ClientOrder2{
        Currency_symbol: "USD/EUR",
        Pricevalue:      71.003,
    },
    ClientOrder2{
        Currency_symbol: "USD/EUR",
        Pricevalue:      70.001,
    },
}

func compcurrency(id string, jobs <-chan string, results chan<- string) 
<-chan string {
    put := make(chan string, 4)
    go func() {
        for j := range jobs {
            for i := 0; i < 4; i++ {
                put <- j
            }
            fmt.Println("comparing pricevalues", id, "Market open:", j)
            time.Sleep(time.Second)
            results <- j
        }
    }()
    return put
}

func comppricevalue(id float32, jobs1 <-chan float32, results1 chan<- 
float32) <-chan float32 {
    putt := make(chan float32, 4)
    go func() {
        for k := range jobs1 {
            for i := 0; i < 4; i++ {
                putt <- k
            }
            fmt.Println("comparing pricevalues", id, "Market open:", k)
            time.Sleep(time.Second)
            results1 <- k
        }
    }()
    return putt
}

func main() {
    fmt.Println("program starting")

    fmt.Println(orders2)

    job := make(chan string, 3)
    result := make(chan string, 3)

    for w := "a"; w <="f"; {
        go compcurrency(w, job, result)
    }
    for j := 1; j <= 9; j++ {
        job <- j
    }
    close(job)
    for a := 1; a <= 9; a++ {
        <-result
    }

    job1 := make(chan float32, 3)
    result1 := make(chan float32, 3)

    for x := 1; x <= 2; x++ {
        go comppricevalue(x, job1, result1)
    }
    for k := 1; k <= 9; k++ {
        job1 <- k
    }
    close(job1)
    for a := 1; a <= 9; a++ {
        <-result1
    }
}

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/ae0ca8cd-3e71-4f5d-b1e4-755c6e24eeebn%40googlegroups.com.

Reply via email to