Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gobdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (db Gobdb[T]) List() []T {
// during the process, the method returns the error with details about what
// went wrong.
func (db *Gobdb[T]) Add(d ...T) error {
file, err := os.Create(db.path)
file, err := os.OpenFile(db.path, os.O_APPEND|os.O_WRONLY, os.ModeAppend)
if err != nil {
return fmt.Errorf("unable to open file: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion gobdb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestAdd(t *testing.T) {
want := []string{"barbara", "victor", "walter"}
err = db.Add(want...)
if err != nil {
t.Errorf("unable to add data %v: %s", want, err)
t.Fatalf("unable to add data %v: %s", want, err)
}
got := db.List()
if !cmp.Equal(want, got) {
Expand Down