# I want to connect scylladb on golang and i tried copying the code from connect and pasting it doesn't work

**URL:** <https://forum.scylladb.com/t/i-want-to-connect-scylladb-on-golang-and-i-tried-copying-the-code-from-connect-and-pasting-it-doesnt-work/458>\
**Category:** ScyllaDB\
**Created:** [April 15, 2023, 12:06pm UTC](https://forum.scylladb.com/t/i-want-to-connect-scylladb-on-golang-and-i-tried-copying-the-code-from-connect-and-pasting-it-doesnt-work/458 "2023-04-15T12:06:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![KongKal](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.scylladb.com/kongkal/32/273_2.png) [@KongKal](https://forum.scylladb.com/u/KongKal)\
**Post date:** [April 15, 2023, 12:06pm UTC](https://forum.scylladb.com/t/i-want-to-connect-scylladb-on-golang-and-i-tried-copying-the-code-from-connect-and-pasting-it-doesnt-work/458/1 "2023-04-15T12:06:55Z")

</div>

I want to connect scylladb on golang and i tried copying the code from connect and pasting it doesn’t work.

---

<div class="post-metadata">

**Author:** ![Guy](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.scylladb.com/guy/32/9_2.png) [@Guy](https://forum.scylladb.com/u/Guy)\
**Post date:** [April 16, 2023, 3:38am UTC](https://forum.scylladb.com/t/i-want-to-connect-scylladb-on-golang-and-i-tried-copying-the-code-from-connect-and-pasting-it-doesnt-work/458/2 "2023-04-16T03:38:46Z")

</div>

Please share the code you used and the error you received.  
You can see a running example of using golang with ScyllaDB on ScyllaDB University.  
Here is the [first less](https://university.scylladb.com/courses/using-scylla-drivers/lessons/golang-and-scylla-part-1/) (part one out of three).

---

<div class="post-metadata">

**Author:** ![KongKal](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.scylladb.com/kongkal/32/273_2.png) [@KongKal](https://forum.scylladb.com/u/KongKal)\
**Post date:** [April 16, 2023, 3:54am UTC](https://forum.scylladb.com/t/i-want-to-connect-scylladb-on-golang-and-i-tried-copying-the-code-from-connect-and-pasting-it-doesnt-work/458/3 "2023-04-16T03:54:37Z")

</div>

This is the code I came up with and I tried it and it doesn’t work because it doesn’t find it. [github.com/gocql/gocql/scyllacloud](http://github.com/gocql/gocql/scyllacloud)

package main

import (  
“fmt”  
“log”

```
"github.com/gocql/gocql"
"github.com/gocql/gocql/scyllacloud"

```

)

const (  
connectionBundlePath = “./build.yaml”  
)

func main() {  
cluster, err := scyllacloud.NewCloudCluster(connectionBundlePath)  
if err != nil {  
log.Fatalf(“Failed to create cloud cluster config: %s”, err)  
}  
cluster.PoolConfig.HostSelectionPolicy = gocql.DCAwareRoundRobinPolicy(“us-east-1”)

```
session, err := cluster.CreateSession()
if err != nil {
	log.Fatalf("Failed to connect to cluster: %s", err)
}

defer session.Close()

var query = session.Query("SELECT * FROM mykeyspace.mytable")

if rows, err := query.Iter().SliceMap(); err == nil {
	for _, row := range rows {
		fmt.Printf("%v\n", row)
	}
} else {
	log.Fatalf("Query error: %s", err)
}

```

}

---

<div class="post-metadata">

**Author:** ![zimnx](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.scylladb.com/zimnx/32/150_2.png) [@zimnx](https://forum.scylladb.com/u/zimnx)\
**Post date:** [April 20, 2023, 7:40am UTC](https://forum.scylladb.com/t/i-want-to-connect-scylladb-on-golang-and-i-tried-copying-the-code-from-connect-and-pasting-it-doesnt-work/458/4 "2023-04-20T07:40:47Z")

</div>

Are you connecting to ScyllaCloud Serverless cluster (free trial)?  
If yes, you probably don’t have a fork replacement directive in your `go.mod`.

> **[GitHub - scylladb/gocql: Package gocql implements a fast and robust ScyllaDB...](https://github.com/scylladb/gocql#installation)**
>
> Package gocql implements a fast and robust ScyllaDB client for the Go programming language. - GitHub - scylladb/gocql: Package gocql implements a fast and robust ScyllaDB client for the Go programm...

Add the following line to your project `go.mod` file.

```auto
replace github.com/gocql/gocql => github.com/scylladb/gocql v1.7.3

```

and run

```auto
go mod tidy

```

Then make sure the path to the bundle is correct, and your code should run fine.
