From 14656fba266a325f977b9473fe8d2cf176944674 Mon Sep 17 00:00:00 2001 From: Egon Elbre Date: Fri, 10 Apr 2015 10:44:37 +0300 Subject: Use correct path separator on Windows. --- store.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/store.go b/store.go index 13cd1db..2c0257f 100644 --- a/store.go +++ b/store.go @@ -9,6 +9,7 @@ import ( "io/ioutil" "net/http" "os" + "path/filepath" "strings" "sync" @@ -123,9 +124,6 @@ func NewFilesystemStore(path string, keyPairs ...[]byte) *FilesystemStore { if path == "" { path = os.TempDir() } - if path[len(path)-1] != '/' { - path += "/" - } return &FilesystemStore{ Codecs: securecookie.CodecsFromPairs(keyPairs...), Options: &Options{ @@ -215,7 +213,7 @@ func (s *FilesystemStore) save(session *Session) error { if err != nil { return err } - filename := s.path + "session_" + session.ID + filename := filepath.Join(s.path, "session_"+session.ID) fileMutex.Lock() defer fileMutex.Unlock() return ioutil.WriteFile(filename, []byte(encoded), 0600) @@ -223,7 +221,7 @@ func (s *FilesystemStore) save(session *Session) error { // load reads a file and decodes its content into session.Values. func (s *FilesystemStore) load(session *Session) error { - filename := s.path + "session_" + session.ID + filename := filepath.Join(s.path, "session_"+session.ID) fileMutex.RLock() defer fileMutex.RUnlock() fdata, err := ioutil.ReadFile(filename) -- cgit v1.2.3