move to utils package

This commit is contained in:
w1ndyb0y
2020-12-21 15:38:33 +08:00
parent 51fa99e57b
commit 8a116818cf
10 changed files with 158 additions and 178 deletions
+5 -15
View File
@@ -16,11 +16,9 @@ limitations under the License.
package cmd
import (
"fmt"
"github.com/spf13/cobra"
"github.com/tarm/serial"
"it2000.com.cn/tele-recv/database"
"os"
"it2000.com.cn/tele-recv/utils"
"log"
)
// testCmd represents the test command
@@ -34,18 +32,10 @@ Test load sqlite database and init table`,
}
func test(cmd *cobra.Command, args []string) {
fmt.Println("test called")
fmt.Println("device :", device)
c := &serial.Config{Name: device, Baud: baudrate, Size: bytesize}
s, err := serial.OpenPort(c)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
fmt.Println(c, "opened")
_ = s.Close()
log.Println("Testing environment")
_ = utils.OpenPort(device, baudrate, bytesize)
err = database.Init(dbFile, dbInit)
err := utils.InitDb(dbFile, dbInit)
if err != nil {
println("create database error ", err)
}