files

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: MIT Imports: 2 Imported by: 1

README

File Examples

Get file content

package main

import (
  "fmt"
  "log"

  "github.com/D3Ext/maldev/files"
)

func main(){
  content, err := files.GetFileContent("/path/to/file.txt")
  if err != nil {
    log.Fatal(err)
  }

  fmt.Println(content)
}

Check if file exists

package main

import (
  "fmt"

  "github.com/D3Ext/maldev/file"
)

func main(){
  check := files.Exists("/path/to/file")
  fmt.Println(check) // true or false
}

Check if path is a file

package main

import (
  "fmt"

  "github.com/D3Ext/maldev/files"
)

func main(){
  check := files.IsFile("/path/to/file")
  fmt.Println(check)
}

Check if path is a directory

package main

import (
  "fmt"

  "github.com/D3Ext/maldev/files"
)

func main(){
  check := files.IsDir("/path/to/dir")
  fmt.Println(check)
}

Copy a file or dir recursively

package main

import (
  "log"

  "github.com/D3Ext/maldev/files"
)

func main(){
  err := files.Copy("/path/to/file.txt", "/path/to/destination")
  if err != nil {
    log.Fatal(err)
  }
}

Move a file or dir

package main

import (
  "log"

  "github.com/D3Ext/maldev/files"
)

func main(){
  err := files.Move("/path/to/file.txt", "/path/to/destination/file.txt")
  if err != nil {
    log.Fatal(err)
  }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy

func Copy(src string, dst string) error

func Exists

func Exists(src string) bool

func GetContent added in v0.1.2

func GetContent(src string) (string, error)

func IsDir

func IsDir(src string) (bool, error)

func IsFile

func IsFile(src string) (bool, error)

func Move added in v0.1.2

func Move(src string, dst string) error

func WriteContent added in v0.1.2

func WriteContent(filename string, text string) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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