kfiles

package module
v0.0.0-...-1e6aa10 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2017 License: Apache-2.0 Imports: 7 Imported by: 1

README

kfiles

Go文件操作 - Go学习实例

Get:
go get github.com/keesely/kfiles
Usage:
 import (
     "fmt"
     "github.com/keesely/kfiles"
 )
 
 // 写入文本
 _, err := kfiles.Put("./test.txt", "这是一段测试文本")
  if err != nil {
    fmt.Println(err)
  } else {
    fmt.Println("文本写入")
  }

  // 追加写入
  _, err = kfiles.Append("./test.txt", "\n追加一段文本")

  if err != nil {
    fmt.Println(err)
  } else {
    fmt.Println("文本追加")
  }

  // 判断是否存在
  exists := kfiles.Exists("./test.txt")

  if true == exists {
    fmt.Println("文件已存在")

    // 获取文本内容
    content, _ := kfiles.Get("./test.txt")
    
    fmt.Println("文本内容: \n```\n", content, "\n```");

  } else {
    fmt.Println("文件不存在")
  }

Documentation

Overview

************************************************************************

> File Name: file.go
> Author: Kee
> Mail: chinboy2012@gmail.com
> Created Time: 2017.11.29

***********************************************************************

************************************************************************ > File Name: file_search.go > Author: Kee > Mail: chinboy2012@gmail.com > Created Time: 2017.12.13 ***********************************************************************

Index

Constants

View Source
const (
	APPEND = 1
)

Variables

This section is empty.

Functions

func Append

func Append(file string, content string) (bool, error)

func Exists

func Exists(file string) bool

func FindFile

func FindFile(fileName string) ([]string, error)

func Get

func Get(file string) (string, error)

func Put

func Put(file string, content string) (bool, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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