diff --git a/micro/microfunctions.go b/micro/microfunctions.go index 0ade0bfe..824f789e 100644 --- a/micro/microfunctions.go +++ b/micro/microfunctions.go @@ -2034,3 +2034,25 @@ func Time_DefaultNil(Value time.Time) *time.Time { } return &Value } + +// IsWindows - возвращает true если операционная система = windows +func IsWindows() bool { + Otvet := false + + if runtime.GOOS == "windows" { + Otvet = true + } + + return Otvet +} + +// Path_Linux_to_Windows - заменяет / на \, для правильных путей файлов +func Path_Linux_to_Windows(s string) string { + Otvet := s + + if IsWindows() == true { + Otvet = strings.ReplaceAll(Otvet, `/`, `\`) + } + + return Otvet +} diff --git a/micro/microfunctions_test.go b/micro/microfunctions_test.go index 1224b0fa..6d3830bc 100644 --- a/micro/microfunctions_test.go +++ b/micro/microfunctions_test.go @@ -1824,3 +1824,14 @@ func TestTime_DefaultNil(t *testing.T) { t.Errorf("Expected %v, but got %v", now, *Otvet) } } + +func TestIsWindows(t *testing.T) { + Otvet := IsWindows() + t.Log("IsWindows(): ", Otvet) +} + +func TestPath_Linux_to_Windows(t *testing.T) { + s := "test/1" + Otvet := Path_Linux_to_Windows(s) + t.Log("Path_Linux_to_Windows(): ", Otvet) +}