diff options
author | Kamil Kisiel <kamil@kamilkisiel.net> | 2015-04-10 20:36:12 +0300 |
---|---|---|
committer | Kamil Kisiel <kamil@kamilkisiel.net> | 2015-04-10 20:36:12 +0300 |
commit | cc7771daaa26e8f47d11405d8936946716a44ae6 (patch) | |
tree | adf7941146b5e01e88ef45f2b2a2092155560a4d | |
parent | 3e759b5c5532bec4f3934ea4c745e4ae5d69737a (diff) | |
parent | 14656fba266a325f977b9473fe8d2cf176944674 (diff) |
Merge pull request #46 from egonelbre/fix-filepath
Use correct path separator on Windows.
-rw-r--r-- | store.go | 8 |
1 files changed, 3 insertions, 5 deletions
@@ -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) |