diff --git a/calendar/calendar.go b/calendar/calendar.go index 08fc33ee..fca947b6 100644 --- a/calendar/calendar.go +++ b/calendar/calendar.go @@ -2,7 +2,6 @@ package calendar import ( "fmt" - "github.com/ManyakRus/starter/constants" "github.com/dromara/carbon/v2" "time" ) @@ -85,7 +84,7 @@ func (d *HoursMinutesSeconds) UnmarshalString(str string) error { } // parse string - t, err := time.Parse(constants.LayoutTime, str) + t, err := time.Parse(constants_starter.LayoutTime, str) if err != nil { err = fmt.Errorf("invalid time string: %s, error: %w", str, err) return err diff --git a/calendar/calendar_test.go b/calendar/calendar_test.go index 8f04db25..6ada560a 100644 --- a/calendar/calendar_test.go +++ b/calendar/calendar_test.go @@ -1,23 +1,22 @@ package calendar import ( - "github.com/ManyakRus/starter/constants" "testing" "time" ) func TestFindPreviousWorkDay(t *testing.T) { - Date := time.Date(2023, 03, 13, 0, 0, 0, 0, constants.Loc) + Date := time.Date(2023, 03, 13, 0, 0, 0, 0, constants_starter.Loc) Otvet := FindPreviousWorkDay(Date) - if Otvet != time.Date(2023, 03, 10, 0, 0, 0, 0, constants.Loc) { + if Otvet != time.Date(2023, 03, 10, 0, 0, 0, 0, constants_starter.Loc) { t.Error("TestFindPreviousWorkDay error") } } func TestIsWorkDay(t *testing.T) { - Date := time.Date(2023, 03, 19, 0, 0, 0, 0, constants.Loc) + Date := time.Date(2023, 03, 19, 0, 0, 0, 0, constants_starter.Loc) Otvet := IsWorkDay(Date) if Otvet != false { t.Error("TestIsWorkDay error") @@ -35,8 +34,8 @@ func TestHoursMinutesSeconds_UnmarshalByte(t *testing.T) { func TestDiff_dates(t *testing.T) { - Date1 := time.Date(2023, 03, 19, 0, 0, 0, 0, constants.Loc) - Date2 := time.Date(2023, 03, 20, 0, 0, 0, 0, constants.Loc) + Date1 := time.Date(2023, 03, 19, 0, 0, 0, 0, constants_starter.Loc) + Date2 := time.Date(2023, 03, 20, 0, 0, 0, 0, constants_starter.Loc) _, _, days, _, _, _ := Diff_dates(Date1, Date2) if days != 1 { t.Error("TestDiff_dates error") diff --git a/constants/constants.go b/constants_starter/constants_starter.go similarity index 97% rename from constants/constants.go rename to constants_starter/constants_starter.go index cb1f9ab3..decde002 100644 --- a/constants/constants.go +++ b/constants_starter/constants_starter.go @@ -1,5 +1,5 @@ // модуль для хранения постоянных переменных, констант -package constants +package constants_starter import ( "time" diff --git a/micro/microfunctions.go b/micro/microfunctions.go index 35991a00..6e02f2df 100644 --- a/micro/microfunctions.go +++ b/micro/microfunctions.go @@ -8,7 +8,7 @@ import ( "encoding/gob" "errors" "fmt" - "github.com/ManyakRus/starter/constants" + "github.com/ManyakRus/starter/constants_starter" "github.com/dromara/carbon/v2" "github.com/google/uuid" "golang.org/x/exp/constraints" @@ -36,7 +36,7 @@ import ( func init() { //время всегда московское (из константы) - carbon.SetLocation(constants.Loc) + carbon.SetLocation(constants_starter.Loc) } // IsTestApp - возвращает true если это тестовая среда выполнения приложения @@ -1682,7 +1682,7 @@ func IsTrueString(s string) bool { // DateTimeFromString_rus - возвращает дату из строки, из формата "02.01.2006 15:04:05" func DateTimeFromString_rus(s string) (time.Time, error) { - t, err := time.ParseInLocation(constants.LayoutDateTimeRus, s, constants.Loc) + t, err := time.ParseInLocation(constants_starter.LayoutDateTimeRus, s, constants_starter.Loc) return t, err } @@ -1695,7 +1695,7 @@ func DateFromString_rus(s string) (time.Time, error) { } // - t, err := time.ParseInLocation(constants.LayoutDateRus, s, constants.Loc) + t, err := time.ParseInLocation(constants_starter.LayoutDateRus, s, constants_starter.Loc) return t, err } diff --git a/micro/microfunctions_test.go b/micro/microfunctions_test.go index 140baa77..d58975e8 100644 --- a/micro/microfunctions_test.go +++ b/micro/microfunctions_test.go @@ -4,7 +4,6 @@ import ( "context" "errors" "fmt" - "github.com/ManyakRus/starter/constants" "github.com/ManyakRus/starter/contextmain" "github.com/google/uuid" "google.golang.org/protobuf/types/known/timestamppb" @@ -1503,8 +1502,8 @@ func TestDateFromToToday_rus(t *testing.T) { } func TestStringDatePeriod_rus(t *testing.T) { - Date1 := time.Date(2025, 04, 01, 0, 0, 0, 0, constants.Loc) - Date2 := time.Date(2025, 04, 23, 0, 0, 0, 0, constants.Loc) + Date1 := time.Date(2025, 04, 01, 0, 0, 0, 0, constants_starter.Loc) + Date2 := time.Date(2025, 04, 23, 0, 0, 0, 0, constants_starter.Loc) Otvet := StringDatePeriod_rus(Date1, Date2) if Otvet == "" { t.Errorf("error: Expected not empty string, but got %s", Otvet) @@ -1512,8 +1511,8 @@ func TestStringDatePeriod_rus(t *testing.T) { } func TestStringDateSPo_rus(t *testing.T) { - Date1 := time.Date(2025, 04, 01, 0, 0, 0, 0, constants.Loc) - Date2 := time.Date(2025, 04, 23, 0, 0, 0, 0, constants.Loc) + Date1 := time.Date(2025, 04, 01, 0, 0, 0, 0, constants_starter.Loc) + Date2 := time.Date(2025, 04, 23, 0, 0, 0, 0, constants_starter.Loc) Otvet := StringDateSPo_rus(Date1, Date2) if Otvet == "" { t.Errorf("error: Expected not empty string, but got %s", Otvet) diff --git a/microl/microl.go b/microl/microl.go index 198a9316..6b488534 100644 --- a/microl/microl.go +++ b/microl/microl.go @@ -4,7 +4,6 @@ package microl import ( "fmt" - "github.com/ManyakRus/starter/constants" "github.com/ManyakRus/starter/log" "github.com/ManyakRus/starter/micro" "os" @@ -127,7 +126,7 @@ func Set_FieldFromEnv_Int32(StructReference any, FieldName string, IsRequired bo func Set_FieldFromEnv_Time(StructReference any, FieldName string, IsRequired bool) { sValue := Getenv(FieldName, IsRequired) - Value, err := time.Parse(constants.LayoutDateTimeRus, sValue) + Value, err := time.Parse(constants_starter.LayoutDateTimeRus, sValue) if err != nil { err = fmt.Errorf("time.Parse() FieldName: %s error: %w", FieldName, err) log.Error(err) @@ -151,7 +150,7 @@ func Set_FieldFromEnv_Time(StructReference any, FieldName string, IsRequired boo func Set_FieldFromEnv_Date(StructReference any, FieldName string, IsRequired bool) { sValue := Getenv(FieldName, IsRequired) - Value, err := time.Parse(constants.LayoutDateRus, sValue) + Value, err := time.Parse(constants_starter.LayoutDateRus, sValue) if err != nil { err = fmt.Errorf("time.Parse() FieldName: %s error: %w", FieldName, err) log.Error(err) diff --git a/microl/microl_test.go b/microl/microl_test.go index 1d0b031b..60c9784e 100644 --- a/microl/microl_test.go +++ b/microl/microl_test.go @@ -1,7 +1,6 @@ package microl import ( - "github.com/ManyakRus/starter/constants" "os" "testing" "time" @@ -80,7 +79,7 @@ func TestSet_FieldFromEnv_Time(t *testing.T) { } sTime := "02.01.2000 00:00:00" - Time1, err := time.Parse(constants.LayoutDateTimeRus, sTime) + Time1, err := time.Parse(constants_starter.LayoutDateTimeRus, sTime) if err != nil { t.Error("TestSet_FieldFromEnv_Time() error") } @@ -103,7 +102,7 @@ func TestSet_FieldFromEnv_Date(t *testing.T) { } sTime := "02.01.2000" - Time1, err := time.Parse(constants.LayoutDateRus, sTime) + Time1, err := time.Parse(constants_starter.LayoutDateRus, sTime) if err != nil { t.Error("TestSet_FieldFromEnv_Date() error") } diff --git a/nats_connect/nats_connect_test.go b/nats_connect/nats_connect_test.go index 5d91e6f5..609b0901 100644 --- a/nats_connect/nats_connect_test.go +++ b/nats_connect/nats_connect_test.go @@ -3,7 +3,6 @@ package nats_connect import ( "context" "github.com/ManyakRus/starter/config_main" - "github.com/ManyakRus/starter/constants" "github.com/ManyakRus/starter/contextmain" "github.com/ManyakRus/starter/micro" "testing" @@ -16,7 +15,7 @@ import ( func TestConnect_err(t *testing.T) { //ProgramDir := micro.ProgramDir_Common() config_main.LoadEnv() - err := Connect_err(constants.SERVICE_NAME + "_test") + err := Connect_err(constants_starter.SERVICE_NAME + "_test") if err != nil { t.Error("nats_connect.TestConnect_err() error: ", err) } @@ -26,14 +25,14 @@ func TestConnect_err(t *testing.T) { func TestCloseConnection(t *testing.T) { //ProgramDir := micro.ProgramDir_Common() config_main.LoadEnv() - Connect(constants.SERVICE_NAME + "_test") + Connect(constants_starter.SERVICE_NAME + "_test") CloseConnection() } func TestStartNats(t *testing.T) { //ProgramDir := micro.ProgramDir_Common() config_main.LoadEnv() - StartNats(constants.SERVICE_NAME + "_test") + StartNats(constants_starter.SERVICE_NAME + "_test") micro.Pause(20) _ = contextmain.GetContext() @@ -59,14 +58,14 @@ func TestWaitStop(t *testing.T) { func TestConnect(t *testing.T) { config_main.LoadEnv() - Connect(constants.SERVICE_NAME + "_test") + Connect(constants_starter.SERVICE_NAME + "_test") defer CloseConnection() } func TestSendMessageCtx(t *testing.T) { config_main.LoadEnv() - Connect(constants.SERVICE_NAME + "_test") + Connect(constants_starter.SERVICE_NAME + "_test") defer CloseConnection() ctxMain := contextmain.GetContext() diff --git a/nats_liveness/nats_liveness_test.go b/nats_liveness/nats_liveness_test.go index f5e8e77c..2ee0db60 100644 --- a/nats_liveness/nats_liveness_test.go +++ b/nats_liveness/nats_liveness_test.go @@ -2,7 +2,6 @@ package nats_liveness import ( "github.com/ManyakRus/starter/config_main" - "github.com/ManyakRus/starter/constants" "github.com/ManyakRus/starter/micro" "testing" ) @@ -12,7 +11,7 @@ var SERVICE_NAME_TEST = "starter_test" func TestConnect(t *testing.T) { config_main.LoadEnv() FillSettings(SERVICE_NAME_TEST) - Connect(constants.SERVICE_NAME + "_test") + Connect(constants_starter.SERVICE_NAME + "_test") CloseConnection() } @@ -20,7 +19,7 @@ func TestConnect(t *testing.T) { func TestSendMessage(t *testing.T) { config_main.LoadEnv() FillSettings(SERVICE_NAME_TEST) - Connect(constants.SERVICE_NAME + "_test") + Connect(constants_starter.SERVICE_NAME + "_test") SendMessage() } diff --git a/postgres_gorm/postgres_gorm.go b/postgres_gorm/postgres_gorm.go index 556648ea..b48bc4ad 100644 --- a/postgres_gorm/postgres_gorm.go +++ b/postgres_gorm/postgres_gorm.go @@ -6,7 +6,7 @@ import ( "context" "errors" "fmt" - "github.com/ManyakRus/starter/constants" + "github.com/ManyakRus/starter/constants_starter" "github.com/ManyakRus/starter/log" "github.com/ManyakRus/starter/port_checker" "strings" @@ -409,7 +409,7 @@ func GetDSN(ApplicationName string) string { dsn += "password=" + Settings.DB_PASSWORD + " " dsn += "dbname=" + Settings.DB_NAME + " " dsn += "port=" + Settings.DB_PORT + " " - dsn += "sslmode=disable TimeZone=" + constants.TIME_ZONE + " " + dsn += "sslmode=disable TimeZone=" + constants_starter.TIME_ZONE + " " dsn += "application_name=" + ApplicationName return dsn diff --git a/postgres_gorm2/postgres_gorm2.go b/postgres_gorm2/postgres_gorm2.go index 6362ca9f..ab18e315 100644 --- a/postgres_gorm2/postgres_gorm2.go +++ b/postgres_gorm2/postgres_gorm2.go @@ -8,7 +8,6 @@ import ( "context" "errors" "fmt" - "github.com/ManyakRus/starter/constants" "github.com/ManyakRus/starter/log" "github.com/ManyakRus/starter/port_checker" "strings" @@ -408,7 +407,7 @@ func GetDSN(ApplicationName string) string { dsn += "password=" + Settings.DB_PASSWORD + " " dsn += "dbname=" + Settings.DB_NAME + " " dsn += "port=" + Settings.DB_PORT + " " - dsn += "sslmode=disable TimeZone=" + constants.TIME_ZONE + " " + dsn += "sslmode=disable TimeZone=" + constants_starter.TIME_ZONE + " " dsn += "application_name=" + ApplicationName return dsn diff --git a/postgres_pgx/postgres_pgx.go b/postgres_pgx/postgres_pgx.go index f6d1bc85..b7147fc5 100644 --- a/postgres_pgx/postgres_pgx.go +++ b/postgres_pgx/postgres_pgx.go @@ -6,7 +6,6 @@ import ( "context" "errors" "fmt" - "github.com/ManyakRus/starter/constants" "github.com/ManyakRus/starter/log" "github.com/ManyakRus/starter/port_checker" "github.com/jackc/pgx/v5" @@ -149,7 +148,7 @@ func GetConnectionString(ApplicationName string) string { dsn += "user=" + Settings.DB_USER + " " dsn += "password=" + Settings.DB_PASSWORD + " " dsn += "dbname=" + Settings.DB_NAME + " " - dsn += "port=" + Settings.DB_PORT + " sslmode=disable TimeZone=" + constants.TIME_ZONE + " " + dsn += "port=" + Settings.DB_PORT + " sslmode=disable TimeZone=" + constants_starter.TIME_ZONE + " " dsn += "application_name=" + ApplicationName + " " dsn += "search_path=" + Settings.DB_SCHEMA + " " diff --git a/postgres_pgxpool/postgres_pgxpool.go b/postgres_pgxpool/postgres_pgxpool.go index 00d0949a..aac0838b 100644 --- a/postgres_pgxpool/postgres_pgxpool.go +++ b/postgres_pgxpool/postgres_pgxpool.go @@ -6,7 +6,6 @@ import ( "context" "errors" "fmt" - "github.com/ManyakRus/starter/constants" "github.com/ManyakRus/starter/log" "github.com/ManyakRus/starter/port_checker" "github.com/ManyakRus/starter/postgres_pgtype" @@ -149,7 +148,7 @@ func GetConnectionString(ApplicationName string) string { dsn += "user=" + Settings.DB_USER + " " dsn += "password=" + Settings.DB_PASSWORD + " " dsn += "dbname=" + Settings.DB_NAME + " " - dsn += "port=" + Settings.DB_PORT + " sslmode=disable TimeZone=" + constants.TIME_ZONE + " " + dsn += "port=" + Settings.DB_PORT + " sslmode=disable TimeZone=" + constants_starter.TIME_ZONE + " " dsn += "application_name=" + ApplicationName + " " dsn += "search_path=" + Settings.DB_SCHEMA + " " diff --git a/postgres_stek/postgres_stek_test.go b/postgres_stek/postgres_stek_test.go index 7ffc56b8..ce91e283 100644 --- a/postgres_stek/postgres_stek_test.go +++ b/postgres_stek/postgres_stek_test.go @@ -2,7 +2,6 @@ package postgres_stek import ( "errors" - "github.com/ManyakRus/starter/constants" "gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/db/tables/table_connections" "gitlab.aescorp.ru/dsp_dev/claim/sync_service/pkg/object_model/entities/connections" "testing" @@ -18,7 +17,7 @@ import ( ) // CONNECTION - объект Соединение, настроенный -var CONNECTION = connections.Connection{Table_Connection: table_connections.Table_Connection{ID: constants.CONNECTION_ID, BranchID: constants.BRANCH_ID, IsLegal: true, Server: "10.1.9.153", Port: "5432", DbName: "kol_atom_ul_uni", DbScheme: "stack", Login: "", Password: ""}} +var CONNECTION = connections.Connection{Table_Connection: table_connections.Table_Connection{ID: constants_starter.CONNECTION_ID, BranchID: constants_starter.BRANCH_ID, IsLegal: true, Server: "10.1.9.153", Port: "5432", DbName: "kol_atom_ul_uni", DbScheme: "stack", Login: "", Password: ""}} func TestConnect_err(t *testing.T) { //Connect_Panic()