netscapecookiejar is a golang package for storing cookies in netscape cookie jar file
www.example.com FALSE / TRUE 1338534278 cookiename value
import netscapecookiejar "github.com/vanym/golang-netscape-cookiejar"
cookie, err := netscapecookiejar.Unmarshal(".example.com\tTRUE\t/\tTRUE\t1338534278\tcookiename\tvalue")
line, err := netscapecookiejar.Marshal(cookie)
subjar, err := cookiejar.New(&cookiejar.Options{})
jar, err := netscapecookiejar.New(&netscapecookiejar.Options{
SubJar: subjar,
AutoWritePath: "cookies_auto.txt",
WriteHeader: true,
})
file, err := os.Open("cookies_read.txt")
_, err = jar.ReadFrom(file)
file.Close()
file2, err := os.Create("cookies_write.txt")
_, err = jar.WriteTo(file2)
file2.Close()