Skip to content

Commit

Permalink
refator: re-struct the directory
Browse files Browse the repository at this point in the history
  • Loading branch information
deancn committed Nov 17, 2024
1 parent 9de2561 commit 1155835
Show file tree
Hide file tree
Showing 26 changed files with 56 additions and 537 deletions.
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
# toolbox

Toolbox is a golang base common library
Toolbox is a golang base common library.

util is short for "utility", typically referring to general-purpose tool functions and methods that are independent of specific business logic.

The diference between utils and kits is that the utils is a collection of functions, without any dependencies.

• Characteristics:
• Lightweight, focused on specific small functions or independent functional points
• No clear domain restrictions, usually consisting of scattered utility functions
• Commonly used to support higher-level business logic

• Usage Scenarios:
• Handling common tasks such as string operations, date formatting, data conversion, etc.
• Independent of specific business logic or context

• Examples:
• Node.js util module: provides general utility functions like util.promisify, util.format
• lodash utility library: includes many common utility functions like deep copy, array deduplication, etc.


## Reference

[gookit/goutil](https://github.com/gookit/goutil)
24 changes: 0 additions & 24 deletions asn2ip/asn2ip_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion deploykit/deploy.go → deployutil/deploy.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package deploykit
package deployutil

import (
"os"
Expand Down
6 changes: 3 additions & 3 deletions deploykit/deploy_test.go → deployutil/deploy_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package deploykit_test
package deployutil_test

import (
"testing"

"github.com/airdb/toolbox/deploykit"
"github.com/airdb/toolbox/deployutil"
. "github.com/smartystreets/goconvey/convey"
)

func TestToEnv(t *testing.T) {
Convey("Given array with few string value", t, func() {
So(deploykit.ToEnv("blue"), ShouldEqual, deploykit.DeployPolicyBlue)
So(deployutil.ToEnv("blue"), ShouldEqual, deployutil.DeployPolicyBlue)
})
}
214 changes: 0 additions & 214 deletions netkit/asn2ip.go

This file was deleted.

2 changes: 1 addition & 1 deletion asn2ip/asn2ip.go → netutil/asn2ip.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package asn2ip
package netutil

import (
"bytes"
Expand Down
6 changes: 3 additions & 3 deletions netkit/asn2ip_test.go → netutil/asn2ip_test.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package netkit_test
package netutil_test

import (
"strings"
"testing"

"github.com/airdb/toolbox/asn2ip"
"github.com/airdb/toolbox/netutil"
)

func TestRun(t *testing.T) {
t.Log("TestRun")

fetcher := asn2ip.NewFetcher("whois.radb.net", 43)
fetcher := netutil.NewFetcher("whois.radb.net", 43)

asnum := "AS4134"
asnum = strings.ReplaceAll(asnum, "AS", "")
Expand Down
6 changes: 3 additions & 3 deletions netkit/dns.go → netutil/dns.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package netkit
package netutil

import (
"log"
"strings"
"time"

"github.com/airdb/toolbox/typekit"
"github.com/airdb/toolbox/typeutil"
"github.com/miekg/dns"
"golang.org/x/net/publicsuffix"
)
Expand Down Expand Up @@ -83,7 +83,7 @@ func ToDomainWithDot(domain string) string {
}

func TrimDomainDot(domain string) string {
return strings.TrimSuffix(domain, typekit.DelimiterDot)
return strings.TrimSuffix(domain, typeutil.DelimiterDot)
}

func GetRootDomain(name string) (string, error) {
Expand Down
2 changes: 1 addition & 1 deletion netkit/dns_test.go → netutil/dns_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package netkit_test
package netutil_test

/*
import (
Expand Down
20 changes: 0 additions & 20 deletions oskit/base.go

This file was deleted.

18 changes: 0 additions & 18 deletions oskit/base_test.go

This file was deleted.

Loading

0 comments on commit 1155835

Please sign in to comment.