Skip to content

Commit

Permalink
Merge pull request #80 from dyweb/config/v1/deprecated
Browse files Browse the repository at this point in the history
[config] Deprecated config (v1) package
  • Loading branch information
at15 authored Aug 8, 2018
2 parents f0644e8 + 0066ca3 commit 1eed5cf
Show file tree
Hide file tree
Showing 27 changed files with 103 additions and 76 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## v0.0.7

[release](https://github.com/dyweb/gommon/releases/tag/0.0.7)

- deprecated config v1, move it to legacy folder
- move cast into util

## v0.0.6

[release](https://github.com/dyweb/gommon/releases/tag/0.0.6)

- improve doc, fix typo

## v0.0.5

[release](https://github.com/dyweb/gommon/releases/tag/0.0.5)
Expand Down
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
PKGS=./cast/... ./config/... ./errors/... ./generator/... ./log/... ./noodle/... ./requests/... ./structure/... ./util/...
PKGST=./cast ./cmd ./config ./errors ./generator ./log ./noodle ./requests ./structure ./util
VERSION = 0.0.1
PKGS=./errors/... ./generator/... ./log/... ./noodle/... ./requests/... ./structure/... ./util/...
PKGST=./cmd ./errors ./generator ./log ./noodle ./requests ./structure ./util
VERSION = 0.0.7
BUILD_COMMIT = $(shell git rev-parse HEAD)
BUILD_TIME = $(shell date +%Y-%m-%dT%H:%M:%S%z)
CURRENT_USER = $(USER)
FLAGS = -X main.version=$(VERSION) -X main.commit=$(BUILD_COMMIT) -X main.buildTime=$(BUILD_TIME) -X main.buildUser=$(CURRENT_USER)

# TODO: define help messages

.PHONY: install
install:
go install -ldflags "$(FLAGS)" ./cmd/gommon
Expand Down Expand Up @@ -52,7 +54,7 @@ update-dep:
#--- docker ---#
.PHONY: docker-test
docker-test:
docker-compose -f scripts/docker-compose.yml run --rm golang1.9
docker-compose -f scripts/docker-compose.yml run --rm golang1.10
docker-compose -f scripts/docker-compose.yml run --rm golanglatest

.PHONY: docker-remove-all-containers
Expand Down
34 changes: 1 addition & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Gommon is a collection of common util libraries written in Go.

It has the following components:

- [config](config) A YAML config reader with template support
- [errors](errors) Typed error with context, multi error
- [generator](generator) Render go template, generate methods for logger interface based on `gommon.yml`
- [log](log) A Javaish logger for Go, application can set level for their dependencies based on package, struct
Expand All @@ -24,6 +23,7 @@ It has the following components:

Legacy

- [config v1](config) A YAML config reader with template support
- [log v1](legacy/log) A logrus like structured logger
- [Runner](legacy/runner) A os/exec wrapper

Expand All @@ -49,38 +49,6 @@ Removed
- `dep ensure`
- `make test`

### Roadmap

0.0.7

- [x] test coverage for multiple packages
- [ ] explain internals of some implementation
- [ ] start documenting the style for writing gommon itself, lib using gommon, app using gommon/lib using gommon
- [ ] improve Makefile and dockerized build & test

0.0.8

- [ ] more complex error interface, error code
- [ ] organized error types
- [ ] extension for collecting errors using third party services
- [ ] init go mod support, not sure if it will be compatible with dep

0.0.9

- [ ] tree of loggers in use
- [ ] benchmark against other loggers
- [ ] support better logging for errors

0.0.10

- [ ] simplify config package, no more template and get value by string path
- [ ] move cast into util

0.0.11

- [ ] httputil package, merge part of current requests package unix domain sock etc.
- [ ] requests, download and upload file, a curl like example

## License

MIT
Expand Down
26 changes: 26 additions & 0 deletions ROADMAP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Roadmap

## 0.0.8

- [x] test coverage for multiple packages
- [ ] explain internals of some implementation
- [ ] start documenting the style for writing gommon itself, lib using gommon, app using gommon/lib using gommon
- [ ] improve Makefile and dockerized build & test

## 0.0.9

- [ ] more complex error interface, error code
- [ ] organized error types
- [ ] extension for collecting errors using third party services
- [ ] init go mod support, not sure if it will be compatible with dep

## 0.0.10

- [ ] tree of loggers in use
- [ ] benchmark against other loggers
- [ ] support better logging for errors

## 0.0.11

- [ ] httputil package, merge part of current requests package unix domain sock etc.
- [ ] requests, download and upload file, a curl like example
21 changes: 21 additions & 0 deletions directory.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Directory

## Project Layout

- [cmd/gommon](cmd/gommon) the command line application
- [doc](doc) documentation
- [errors](errors) error wrapping and multi error
- [generator](generator) generating interface methods, render go template, protobuf etc.
- [legacy](legacy) legacy code base
- [noodle](noodle) embed static assets for go binary with .ignore file support
- [playground](playground) test library and replay issues
- [requests](requests) ~~http util~~
- [scripts](scripts) test scripts
- [structure](structure) data structure
- [util](util) small packages

## Package Layout

- README.md
- doc
- history.md verbose log about the evolve of the package, important decision made and the reason behind it
5 changes: 5 additions & 0 deletions doc/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
# Gommon Documentation

- Style
- [General](style.md)
- [Application using Gommon](style-application.md)
- [Library using Gommon](style-library.md)
- [Writing Gommon](style-gommon.md)
15 changes: 0 additions & 15 deletions doc/directory.md

This file was deleted.

18 changes: 18 additions & 0 deletions doc/style-gommon.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Gommon Style

Style for writing gommon itself, see [library](style-library.md) and [application](style-application.md) for using gommon.

## Folder structure

see [directory](../directory.md)

- [ ] TODO: add how to structure file inside a package etc.

## Documentation

MUST cover the following

- [ ] convention, i.e. variable names, error handling etc.
- [ ] internal, a basic walk through of import parts
- define canonical import path in `pkg.go` https://golang.org/doc/go1.4#canonicalimports
- [ ] survey
18 changes: 1 addition & 17 deletions doc/style.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,4 @@
# Coding Style

Style for writing gommon itself, see [library](style-library.md) and [application](style-application.md) for using gommon.

## Folder structure

see [directory](directory.md)

- [ ] TODO: add how to structure file inside a package etc.

## Documentation

MUST cover the following

- [ ] convention, i.e. variable names, error handling etc.
- [ ] internal, a basic walk through of import parts
- define canonical import path in `pkg.go` https://golang.org/doc/go1.4#canonicalimports
- [ ] survey

General coding style

11 changes: 8 additions & 3 deletions generator/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import (
"os"
"path/filepath"
"strings"
"io/ioutil"

"gopkg.in/yaml.v2"

"github.com/dyweb/gommon/config"
"github.com/dyweb/gommon/errors"
"github.com/dyweb/gommon/util/fsutil"
)
Expand Down Expand Up @@ -37,10 +39,13 @@ func GenerateSingle(file string) error {
segments := strings.Split(dir, string(os.PathSeparator))
pkg := segments[len(segments)-1]
cfg := NewConfig(pkg, file)
// TODO: config may remove LoadYAMLAsStruct in the future
if err = config.LoadYAMLAsStruct(file, &cfg); err != nil {
b, err := ioutil.ReadFile(file)
if err != nil {
return errors.Wrap(err, "can't read config file")
}
if err = yaml.Unmarshal(b, &cfg); err != nil {
return errors.Wrap(err, "can't decode config file as YAML")
}

// gommon logger
if rendered, err = cfg.RenderGommon(); err != nil {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion config/pkg.go → legacy/config/pkg.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Package config supports go text/template, environment and self defined variables
package config // import "github.com/dyweb/gommon/config"
package config

import (
"github.com/dyweb/gommon/util/logutil"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion config/yaml.go → legacy/config/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import (

"gopkg.in/yaml.v2"

"github.com/dyweb/gommon/cast"
"github.com/dyweb/gommon/errors"
dlog "github.com/dyweb/gommon/log"
"github.com/dyweb/gommon/util"
"github.com/dyweb/gommon/util/cast"
)

// YAMLConfig is a thread safe struct for parse YAML file and get value
Expand Down
File renamed without changes.
Empty file added requests/doc/history.md
Empty file.
2 changes: 1 addition & 1 deletion scripts/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '2'
services:
# FIXME: there should be a way of reusing command, I am just copying stuff around, there is extend keyword, but removed in v3
golang1.9:
image: golang:1.9
image: golang:1.10
command: go test -v -cover ./cast/... ./config/... ./generator/... ./log/... ./playground/... ./requests/... ./structure/... ./util/...
working_dir: /go/src/github.com/dyweb/gommon
volumes:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion cast/pkg.go → util/cast/pkg.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Package cast convert types safely and drop incompatible types during conversion
//
// it is inspired by https://github.com/spf13/cast
package cast // import "github.com/dyweb/gommon/cast"
package cast // import "github.com/dyweb/gommon/util/cast"

0 comments on commit 1eed5cf

Please sign in to comment.