Browse Source

Initial commit

Dmitry Yu Okunev 2 years ago
commit
34bae1d798
3 changed files with 40 additions and 0 deletions
  1. 1 0
      .gitignore
  2. 9 0
      Makefile
  3. 30 0
      main.go

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+sdapi-cli

+ 9 - 0
Makefile

@@ -0,0 +1,9 @@
+
+all: deps
+	go build
+
+deps:
+	go get -u github.com/mailru/easyjson/...
+	go get github.com/xaionaro/reform/reform
+	cd $(GOPATH)/src/devel.mephi.ru/dyokunev/go-asu-models && go generate
+

+ 30 - 0
main.go

@@ -0,0 +1,30 @@
+//go:generate make deps
+
+package main
+
+import (
+	"devel.mephi.ru/dyokunev/go-sdapi/sdApi1"
+	"fmt"
+	"github.com/alyu/configparser"
+)
+
+func checkErr(err error) {
+	if err != nil {
+		panic(err)
+	}
+}
+
+func main() {
+	config, err := configparser.Read("/etc/sdapi.ini")
+	checkErr(err)
+
+	section, err := config.Section("sdapi1")
+	checkErr(err)
+
+	sdApi1.SetApiKey(section.ValueOf("api_key"))
+
+	units, err := sdApi1.GetUnits()
+	checkErr(err)
+
+	fmt.Printf("units == %v", units)
+}