oss

package
v1.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2023 License: MIT Imports: 6 Imported by: 20

README

oss

操作系统相关函数。

goos

IsDarwin

是否是 Darwin 系统

IsLinux

是否是 Linux 系统

IsWindows

是否是 Windows 系统

os

Open

打开文件

Show

在目录中显示

path

Abs

返回路径的绝对表示,~符号表示用户根目录。

Exist

文件或目录是否存在。

IsDir

路径是否是目录。

Documentation

Overview

Package oss 操作系统相关.

Index

Examples

Constants

View Source
const (
	DefaultFileMode   os.FileMode = 0o664
	DefaultDirFileMod os.FileMode = 0o771
)

Variables

View Source
var ErrNotDefined = errors.New("OS is not defined")

ErrNotDefined 系统不支持.

Functions

func Abs

func Abs(path string) (string, error)

Abs 返回路径的绝对表示,~符号表示用户根目录.

Example
package main

import (
	"fmt"
	"os"
	"path/filepath"

	"github.com/samber/lo"
	"github.com/xuender/kit/oss"
)

func main() {
	home, _ := os.UserHomeDir()
	fmt.Println(lo.Must1(oss.Abs("~/file")) == filepath.Join(home, "file"))

}
Output:

true

func Exist

func Exist(path string) bool

Exist 文件或目录是否存在.

func IsDarwin

func IsDarwin() bool

IsDarwin 是否是 Darwin 系统.

Example
package main

import (
	"fmt"

	"github.com/xuender/kit/oss"
)

func main() {
	fmt.Println(oss.IsDarwin())

}
Output:

false

func IsDir

func IsDir(path string) bool

IsDir 路径是否是目录.

func IsLinux

func IsLinux() bool

IsLinux 是否是 Linux 系统.

Example
package main

import (
	"fmt"

	"github.com/xuender/kit/oss"
)

func main() {
	fmt.Println(oss.IsLinux())

}
Output:

true

func IsWindows

func IsWindows() bool

IsWindows 是否是 Windows 系统.

Example
package main

import (
	"fmt"

	"github.com/xuender/kit/oss"
)

func main() {
	fmt.Println(oss.IsWindows())

}
Output:

false

func Open

func Open(file string) error

Open 打开文件.

func Show

func Show(file string) error

Show 在目录中显示.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL