human
How do I create a JWT token in Go?
gpt
To create a JWT token in Go, you can use the popular "github.com/dgrijalva/jwt-go" library. Here's an example code snippet that demonstrates how to create a JWT token:

```go
package main

import (
	"fmt"
	"time"

	"github.com/dgrijalva/jwt-go"
)

func main() {
	// Set the secret key used to sign the token
	secret := []byte("my_secret_key")

	// Create a new token with a set of claims
	token := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{
		"username": "my_username",
		"exp":      time.Now().Add(time.Hour * 24).Unix(),
	})

	// Sign the token with the secret key
	tokenString, err := token.SignedString(secret)
	if err != nil {
		fmt.Println("Error creating token string:", err)
		return
	}

	// Print the JWT token string
	fmt.Println(tokenString)
}
```

In this example, we first set a secret key that will be used to sign the token. We then create a new token with a set of claims (in this case, a username and an expiration time of 24 hours from now). Finally, we sign the token with the secret key and print out the resulting JWT token string.
human
What are the advantages of using JWT over cookies for authentication? What are the disadvantages?
gpt
In short, JWT generates token on the server side and store them in the client while cookies work as remembering information on the client browser. They are different.