Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
vahagz committed Feb 5, 2024
1 parent 7d7e07a commit 8457e2b
Showing 1 changed file with 0 additions and 45 deletions.
45 changes: 0 additions & 45 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package main

import (
"bytes"
"fmt"
"io"
r "math/rand"
"os"
"os/signal"
Expand All @@ -12,13 +10,10 @@ import (
"time"

"go-dbms/config"
"go-dbms/pkg/column"
"go-dbms/pkg/types"
"go-dbms/server"
"go-dbms/services/auth"
"go-dbms/services/executor"
"go-dbms/services/parser"
"go-dbms/util/response"
)

var seed = time.Now().UnixMilli()
Expand Down Expand Up @@ -65,43 +60,3 @@ func fatalf(format string, values ...interface{}) {
fmt.Printf(format, values...)
os.Exit(1)
}

func sprintData(columns []*column.Column, data []map[string]types.DataType) string {
buf := bytes.Buffer{}
for _, d := range data {
for _, col := range columns {
val := fmt.Sprintf("%v", d[col.Name].Value())
buf.WriteByte('\'')
buf.Write([]byte(col.Name))
buf.Write([]byte("' -> '"))
buf.Write([]byte(val))
buf.WriteString("', ")
}
buf.WriteString("\n")
}
return buf.String()
}

func printData(columns []*column.Column, data []map[string]types.DataType) {
fmt.Print(sprintData(columns, data))
}

func randomString(length int) string {
bytes := make([]byte, 0, length)
for i := 0; i < length; i++ {
bytes = append(bytes, byte('a' + rand.Intn(int('z') - int('a'))))
}
return string(bytes)
}

func printResponse(res io.Reader) {
rr := response.NewReader(res)
for {
msg, err := rr.ReadLine()
fmt.Printf("%v '%s'\n", len(msg), string(msg))
if err != nil {
fmt.Println("error =>", err)
break
}
}
}

0 comments on commit 8457e2b

Please sign in to comment.