github.com/mkasner/goat@v0.0.0-20190419083224-77b17249a8e3/context/context.go (about)

     1  package context
     2  
     3  import "os"
     4  
     5  // Context represents a context of a process.
     6  type Context struct {
     7  	Wd       string
     8  	Config   *Config
     9  	Interval int
    10  }
    11  
    12  // NewContext generates a Context and returns it.
    13  func NewContext(interval int) (*Context, error) {
    14  	wd, err := os.Getwd()
    15  	if err != nil {
    16  		return nil, err
    17  	}
    18  	config, err := NewConfig()
    19  	if err != nil {
    20  		return nil, err
    21  	}
    22  	return &Context{Wd: wd, Config: config, Interval: interval}, nil
    23  }