From 6557709b79027a167e8fe95c80f7188c91994428 Mon Sep 17 00:00:00 2001 From: weishao Date: Thu, 9 Mar 2023 09:44:24 +0800 Subject: [PATCH] inti --- src/main/go-mod/excel.go | 48 --------------------------------------- src/main/go-mod/func.go | 24 -------------------- src/main/go-mod/main.go | 6 ----- src/main/go-mod/struct.go | 7 ------ 4 files changed, 85 deletions(-) delete mode 100644 src/main/go-mod/excel.go delete mode 100644 src/main/go-mod/func.go delete mode 100644 src/main/go-mod/main.go delete mode 100644 src/main/go-mod/struct.go diff --git a/src/main/go-mod/excel.go b/src/main/go-mod/excel.go deleted file mode 100644 index 1bfb4a0..0000000 --- a/src/main/go-mod/excel.go +++ /dev/null @@ -1,48 +0,0 @@ -package excel - -import ( - "fmt" - "reflect" - - "github.com/360EntSecGroup-Skylar/excelize" -) - -// WriteXlsx 生成表格到本地服务器 -func WriteXlsx(sheet string, records interface{}) *excelize.File { - f := excelize.NewFile() // new file - index := f.NewSheet(sheet) // new sheet - f.SetActiveSheet(index) // set active (default) sheet - firstCharacter := 65 // start from 'A' line - t := reflect.TypeOf(records) - - if t.Kind() != reflect.Slice { - return f - } - - s := reflect.ValueOf(records) - for i := 0; i < s.Len(); i++ { - elem := s.Index(i).Interface() - elemType := reflect.TypeOf(elem) - elemValue := reflect.ValueOf(elem) - for j := 0; j < elemType.NumField(); j++ { - field := elemType.Field(j) - // 结构体中xlsx 类似json - tag := field.Tag.Get("xlsx") - name := tag - column := string(firstCharacter + j) - if tag == "" { - continue - } - // 设置表头 - if i == 0 { - f.SetCellValue(sheet, fmt.Sprintf("%s%d", column, i+1), name) - } - // 设置列宽 - f.SetColWidth(sheet, "A", fmt.Sprintf("%s", column), 20) - - // 设置内容 - f.SetCellValue(sheet, fmt.Sprintf("%s%d", column, i+2), elemValue.Field(j).Interface()) - } - } - return f -} diff --git a/src/main/go-mod/func.go b/src/main/go-mod/func.go deleted file mode 100644 index d88120a..0000000 --- a/src/main/go-mod/func.go +++ /dev/null @@ -1,24 +0,0 @@ -package main - -import "fmt" - -type Publisher struct { - name string - address string -} -type Book struct { - title, name string - publisher Publisher -} - -func main() { - var book = Book{"title","name",Publisher{"pub","beijing"}} - /* 这是我的第一个简单的程序 */ - fmt.Println("Hello, World!") - fmt.Println(book) - -} - -func test (book Book) (b1 Book, b2 Book){ - return book,book -} \ No newline at end of file diff --git a/src/main/go-mod/main.go b/src/main/go-mod/main.go deleted file mode 100644 index 7ac7c81..0000000 --- a/src/main/go-mod/main.go +++ /dev/null @@ -1,6 +0,0 @@ -package main - -func main(){ - printf('hello wold') - io.out('ok') -} \ No newline at end of file diff --git a/src/main/go-mod/struct.go b/src/main/go-mod/struct.go deleted file mode 100644 index 1de4533..0000000 --- a/src/main/go-mod/struct.go +++ /dev/null @@ -1,7 +0,0 @@ -package test -type Books struct { - title string - author string - subject string - book_id int -}