title: Go Connecting to S3
body: <p>Working on learning Go, and I am writing a component to manage pictures.</p>
  
  <p>I've been looking at the s3 library here: <a href="https://godoc.org/launchpad.net/goamz/s3#ACL" rel="nofollow noreferrer">https://godoc.org/launchpad.net/goamz/s3#ACL</a></p>
  
  <p>In Node, I use the Knox client and connect to my bucket like this:</p>
  
  <pre><code>    var bucket = knox.createClient({
          key: config.get('AWS_KEY'),
          secret: config.get('AWS_SECRET'),
          bucket: "bucketName"
      });
  </code></pre>
  
  <p>In the Go s3 library I see all of the functions I need to work with the s3 bucket, but I can't find the connect function - similar to this one above.</p>
  
  <p>So far, I've found this in the Docs:</p>
  
  <pre><code>    type Auth struct {
          AccessKey, SecretKey string
      }
  </code></pre>
  
  <p>And it seems like I need to call this function:</p>
  
  <pre><code>    func EnvAuth() (auth Auth, err error)
  </code></pre>
  
  <p>This is the EnvAuth function:</p>
  
  <pre><code>    func EnvAuth() (auth Auth, err error) {
          auth.AccessKey = os.Getenv("AWS_ACCESS_KEY_ID")
          auth.SecretKey = os.Getenv("AWS_SECRET_ACCESS_KEY")
          // We fallback to EC2_ env variables if the AWS_ variants are not used.
          if auth.AccessKey == "" &amp;&amp; auth.SecretKey == "" {
              auth.AccessKey = os.Getenv("EC2_ACCESS_KEY")
              auth.SecretKey = os.Getenv("EC2_SECRET_KEY")
          }
          if auth.AccessKey == "" {
              err = errors.New("AWS_ACCESS_KEY_ID not found in environment")
          }
          if auth.SecretKey == "" {
              err = errors.New("AWS_SECRET_ACCESS_KEY not found in environment")
          }
          return
       }
  </code></pre>
  
  <p>In the S3 docs, I see all of the things that I need. I am just unsure about how I use the library, this is the first time I use a Go library.</p>
  
  <p>A guide on connecting to AWS/S3, then making a delete call would be very helpful!</p>
  
  <p>Many thanks :)</p>