1. If you are getting a panic, then you should show the complete error message together with the backtrace, and it will help someone diagnose what's going on. I don't think that simply having stale sessions in your cookie store should cause your program to crash. Indeed, that's one of the benefits of having a persistent cookie store: it should allow your application to be restarted and users' existing sessions should continue unaffected.
2. Do you realise that you've just given the entire world the credentials to access your database? https://github.com/MukhortovDenis/goproject/blob/main/cmd/web/handlers.go#L22 You should keep secrets out of your source code. If your hosting setup lets you pass environment variables to your application at runtime, that would be an easy way to fix it: use os.Getenv() <https://play.golang.org/p/-CplX2jEebO>. Or put the secret into a separate file that you read when the application starts, but you don't commit to version control (use ".gitignore" to prevent it being added by accident). Or pass it as a command-line argument. This is good practice even if the source code were kept private. Passing configuration to your application lets the same code be used in dev, test and production environments. On Thursday, 14 October 2021 at 06:34:54 UTC+1 muhorto...@gmail.com wrote: > Hi, there! How to properly clean up sessions after before disconnecting > the server or before starting it? have a problem that the server > is on a free hosting that periodically shuts down the server. > Since cookies are stored with me and they are no longer relevant, > my server is panicking. This is also necessary for local testing. > What to do and what to use in such cases? > https://github.com/MukhortovDenis/goproject > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/aed281bc-ce70-4291-bae8-0f812569d7cen%40googlegroups.com.