func request() { resp, err := http.Get("http://localhost:8090/teste") erro.Trata(err) var body []byte body, err = ioutil.ReadAll(resp.Body) erro.Trata(err) fmt.Println(string(body)) }
func main() { //tasks := make(chan int, 100) query := "select * from mgmag.efd_registro_c170" db, err := sql.Open("oci8", "system/mega@local") erro.Trata(err) defer db.Close() //defer Trace(time.Now()) rows, err := db.Query(query) erro.Trata(err) defer rows.Close() columns, _ := rows.Columns() scanArgs := make([]interface{}, len(columns)) values := make([]interface{}, len(columns)) for i := range values { scanArgs[i] = &values[i] } total := 0 for rows.Next() { total++ rows.Scan(scanArgs...) //linhas := channels.NewInfiniteChannel() linhas := make(chan []interface{}, 1000) /*if i == 5000 { tasks.Resize(500000) }*/ //fmt.Println(tasks.Cap()) //select { linhas <- values /* fmt.Println("mandou", i) default: fmt.Println("miou", i) }*/ //linhas.Close() close(linhas) } fmt.Println(total) time.Sleep(time.Second * 5) }
func main() { jar, err := cookiejar.New(nil) erro.Trata(err) cookie := http.Cookie{Name: "_jira_ondemand_plugin_session", Domain: "jiraplugin.zendesk.com", Value: `Y1A2elBhcE9hYVZVbThQb0M0YzdjT1dJaEVQaERZZ2VmaitYbWJBQXlXWHlrY3U4K1lUV1VYQUhscWJJelYxR0R1cStFbnNvcEE2WWJ1WWRrR240QnFVT2xvODNGd2UyRmpaL1hGaWdoeVJnWkpSaFJtZXpiU3l1cGRsOU9Za1NDNjRLakE5OWxZUjN5Tm9GYXBJWFhONmJibGNpSlRpZUhlTW1JeHFhdG1tdE9xTGV6cCsrUUh0U292OW9BeS9qTWFaeXZYNFIraDEyelM3aDgxekVoZz09LS11RldRckRVR0xQNFNMeHhUWGJrb1N3PT0%3D--9b6ca352ea8b0ae012c297792976ac9e08bf87d3`, } cookies := []*http.Cookie{&cookie} urlcookie, err := url.Parse("jiraplugin.zendesk.com") erro.Trata(err) jar.SetCookies(urlcookie, cookies) client := http.Client{nil, nil, jar, time.Minute} req, err := http.NewRequest("GET", "https://jiraplugin.zendesk.com/integrations/jira/account/megasistemas/links", nil) erro.Trata(err) resp, err := client.Do(req) erro.Trata(err) io.Copy(os.Stdout, resp.Body) }
func main() { connect := flag.String("connect", "mega/[email protected]:1521/mega", "Connect string no format usuaro/mega@maquina:porta/instancia ou nome do TNS_NAMES") //query := flag.String("query", "select 1 from dual", "Query a ser executada") flag.Parse() fmt.Println(*connect) db, err := sql.Open("oci8", *connect) //db, err := sql.Open("sqlite3", `c:\temp\teste.db`) erro.Trata(err) db.Exec("delete from teste") //for x := 1; x <= 100; x++ { //go func(x int) { x := 1 _, err = db.Exec("insert into teste values (:pk, :id)", x, x) erro.Trata(err) // wg.Done() //}(x) //} //wg.Wait() }
func executa(connect string, query string) { fmt.Println(connect, query) dbg.SetDebug(false) //var err error //var db *sql.DB var banco string if strings.Contains(connect, ".db") { banco = "sqlite3" } else { banco = "oci8" } db, err := sql.Open(banco, connect) //db, err := sql.Open("oci8", connect) //db, err = sql.Open("sqlite3", `c:\temp\teste.db`) if err != nil { fmt.Println(err) return } defer db.Close() defer Trace(time.Now()) rows, err := db.Query(query) if err != nil { fmt.Println(err) } defer rows.Close() columns, _ := rows.Columns() fmt.Println(columns) scanArgs := make([]interface{}, len(columns)) values := make([]interface{}, len(columns)) for i := range values { scanArgs[i] = &values[i] } for rows.Next() { err := rows.Scan(scanArgs...) erro.Trata(err) fmt.Println(values) } }
func main() { config := client.Config{Addr: "127.0.0.1:7373"} cli, err := client.ClientFromConfig(&config) erro.Trata(err) fmt.Println(cli.Members()) }