fcounter

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2019 License: MIT Imports: 6 Imported by: 1

README

fcounter

Work with counter in a text file

Install

go get github.com/belfinor/fcounter

Usage

package main

import (
  "fmt"
  "time"

  "github.com/belfinor/fcounter"
)

func main() {

  // 0 if no file or last value
  // val = val % 100000000
  cnt := fcounter.New("counter.txt", 100000000)

  cnt.Set(0)

  fmt.Println(cnt.Get()) // 0

  for i := 0 ; i < 10 ; i++ {
    // inc = ( inc + 1 ) % 100000000
    fmt.Println( cnt.Inc() ) // i + 1
  }

  cnt.SetDate(time.Now()) // val = YYYYMMDD
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Counter

type Counter struct {
	// contains filtered or unexported fields
}

func New

func New(filename string, mod int64) *Counter

func (*Counter) Get

func (c *Counter) Get() int64

func (*Counter) Inc

func (c *Counter) Inc() int64

func (*Counter) Set

func (c *Counter) Set(val int64)

func (*Counter) SetDate

func (c *Counter) SetDate(t time.Time)

Jump to

Keyboard shortcuts

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