How to Connect to Cassandra from Go with gocql

Connect to Cassandra from Go using the gocql driver by creating a cluster and establishing a session.

Use the gocql driver to create a session by initializing a cluster with your Cassandra contact points and calling Connect().

import "github.com/gocql/gocql"

cluster := gocql.NewCluster("127.0.0.1")
session, err := cluster.CreateSession()
if err != nil {
    log.Fatal(err)
}
defer session.Close()

This establishes a connection to the Cassandra cluster at the specified address, allowing you to execute queries via the session object.