Skip to content

Commit

Permalink
chore: update count scrit
Browse files Browse the repository at this point in the history
  • Loading branch information
thuongtruong109 committed Aug 6, 2024
1 parent 96c992d commit 664f927
Show file tree
Hide file tree
Showing 150 changed files with 2,817 additions and 2,765 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ build:

doc:
@echo "Generating docs..."
go run docs/generate.go ./samples ./samples/api ./samples/array ./samples/cache ./samples/chart ./samples/config ./samples/crypto ./samples/date ./samples/function ./samples/helper ./samples/io ./samples/io/dir ./samples/io/file ./samples/io/path ./samples/math/check ./samples/math/operator ./samples/math/geometry ./samples/math/fomular ./samples/net ./samples/number ./samples/regex ./samples/strings ./samples/structs ./samples/tools ./samples/types/cast ./samples/types/check
go run cmd/doc.go ./samples ./samples/api ./samples/array ./samples/cache ./samples/chart ./samples/config ./samples/crypto ./samples/date ./samples/function ./samples/helper ./samples/io ./samples/io/dir ./samples/io/file ./samples/io/path ./samples/math/check ./samples/math/operator ./samples/math/geometry ./samples/math/fomular ./samples/math/media ./samples/net ./samples/number ./samples/regex ./samples/strings ./samples/structs ./samples/types/cast ./samples/types/check
@echo "Done!"

test:
@echo "Running tests..."
go clean -testcache
go test -v -count=1 -cover -coverprofile=coverage.out ./cache/... ./chart/... ./config/... ./date/... ./number/... ./regex/... ./strings/... ./structs/... ./types/...
go test -v -count=1 -cover -coverprofile=coverage.out ./array/... ./cache/... ./chart/... ./config/... ./cron/... ./date/... ./number/... ./regex/... ./strings/... ./structs/... ./types/...
go tool cover -func=coverage.out
@echo "Done!"

Expand Down Expand Up @@ -56,7 +56,7 @@ lint:

count:
@echo "Counting lines..."
bash count.sh public/count.svg true 13708a api array cache chart config connection crypto console date function helper io log math net number regex strings structs tools types
bash count.sh public/count.svg array cache chart config connection cron crypto console date function helper io log math media net number os regex strings structs types
@echo "Done!"

pre:
Expand Down
2 changes: 2 additions & 0 deletions api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
- http methods
- routing
- interceptors

<!-- https://github.com/uber-go/ratelimit -->
79 changes: 0 additions & 79 deletions api/cors_proxy.go

This file was deleted.

38 changes: 0 additions & 38 deletions api/port_scanner.go

This file was deleted.

25 changes: 0 additions & 25 deletions api/validator.go

This file was deleted.

8 changes: 6 additions & 2 deletions tools/auto_doc.go → cmd/doc.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tools
package main

import (
"fmt"
Expand All @@ -10,7 +10,7 @@ import (
"github.com/thuongtruong109/gouse/strings"
)

func Doc(outputPath, newName string) {
func GenerateDocument(outputPath, newName string) {
if len(os.Args) < 2 {
println("Please provide at least one path to a file or directory")
return
Expand Down Expand Up @@ -120,3 +120,7 @@ func createFilePath(subPath, fileName string, result []byte) {
return
}
}

func main() {
GenerateDocument("docs/docs", "receipts")
}
8 changes: 4 additions & 4 deletions connection/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ package connection
// fieldName := t.Field(i).Name
// fieldValue := v.Field(i).Interface()
// fields = append(fields, fieldName)
// values = append(values, types.InterfaceToString(fieldValue))
// values = append(values, types.ToString(fieldValue))
// }

// query := fmt.Sprintf("INSERT INTO %s (%s) VALUES ('%s')", t.Name(), strings.Join(fields, ", "), strings.Join(values, "', '"))
Expand All @@ -63,7 +63,7 @@ package connection
// fieldName := t.Field(i).Name
// fieldValue := v.Field(i).Interface()
// fields = append(fields, fieldName)
// values = append(values, types.InterfaceToString(fieldValue))
// values = append(values, types.ToString(fieldValue))
// }

// query := fmt.Sprintf("UPDATE %s SET %s WHERE id = %s", t.Name(), strings.Join(fields, ", "), strings.Join(values, "', '"))
Expand All @@ -84,7 +84,7 @@ package connection

// for i := 0; i < v.NumField(); i++ {
// fieldValue := v.Field(i).Interface()
// values = append(values, types.InterfaceToString(fieldValue))
// values = append(values, types.ToString(fieldValue))
// }

// query := fmt.Sprintf("DELETE FROM %s WHERE id = %s", t.Name(), strings.Join(values, "', '"))
Expand All @@ -105,7 +105,7 @@ package connection

// for i := 0; i < v.NumField(); i++ {
// fieldValue := v.Field(i).Interface()
// values = append(values, types.InterfaceToString(fieldValue))
// values = append(values, types.ToString(fieldValue))
// }

// query := fmt.Sprintf("SELECT * FROM %s WHERE id = %s", t.Name(), strings.Join(values, "', '"))
Expand Down
35 changes: 35 additions & 0 deletions count.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

if [ $# -eq 0 ]; then
echo "Please provide at least one path."
exit 1
fi

total_count=0

for dir in "$@"; do
for file in $(find "$dir" -type f -name "*.go" ! -name "*_test.go"); do
count=$(grep -E 'func [A-Z]' "$file" | grep -vE 'func New' | wc -l)
total_count=$((total_count + count))
done
done

echo "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"85\" height=\"20\" role=\"img\" aria-label=\"$total_count functions\" class=\"mdl-js\">
<title>$total_count functions</title>
<linearGradient id=\"s\" x2=\"0\" y2=\"100%\">
<stop offset=\"0\" stop-color=\"#bbb\" stop-opacity=\".1\"/>
<stop offset=\"1\" stop-opacity=\".1\"/>
</linearGradient>
<clipPath id=\"r\">
<rect width=\"85\" height=\"20\" rx=\"3\" fill=\"#fff\"/>
</clipPath>
<g clip-path=\"url(#r)\">
<rect width=\"0\" height=\"20\" fill=\"#13708a\"/>
<rect x=\"0\" width=\"85\" height=\"20\" fill=\"#13708a\"/>
<rect width=\"85\" height=\"20\" fill=\"url(#s)\"/>
</g>
<g fill=\"#fff\" text-anchor=\"middle\" font-family=\"Verdana,Geneva,DejaVu Sans,sans-serif\" text-rendering=\"geometricPrecision\" font-size=\"110\">
<text aria-hidden=\"true\" x=\"425\" y=\"150\" fill=\"#010101\" fill-opacity=\".3\" transform=\"scale(.1)\" textLength=\"750\">$total_count functions</text>
<text x=\"425\" y=\"140\" transform=\"scale(.1)\" fill=\"#fff\" textLength=\"750\">$total_count functions</text>
</g>
</svg>" > public/count.svg
13 changes: 5 additions & 8 deletions docs/docs/receipts/api/port_checker.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,15 @@

```go
import (
"fmt"
"github.com/thuongtruong109/gouse/api"
)
"fmt" "github.com/thuongtruong109/gouse/api")
```
## Functions


### SampleApiPortChecker

```go
func SampleApiPortChecker() {
open := api.PortChecker("tcp", "localhost", 1313)
fmt.Printf("Port Open: %t\n", open)
}
```
func SampleApiPortChecker() {
open := api.PortChecker("tcp", "localhost", 1313)
fmt.Printf("Port Open: %t\n", open)
}```
Expand Down
10 changes: 4 additions & 6 deletions docs/docs/receipts/api/port_scanner.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@

```go
import (
"github.com/thuongtruong109/gouse/api"
)
"github.com/thuongtruong109/gouse/api")
```
## Functions


### SampleApiPortScanner

```go
func SampleApiPortScanner() {
api.PortScanner("tcp", "127.0.0.1", 3000, 8080)
}
```
func SampleApiPortScanner() {
api.PortScanner("tcp", "127.0.0.1", 3000, 8080)
}```
Expand Down
25 changes: 11 additions & 14 deletions docs/docs/receipts/array/chunk.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,21 @@

```go
import (
"fmt"
"github.com/thuongtruong109/gouse/array"
)
"fmt" "github.com/thuongtruong109/gouse/array")
```
## Functions


### SampleArrayChunk

```go
func SampleArrayChunk() {
println("--- Chunk array ---")
fmt.Println("[int]: ", array.Chunk([]int{1, -2, 3, -4, 5, 6}, 3))
fmt.Println("[uint]: ", array.Chunk([]uint{1, 2, 3, 4, 5, 6}, 3))
fmt.Println("[float]: ", array.Chunk([]float64{1.2, 2.3, 3.4, 4.5, 5.6, 6.7}, 3))
fmt.Println("[string]: ", array.Chunk([]string{"1", "2", "3", "4", "5", "6"}, 3))
fmt.Println("[rune]: ", array.Chunk([]rune{'a', 'b', 'c', 'd', 'e', 'f'}, 3))
fmt.Println("[complex]: ", array.Chunk([]complex128{1 + 2i, 2 + 3i, 3 + 4i, 4 + 5i, 5 + 6i, 6 + 7i}, 3))
fmt.Println("[struct]: ", array.Chunk([]struct{ a int }{{1}, {2}, {3}, {4}, {5}, {6}}, 3))
}
```
func SampleArrayChunk() {
println("--- Chunk array ---")
fmt.Println("[int]: ", array.Chunk([]int{1, -2, 3, -4, 5, 6}, 3))
fmt.Println("[uint]: ", array.Chunk([]uint{1, 2, 3, 4, 5, 6}, 3))
fmt.Println("[float]: ", array.Chunk([]float64{1.2, 2.3, 3.4, 4.5, 5.6, 6.7}, 3))
fmt.Println("[string]: ", array.Chunk([]string{"1", "2", "3", "4", "5", "6"}, 3))
fmt.Println("[rune]: ", array.Chunk([]rune{'a', 'b', 'c', 'd', 'e', 'f'}, 3))
fmt.Println("[complex]: ", array.Chunk([]complex128{1 + 2i, 2 + 3i, 3 + 4i, 4 + 5i, 5 + 6i, 6 + 7i}, 3))
fmt.Println("[struct]: ", array.Chunk([]struct{ a int }{{1}, {2}, {3}, {4}, {5}, {6}}, 3))
}```
Expand Down
13 changes: 5 additions & 8 deletions docs/docs/receipts/array/compact.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,15 @@

```go
import (
"fmt"
"github.com/thuongtruong109/gouse/array"
)
"fmt" "github.com/thuongtruong109/gouse/array")
```
## Functions


### SampleArrayCompact

```go
func SampleArrayCompact() {
result := array.Compact([]interface{}{1, -2, 3, -4, 5, 6, 0, 0.0, "", false, nil})
fmt.Println("Compact remove all falsy values: ", result)
}
```
func SampleArrayCompact() {
result := array.Compact([]interface{}{1, -2, 3, -4, 5, 6, 0, 0.0, "", false, nil})
fmt.Println("Compact remove all falsy values: ", result)
}```
Expand Down
Loading

0 comments on commit 664f927

Please sign in to comment.