Skip to content

Commit

Permalink
Replaced the Seqhash sequencetype with Struct type argument instead o…
Browse files Browse the repository at this point in the history
…f a plain string.. (#264)

* Replaced the Seqhash sequencetype with Struct type argument instead of a plain string..

* Cleared the linting errors for Go > 1.16 where ioutils package has been depreciated

Co-authored-by: Tim <[email protected]>
  • Loading branch information
rkrishnasanka and TimothyStiles authored Sep 11, 2022
1 parent 07afbb6 commit eba6b72
Show file tree
Hide file tree
Showing 16 changed files with 143 additions and 144 deletions.
37 changes: 19 additions & 18 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
name: golangci-lint
# on:
# push:
# tags:
# - v*
# branches:
# - main
# pull_request:
# jobs:
# golangci:
# name: lint
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - name: Run golangci-lint
# uses: golangci/[email protected]
# with:
# # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
# version: latest

on:
push:
tags:
- v*
branches:
- main
pull_request:
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run golangci-lint
uses: golangci/[email protected]
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: latest

# Optional: working directory, useful for monorepos
# working-directory: somedir
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/notify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ on:
release:
issues:
pull_request:
issue_comment:
pull_request_review:
pull_request_review_comment:
types: [opened]
issue_comment:
discussion:
discussion_comment:
push:
Expand All @@ -23,4 +22,4 @@ jobs:
- name: Actions for Discord
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/[email protected]
uses: Ilshidur/[email protected]
3 changes: 1 addition & 2 deletions io/fasta/fasta.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"bytes"
"compress/gzip"
"io"
"io/ioutil"
"os"
"strings"
)
Expand Down Expand Up @@ -193,5 +192,5 @@ func Write(fastas []Fasta, path string) error {
if err != nil {
return err
}
return ioutil.WriteFile(path, fastaBytes, 0644)
return os.WriteFile(path, fastaBytes, 0644)
}
5 changes: 2 additions & 3 deletions io/genbank/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package genbank_test
import (
"bytes"
"fmt"
"io/ioutil"
"os"
"path/filepath"

Expand All @@ -29,7 +28,7 @@ func ExampleRead() {
}

func ExampleWrite() {
tmpDataDir, err := ioutil.TempDir("", "data-*")
tmpDataDir, err := os.MkdirTemp("", "data-*")
if err != nil {
fmt.Println(err.Error())
}
Expand Down Expand Up @@ -74,7 +73,7 @@ func ExampleReadMulti() {
}

func ExampleWriteMulti() {
tmpDataDir, err := ioutil.TempDir("", "data-*")
tmpDataDir, err := os.MkdirTemp("", "data-*")
if err != nil {
fmt.Println(err.Error())
}
Expand Down
7 changes: 3 additions & 4 deletions io/genbank/genbank.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"bytes"
"fmt"
"io"
"io/ioutil"
"os"
"regexp"
"strconv"
Expand All @@ -33,7 +32,7 @@ GBK specific IO related things begin here.
******************************************************************************/

var (
readFileFn = ioutil.ReadFile
readFileFn = os.ReadFile
parseMultiNthFn = ParseMultiNth
parseReferencesFn = parseReferences
)
Expand Down Expand Up @@ -187,7 +186,7 @@ func Write(sequences Genbank, path string) error {
// add error handling in the future.
gbk, _ := Build(sequences)

err := ioutil.WriteFile(path, gbk, 0644)
err := os.WriteFile(path, gbk, 0644)
return err
}

Expand All @@ -198,7 +197,7 @@ func WriteMulti(sequences []Genbank, path string) error {
// add error handling in the future.
gbk, _ := BuildMulti(sequences)

err := ioutil.WriteFile(path, gbk, 0644)
err := os.WriteFile(path, gbk, 0644)
return err
}

Expand Down
9 changes: 4 additions & 5 deletions io/genbank/genbank_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package genbank
import (
"errors"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -34,7 +33,7 @@ var singleGbkPaths = []string{
}

func TestGbkIO(t *testing.T) {
tmpDataDir, err := ioutil.TempDir("", "data-*")
tmpDataDir, err := os.MkdirTemp("", "data-*")
if err != nil {
t.Error(err)
}
Expand Down Expand Up @@ -68,7 +67,7 @@ func TestMultiLineFeatureParse(t *testing.T) {
}

func TestMultiGenbankIO(t *testing.T) {
tmpDataDir, err := ioutil.TempDir("", "data-*")
tmpDataDir, err := os.MkdirTemp("", "data-*")
if err != nil {
t.Error(err)
}
Expand All @@ -89,7 +88,7 @@ func TestMultiGenbankIO(t *testing.T) {
}

func TestGbkLocationStringBuilder(t *testing.T) {
tmpDataDir, err := ioutil.TempDir("", "data-*")
tmpDataDir, err := os.MkdirTemp("", "data-*")
if err != nil {
t.Error(err)
}
Expand Down Expand Up @@ -117,7 +116,7 @@ func TestGbkLocationStringBuilder(t *testing.T) {
}

func TestGbLocationStringBuilder(t *testing.T) {
tmpDataDir, err := ioutil.TempDir("", "data-*")
tmpDataDir, err := os.MkdirTemp("", "data-*")
if err != nil {
t.Error(err)
}
Expand Down
3 changes: 1 addition & 2 deletions io/gff/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package gff_test
import (
"bytes"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"testing"
Expand Down Expand Up @@ -49,7 +48,7 @@ func ExampleBuild() {
}

func ExampleWrite() {
tmpDataDir, err := ioutil.TempDir("", "data-*")
tmpDataDir, err := os.MkdirTemp("", "data-*")
if err != nil {
fmt.Println(err.Error())
}
Expand Down
5 changes: 2 additions & 3 deletions io/gff/gff.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ package gff
import (
"bytes"
"io"
"io/ioutil"
"os"
"sort"
"strconv"
Expand All @@ -26,7 +25,7 @@ import (
)

var (
readAllFn = ioutil.ReadAll
readAllFn = io.ReadAll
atoiFn = strconv.Atoi
openFn = os.Open
)
Expand Down Expand Up @@ -305,5 +304,5 @@ func Read(path string) (Gff, error) {
// Write takes an poly.Sequence struct and a path string and writes out a gff to that path.
func Write(sequence Gff, path string) error {
gff, _ := Build(sequence)
return ioutil.WriteFile(path, gff, 0644)
return os.WriteFile(path, gff, 0644)
}
7 changes: 3 additions & 4 deletions io/gff/gff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"errors"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand All @@ -24,7 +23,7 @@ Gff related tests and benchmarks begin here.
// TODO should delete output files.

func TestGffIO(t *testing.T) {
tmpDataDir, err := ioutil.TempDir("", "data-*")
tmpDataDir, err := os.MkdirTemp("", "data-*")
if err != nil {
t.Error(err)
}
Expand All @@ -42,8 +41,8 @@ func TestGffIO(t *testing.T) {
t.Errorf("Parsing the output of Build() does not produce the same output as parsing the original file read with ReadGff(). Got this diff:\n%s", diff)
}

original, _ := ioutil.ReadFile(testInputPath)
builtOutput, _ := ioutil.ReadFile(tmpGffFilePath)
original, _ := os.ReadFile(testInputPath)
builtOutput, _ := os.ReadFile(tmpGffFilePath)
gffDiff := difflib.UnifiedDiff{
A: difflib.SplitLines(string(original)),
B: difflib.SplitLines(string(builtOutput)),
Expand Down
5 changes: 2 additions & 3 deletions io/polyjson/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package polyjson_test

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"time"
Expand All @@ -14,7 +13,7 @@ import (
func Example() {

// this example also is run by the poly's test suite so this just sets up a temporary directory for writing files
tmpDataDir, err := ioutil.TempDir("", "data-*")
tmpDataDir, err := os.MkdirTemp("", "data-*")
if err != nil {
fmt.Println(err.Error())
}
Expand Down Expand Up @@ -74,7 +73,7 @@ func ExampleParse() {
}

func ExampleWrite() {
tmpDataDir, err := ioutil.TempDir("", "data-*")
tmpDataDir, err := os.MkdirTemp("", "data-*")
if err != nil {
fmt.Println(err.Error())
}
Expand Down
3 changes: 1 addition & 2 deletions io/polyjson/polyjson.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"bytes"
"encoding/json"
"io"
"io/ioutil"
"os"
"time"

Expand Down Expand Up @@ -151,7 +150,7 @@ func Write(sequence Poly, path string) error {
if err != nil {
return err
}
return ioutil.WriteFile(path, file, 0644)
return os.WriteFile(path, file, 0644)
}

/******************************************************************************
Expand Down
Loading

0 comments on commit eba6b72

Please sign in to comment.