使用Go客户端接收和发送Cookie?

I want my Go application to authenticate with a website and then use the received cookie to access secure locations. The following curl examples illustrates exactly what I'm trying to do:

Authenticate with website via x-www-form-urlencoded and save cookie. Data is urlencoded automatically:

curl 'https://www.example.com/login' \
    --cookie-jar cookies.txt \
    --header 'Content-Type: application/x-www-form-urlencoded' \
    --data 'user=USER NAME&pass=PASS'

Now authentication cookie is saved in cookies.txt and I just send that to access a page that requires login:

curl 'https://www.example.com/profile' \
    --cookie cookies.txt

I don't want to store the cookie on disk in my application, only in memory so I can use it when required.

Does anyone have an example of how this can be achieved in Go?

For golang you can Add a cookie to a request you can also get cookies using this function after making a web request.