1
0
mirror of https://github.com/ManyakRus/starter.git synced 2024-11-21 18:16:31 +02:00

сделал packages.jpg

This commit is contained in:
Nikitin Aleksandr 2023-09-13 13:48:19 +03:00
parent d86504a070
commit 4ee2118a36
11 changed files with 4241 additions and 32 deletions

View File

@ -1,5 +1,5 @@
SERVICEURL=gitlab.aescorp.ru/dsp_dev/claim/nikitin
SERVICEURL2=github.com/ManyakRus/starter
SERVICENAME=nikitin
SERVICEURL=gitlab.aescorp.ru/dsp_dev/claim/$(SERVICENAME)
FILEMAIN=./internal/v0/app/main.go
FILEAPP=./bin/app_race
@ -35,10 +35,12 @@ test.run:
go fmt ./...
go test -coverprofile cover.out ./...
go tool cover -func=cover.out
graph:
goda graph -f "{{.Package.Name}}" "shared($(SERVICEURL)/... $(SERVICEURL2)/...)" | dot -Tsvg -o graph.svg
dot:
goda graph -f "{{.Package.Name}}" "shared($(SERVICEURL)/... $(SERVICEURL2)/...)" >graph.dot
newrepo:
sed -i 's+$(SERVICEURL)+$(NEW_REPO)+g' go.mod
find -name *.go -not -path "*/vendor/*"|xargs sed -i 's+$(SERVICEURL)+$(NEW_REPO)+g'
graph:
clear
image_packages ./ docs/packages.graphml
conn:
clear
image_connections ./ docs/connections.graphml $(SERVICENAME)

View File

@ -3,11 +3,9 @@
package config
import (
"github.com/joho/godotenv"
"github.com/ManyakRus/starter/logger"
"github.com/ManyakRus/starter/micro"
"os"
"github.com/joho/godotenv"
//log "github.com/sirupsen/logrus"
//log "github.com/sirupsen/logrus"
//"gitlab.aescorp.ru/dsp_dev/notifier/notifier_adp_eml/internal/v0/app/types"
@ -30,15 +28,15 @@ func LoadEnv_from_file(filename string) {
err := godotenv.Load(filename)
if err != nil {
log.Debug("Can not parse .env file: ", filename, " error: "+err.Error())
log.Debug("Can not parse .env file: ", filename, " warning: "+err.Error())
} else {
log.Info("load .env from file: ", filename)
}
LOG_LEVEL := os.Getenv("LOG_LEVEL")
if LOG_LEVEL == "" {
LOG_LEVEL = "info"
}
logger.SetLevel(LOG_LEVEL)
//LOG_LEVEL := os.Getenv("LOG_LEVEL")
//if LOG_LEVEL == "" {
// LOG_LEVEL = "info"
//}
//logger.SetLevel(LOG_LEVEL)
}

4094
docs/packages.graphml Normal file

File diff suppressed because it is too large Load Diff

BIN
docs/packages.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 387 KiB

View File

@ -50,7 +50,12 @@ func FillSettings() {
}
if Settings.WEBSERVER_PORT == "" {
log.Info("Need fill WEBSERVER_PORT ! in OS Environment ")
Settings.WEBSERVER_HOST = os.Getenv("WEB_SERVER_HOST")
Settings.WEBSERVER_PORT = os.Getenv("WEB_SERVER_PORT")
}
if Settings.WEBSERVER_PORT == "" {
log.Warn("Need fill WEBSERVER_PORT ! in OS Environment ")
Settings.WEBSERVER_PORT = "3002"
}

View File

@ -30,6 +30,10 @@ func FindFoldersTree(dir string, NeedFolders, NeedFiles, NeedDot bool, exclude s
var tree *Folder
var nodes = map[string]interface{}{}
var walkFun filepath.WalkFunc = func(p string, info os.FileInfo, err error) error {
if info == nil {
return nil
}
if info.IsDir() {
nodes[p] = &Folder{p, path.Base(p), []*File{}, map[string]*Folder{}}
} else {

View File

@ -73,7 +73,7 @@ func SetLevel(LOG_LEVEL string) {
}
if LOG_LEVEL == "" {
LOG_LEVEL = "info"
LOG_LEVEL = "debug"
}
level, err := logrus.ParseLevel(LOG_LEVEL)
if err != nil {

View File

@ -200,7 +200,12 @@ func CurrentFilename() string {
// ProgramDir - возвращает главный каталог программы, в конце "/"
func ProgramDir_Common() string {
filename := os.Args[0]
//filename := os.Args[0]
filename, err := os.Executable()
if err != nil {
panic(err)
}
dir := filepath.Dir(filename)
sdir := strings.ToLower(dir)
@ -593,7 +598,7 @@ func SaveTempFile_err(bytes []byte) (string, error) {
// close and remove the temporary file at the end of the program
defer f.Close()
defer os.Remove(f.Name())
//defer os.Remove(f.Name())
// write data to the temporary file
if _, err := f.Write(bytes); err != nil {
@ -627,3 +632,63 @@ func TextError(err error) string {
func GetType(myvar interface{}) string {
return reflect.TypeOf(myvar).String()
}
// FindFileNameShort - возвращает имя файла(каталога) без пути
func FindFileNameShort(path string) string {
Otvet := ""
if path == "" {
return Otvet
}
Otvet = filepath.Base(path)
return Otvet
}
// CurrentDirectory - возвращает текущую директорию ОС
func CurrentDirectory() string {
Otvet, err := os.Getwd()
if err != nil {
//log.Println(err)
}
return Otvet
}
// BoolFromInt64 - возвращает true если число <>0
func BoolFromInt64(i int64) bool {
Otvet := false
if i != 0 {
Otvet = true
}
return Otvet
}
// BoolFromInt - возвращает true если число <>0
func BoolFromInt(i int) bool {
Otvet := false
if i != 0 {
Otvet = true
}
return Otvet
}
// DeleteFileSeperator - убирает в конце / или \
func DeleteFileSeperator(dir string) string {
Otvet := dir
len1 := len(Otvet)
if len1 == 0 {
return Otvet
}
LastWord := Otvet[len1-1 : len1]
if LastWord == SeparatorFile() {
Otvet = Otvet[0 : len1-1]
}
return Otvet
}

View File

@ -327,3 +327,42 @@ func TestGetType(t *testing.T) {
t.Error("TestGetType() error: Otvet: ", Otvet)
}
}
func TestFindFileNameShort(t *testing.T) {
dir := ProgramDir()
Otvet := FindFileNameShort(dir)
if Otvet == "" {
t.Error("TestFindFileNameShort() error: Otvet =''")
}
}
func TestCurrentDirectory(t *testing.T) {
Otvet := CurrentDirectory()
if Otvet == "" {
t.Error("TestCurrentDirectory() error: Otvet = ''")
}
}
func TestBoolFromInt64(t *testing.T) {
Otvet := BoolFromInt64(111)
if Otvet != true {
t.Error("TestBoolFromInt64() error: Otvet != true")
}
}
func TestBoolFromInt(t *testing.T) {
Otvet := BoolFromInt(111)
if Otvet != true {
t.Error("TestBoolFromInt64() error: Otvet != true")
}
}
func TestDeleteFileSeperator(t *testing.T) {
dir := "home" + SeparatorFile()
dir = DeleteFileSeperator(dir)
if dir != "home" {
t.Error("TestDeleteFileSeperator() error")
}
}

View File

@ -305,7 +305,7 @@ func UploadFileCtx_err(ctx context.Context, bucketName, objectName, filePath str
return "", fmt.Errorf("UploadFile, error: %w", err)
}
log.Infof("[INFO] UploadFile, Successfully upload file: %q, size: %d, tag: %s\n", objectName, info.Size, info.ETag)
log.Debugf("UploadFile, Successfully upload file: %q, size: %d, tag: %s\n", objectName, info.Size, info.ETag)
return info.ETag, nil
}
@ -345,15 +345,17 @@ func DownloadFileCtx_err(ctx context.Context, bucketName, objectName string) ([]
Object, err := Conn.GetObject(ctx, bucketName, objectName, miniogo.GetObjectOptions{})
if err != nil {
log.Panic("GetObject() error: ", err)
return Otvet, fmt.Errorf("DownloadFileCtx_err(), error: %w", err)
//log.Panic("GetObject() error: ", err)
//return Otvet, fmt.Errorf("DownloadFileCtx_err(), error: %w", err)
return Otvet, err
}
defer Object.Close()
//count, err := Object.Read(Otvet)
Otvet, err = io.ReadAll(Object)
if err != nil {
log.Panic("minio Read() error: ", err)
//log.Panic("minio Read() error: ", err)
//return Otvet, err
return Otvet, err
}
if len(Otvet) == 0 {

View File

@ -260,15 +260,15 @@ func FillSettings() {
Settings.DB_USER = os.Getenv("DB_USER")
Settings.DB_PASSWORD = os.Getenv("DB_PASSWORD")
// заполним из переменных оуружения как у Нечаева
if Settings.DB_HOST == "" {
Settings.DB_HOST = os.Getenv("STORE_HOST")
Settings.DB_PORT = os.Getenv("STORE_PORT")
Settings.DB_NAME = os.Getenv("STORE_NAME")
Settings.DB_SCHEMA = os.Getenv("STORE_SCHEME")
Settings.DB_USER = os.Getenv("STORE_LOGIN")
Settings.DB_PASSWORD = os.Getenv("STORE_PASSWORD")
}
//// заполним из переменных оуружения как у Нечаева
//if Settings.DB_HOST == "" {
// Settings.DB_HOST = os.Getenv("STORE_HOST")
// Settings.DB_PORT = os.Getenv("STORE_PORT")
// Settings.DB_NAME = os.Getenv("STORE_NAME")
// Settings.DB_SCHEMA = os.Getenv("STORE_SCHEME")
// Settings.DB_USER = os.Getenv("STORE_LOGIN")
// Settings.DB_PASSWORD = os.Getenv("STORE_PASSWORD")
//}
if Settings.DB_HOST == "" {
log.Panicln("Need fill DB_HOST ! in os.ENV ")