Skip to content

Commit ace19ee

Browse files
committed
cleaning up src ^^
- rm `vendor` folder - bump ext dep. - github actions - ...
1 parent 253bb4e commit ace19ee

37 files changed

+288
-10058
lines changed

.github/workflows/release.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: goreleaser
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
goreleaser:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v3
16+
with:
17+
fetch-depth: 0
18+
- run: git fetch --force --tags
19+
- uses: actions/setup-go@v3
20+
with:
21+
go-version: '>=1.19.2'
22+
cache: true
23+
- uses: goreleaser/goreleaser-action@v2
24+
with:
25+
distribution: goreleaser
26+
version: latest
27+
args: release --rm-dist
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
.idea/
2-
out/
3-
release/
2+
dist/

.golangci.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
linters:
2+
enable-all: true
3+
disable:
4+
- forbidigo
5+
- funlen
6+
- lll
7+
- gochecknoglobals
8+
- paralleltest
9+
- scopelint
10+
- testpackage
11+
- varnamelen

.goreleaser.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
before:
2+
hooks:
3+
- go mod tidy
4+
builds:
5+
- env:
6+
- CGO_ENABLED=0
7+
goos:
8+
- linux
9+
- windows
10+
- darwin
11+
goarch:
12+
- amd64
13+
- arm64
14+
checksum:
15+
name_template: 'checksums.txt'
16+
snapshot:
17+
name_template: "{{ incpatch .Version }}-next"
18+
changelog:
19+
sort: asc
20+
filters:
21+
exclude:
22+
- '^docs:'
23+
- '^test:'

.pre-commit-config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# todo add to CI
2+
repos:
3+
- repo: https://github.com/pre-commit/pre-commit-hooks
4+
rev: v4.3.0
5+
hooks:
6+
- id: check-case-conflict
7+
- id: trailing-whitespace
8+
- id: end-of-file-fixer
9+
- id: check-yaml
10+
- id: check-added-large-files

.travis.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
BSD 2-Clause License
22

3-
Copyright (c) 2017, AJ
3+
Copyright (c) 2022, AJ
44
All rights reserved.
55

66
Redistribution and use in source and binary forms, with or without

README.md

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,16 @@
22

33
A small tool for converting YAML files into JSON.
44

5-
## Installation
6-
7-
macOS
8-
```
9-
$ brew tap wakeful/selection
10-
$ brew install yaml2json
11-
```
12-
13-
Linux
14-
```
15-
curl -Lo yaml2json https://github.com/wakeful/yaml2json/releases/latest/download/yaml2json-linux-amd64 && chmod +x yaml2json && sudo mv yaml2json /usr/local/bin/
16-
```
17-
18-
src
19-
```
20-
go get -u github.com/wakeful/yaml2json
21-
```
22-
235
## Usage
246

257
stdin pipe:
8+
269
```
2710
cat file.yml | yaml2json
2811
```
2912

3013
or specify a file:
14+
3115
```
3216
yaml2json path/file.yml
3317
```

decode.go

Lines changed: 0 additions & 33 deletions
This file was deleted.

go.mod

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
module github.com/wakeful/yaml2json
22

3-
go 1.12
3+
go 1.19
44

5-
require (
6-
github.com/go-yaml/yaml v2.1.0+incompatible
7-
github.com/kr/pretty v0.1.0 // indirect
8-
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
9-
gopkg.in/yaml.v2 v2.2.2 // indirect
10-
)
5+
require gopkg.in/yaml.v2 v2.4.0

go.sum

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
github.com/go-yaml/yaml v2.1.0+incompatible h1:RYi2hDdss1u4YE7GwixGzWwVo47T8UQwnTLB6vQiq+o=
2-
github.com/go-yaml/yaml v2.1.0+incompatible/go.mod h1:w2MrLa16VYP0jy6N7M5kHaCkaLENm+P+Tv+MfurjSw0=
3-
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
4-
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
5-
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
6-
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
7-
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
1+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
82
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
9-
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
10-
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
11-
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
12-
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
3+
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
4+
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=

help.go

Lines changed: 0 additions & 20 deletions
This file was deleted.

input.go

Lines changed: 0 additions & 25 deletions
This file was deleted.

pkg/parse/decode.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package parse
2+
3+
import (
4+
"encoding/json"
5+
"fmt"
6+
7+
"gopkg.in/yaml.v2"
8+
)
9+
10+
func decode(input interface{}) interface{} {
11+
switch element := input.(type) {
12+
case map[interface{}]interface{}:
13+
rec := map[string]interface{}{}
14+
15+
for key, value := range element {
16+
rec[fmt.Sprintf("%v", key)] = decode(value)
17+
}
18+
19+
return rec
20+
case []interface{}:
21+
for key, value := range element {
22+
element[key] = decode(value)
23+
}
24+
}
25+
26+
return input
27+
}
28+
29+
func ByteSliceToJSON(input []byte) (string, error) {
30+
var unYaml interface{}
31+
if err := yaml.Unmarshal(input, &unYaml); err != nil {
32+
return "", fmt.Errorf("%w", err)
33+
}
34+
35+
output, err := json.Marshal(decode(unYaml))
36+
if err != nil {
37+
return "", fmt.Errorf("%w", err)
38+
}
39+
40+
return string(output), nil
41+
}

0 commit comments

Comments
 (0)