Commit 62a0d7a8a772705b98713e3be1dde7af2e928856
1 parent
0c71c54873
Exists in
master
minor changes
Showing
3 changed files
with
14 additions
and
17 deletions
Show diff stats
document/document.go
... | ... | @@ -175,6 +175,9 @@ func (d *Document) SaveToFile(path string) (f *os.File, err error) { |
175 | 175 | |
176 | 176 | func DeleteDocuments(docs []*Document) error { |
177 | 177 | for _, d := range docs { |
178 | + if d == nil { | |
179 | + continue | |
180 | + } | |
178 | 181 | if err := d.DeleteFile(); err != nil { |
179 | 182 | return err |
180 | 183 | } | ... | ... |
quicksort.go
... | ... | @@ -50,3 +50,13 @@ func partition(que QuickSortable, low, high int, dir QSortDirection) int { |
50 | 50 | que.Swap(i+1, high) |
51 | 51 | return i + 1 |
52 | 52 | } |
53 | + | |
54 | +func BubbleSort(arr []int64) { | |
55 | + for i := 0; i < len(arr)-1; i++ { | |
56 | + for j := i; j < len(arr); j++ { | |
57 | + if arr[i] > arr[j] { | |
58 | + arr[i], arr[j] = arr[j], arr[i] | |
59 | + } | |
60 | + } | |
61 | + } | |
62 | +} | ... | ... |
server.go
... | ... | @@ -4,7 +4,6 @@ import ( |
4 | 4 | "database/sql" |
5 | 5 | "fmt" |
6 | 6 | "net/http" |
7 | - "time" | |
8 | 7 | |
9 | 8 | "git.to-net.rs/marko.tikvic/gologger" |
10 | 9 | "github.com/gorilla/mux" |
... | ... | @@ -38,7 +37,7 @@ func NewODBCServer(dsn, port, logDir string) (s *Server, err error) { |
38 | 37 | s.DBs["default"] = s.DB |
39 | 38 | |
40 | 39 | s.dsn = make(map[string]string) |
41 | - s.DBs["default"] = s.DB | |
40 | + s.dsn["default"] = dsn | |
42 | 41 | |
43 | 42 | return s, nil |
44 | 43 | } |
... | ... | @@ -79,18 +78,3 @@ func CommitChanges(tx *sql.Tx, err *error, opt ...error) { |
79 | 78 | tx.Rollback() |
80 | 79 | } |
81 | 80 | } |
82 | - | |
83 | -func (s *Server) RefreshDatabaseConnections(period time.Duration) { | |
84 | - for { | |
85 | - for k, db := range s.DBs { | |
86 | - if err := db.Ping(); err != nil { | |
87 | - if s.Logger != nil { | |
88 | - s.Logger.PrintAndTrace("failed to ping database (%s): %s", s.dsn[k], err.Error()) | |
89 | - } else { | |
90 | - fmt.Println("failed to ping database (%s): %s", s.dsn[k], err.Error()) | |
91 | - } | |
92 | - } | |
93 | - } | |
94 | - time.Sleep(period) | |
95 | - } | |
96 | -} | ... | ... |