Skip to content

Commit

Permalink
remove builtin component
Browse files Browse the repository at this point in the history
  • Loading branch information
mkideal committed Aug 10, 2024
1 parent eeb6c28 commit 19c8f62
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 123 deletions.
74 changes: 0 additions & 74 deletions component/builtin/httpserver.go

This file was deleted.

6 changes: 3 additions & 3 deletions container/tree/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,14 @@ var defaultOptions = &Options{

// Fix ensures all options have valid values, using defaults where necessary.
func (options *Options) Fix() {
options.Parent = operator.Or(options.Parent, defaultOptions.Parent)
operator.SetDefault(&options.Parent, defaultOptions.Parent)
if options.Branch == "" {
options.Branch = defaultOptions.Branch
options.LastBranch = operator.Or(options.LastBranch, defaultOptions.LastBranch)
operator.SetDefault(&options.LastBranch, defaultOptions.LastBranch)
} else if options.LastBranch == "" {
options.LastBranch = options.Branch
}
options.Space = operator.Or(options.Space, defaultOptions.Space)
operator.SetDefault(&options.Space, defaultOptions.Space)
}

// Stringify converts a node to a string representation.
Expand Down
7 changes: 0 additions & 7 deletions main.go

This file was deleted.

10 changes: 0 additions & 10 deletions operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,6 @@ package operator

import "github.com/gopherd/core/constraints"

// Or returns b if a is the zero value for T, otherwise returns a.
// It provides a generic "or" operation for any comparable type.
func Or[T comparable](a, b T) T {
var zero T
if a == zero {
return b
}
return a
}

// OrFunc returns the result of calling b() if a is the zero value for T,
// otherwise returns a. It allows for lazy evaluation of the alternative value.
func OrFunc[T comparable](a T, b func() T) T {
Expand Down
29 changes: 0 additions & 29 deletions operator/operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,6 @@ import (
"github.com/gopherd/core/operator"
)

func TestOr(t *testing.T) {
tests := []struct {
name string
a, b, want int
}{
{"both non-zero", 1, 2, 1},
{"a zero", 0, 2, 2},
{"b zero", 1, 0, 1},
{"both zero", 0, 0, 0},
{"negative values", -1, -2, -1},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := operator.Or(tt.a, tt.b); got != tt.want {
t.Errorf("Or(%v, %v) = %v, want %v", tt.a, tt.b, got, tt.want)
}
})
}

// Test with string type
if got := operator.Or("", "default"); got != "default" {
t.Errorf(`Or("", "default") = %q, want "default"`, got)
}
if got := operator.Or("value", "default"); got != "value" {
t.Errorf(`Or("value", "default") = %q, want "value"`, got)
}
}

func TestOrFunc(t *testing.T) {
counter := 0
newFunc := func() int {
Expand Down

0 comments on commit 19c8f62

Please sign in to comment.