Skip to content

Commit

Permalink
Cleanup (#277)
Browse files Browse the repository at this point in the history
Some cleanup of imports, headers, licences, etc.
  • Loading branch information
oxisto authored Dec 29, 2023
1 parent 6a03f2e commit cac7fb1
Show file tree
Hide file tree
Showing 31 changed files with 132 additions and 52 deletions.
3 changes: 1 addition & 2 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
//
// This file is part of The Money Gopher.

// repl provides a simple Read-Eval-Print-Loop (REPL) to issue commands to an
// integrated client.
// cli provides the commands for a simple CLI.
package cli

import (
Expand Down
19 changes: 18 additions & 1 deletion cli/commands/account.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
// Copyright 2023 Christian Banse
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// This file is part of The Money Gopher.

package commands

import (
"context"
"fmt"

"connectrpc.com/connect"
"github.com/oxisto/money-gopher/cli"
portfoliov1 "github.com/oxisto/money-gopher/gen"

"connectrpc.com/connect"
)

type BankAccountCmd struct {
Expand Down
8 changes: 4 additions & 4 deletions cli/commands/portfolio.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ import (
"strings"
"time"

"github.com/fatih/color"
kongcompletion "github.com/jotaen/kong-completion"
"github.com/oxisto/money-gopher/cli"
portfoliov1 "github.com/oxisto/money-gopher/gen"
"github.com/oxisto/money-gopher/gen/portfoliov1connect"
"github.com/posener/complete"
"google.golang.org/protobuf/types/known/timestamppb"

"connectrpc.com/connect"
"github.com/fatih/color"
kongcompletion "github.com/jotaen/kong-completion"
"github.com/posener/complete"
"google.golang.org/protobuf/types/known/timestamppb"
)

type PortfolioCmd struct {
Expand Down
8 changes: 4 additions & 4 deletions cli/commands/securities.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ import (
"fmt"
"net/http"

"connectrpc.com/connect"
kongcompletion "github.com/jotaen/kong-completion"
"github.com/posener/complete"

"github.com/oxisto/money-gopher/cli"
portfoliov1 "github.com/oxisto/money-gopher/gen"
"github.com/oxisto/money-gopher/gen/portfoliov1connect"

"connectrpc.com/connect"
kongcompletion "github.com/jotaen/kong-completion"
"github.com/posener/complete"
)

type SecurityCmd struct {
Expand Down
6 changes: 3 additions & 3 deletions cmd/mgo/mgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ package main
import (
"os"

"github.com/alecthomas/kong"
kongcompletion "github.com/jotaen/kong-completion"

"github.com/oxisto/money-gopher/cli"
"github.com/oxisto/money-gopher/cli/commands"

"github.com/alecthomas/kong"
kongcompletion "github.com/jotaen/kong-completion"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion finance/calculation.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
//
// This file is part of The Money Gopher.

// package portfolio contains all kinds of different finance calculations.
// package finance contains all kinds of different finance calculations.
package finance

import (
Expand Down
5 changes: 3 additions & 2 deletions finance/calculation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
//
// This file is part of The Money Gopher.

// package portfolio contains all kinds of different finance calculations.
// package finance contains all kinds of different finance calculations.
package finance

import (
"testing"

"github.com/oxisto/assert"
portfoliov1 "github.com/oxisto/money-gopher/gen"

"github.com/oxisto/assert"
)

func TestNewCalculation(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions gen/account_sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.
//
// This file is part of The Money Gopher.

package portfoliov1

import (
Expand Down
1 change: 1 addition & 0 deletions gen/currency.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.
//
// This file is part of The Money Gopher.

package portfoliov1

import (
Expand Down
1 change: 1 addition & 0 deletions gen/portfolio.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.
//
// This file is part of The Money Gopher.

package portfoliov1

import (
Expand Down
2 changes: 2 additions & 0 deletions gen/portfolio_sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.
//
// This file is part of The Money Gopher.

package portfoliov1

import (
Expand All @@ -22,6 +23,7 @@ import (
"time"

"github.com/oxisto/money-gopher/persistence"

timestamppb "google.golang.org/protobuf/types/known/timestamppb"
)

Expand Down
16 changes: 16 additions & 0 deletions gen/portfolio_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
// Copyright 2023 Christian Banse
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// This file is part of The Money Gopher.

package portfoliov1

import (
Expand Down
2 changes: 2 additions & 0 deletions gen/securities_sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.
//
// This file is part of The Money Gopher.

package portfoliov1

import (
Expand All @@ -21,6 +22,7 @@ import (
"time"

"github.com/oxisto/money-gopher/persistence"

"google.golang.org/protobuf/types/known/timestamppb"
)

Expand Down
4 changes: 2 additions & 2 deletions import/csv/csv_importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ import (
"strings"
"time"

"github.com/lmittmann/tint"
moneygopher "github.com/oxisto/money-gopher"
portfoliov1 "github.com/oxisto/money-gopher/gen"
"github.com/oxisto/money-gopher/service/securities"

"github.com/lmittmann/tint"
"github.com/oxisto/money-gopher/service/securities"
"google.golang.org/protobuf/types/known/timestamppb"
)

Expand Down
3 changes: 2 additions & 1 deletion import/csv/csv_importer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ import (
"testing"
"time"

"github.com/oxisto/assert"
moneygopher "github.com/oxisto/money-gopher"
portfoliov1 "github.com/oxisto/money-gopher/gen"

"github.com/oxisto/assert"
"github.com/oxisto/money-gopher/service/securities"
"google.golang.org/protobuf/types/known/timestamppb"
)
Expand Down
19 changes: 17 additions & 2 deletions internal/persistence.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
// Copyright 2023 Christian Banse
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// This file is part of The Money Gopher.

package internal

import (
Expand Down Expand Up @@ -25,10 +41,9 @@ func NewTestDB(t *testing.T, inits ...func(db *persistence.DB)) (db *persistence

func NewTestDBOps[T persistence.StorageObject](t *testing.T, inits ...func(ops persistence.StorageOperations[T])) (ops persistence.StorageOperations[T]) {
var (
db *persistence.DB
db = NewTestDB(t)
)

db = NewTestDB(t)
ops = persistence.Ops[T](db)

for _, init := range inits {
Expand Down
2 changes: 1 addition & 1 deletion money-gopher.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@
"tailwindcss",
"timestamppb"
],
"editor.tabSize": 2
"editor.tabSize": 4
}
}
4 changes: 2 additions & 2 deletions service/internal/crud/crud_requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import (
"log/slog"
"strings"

"github.com/oxisto/money-gopher/persistence"

"connectrpc.com/connect"
"google.golang.org/protobuf/types/known/emptypb"

"github.com/oxisto/money-gopher/persistence"
)

func Create[T any, S persistence.StorageObject](obj S, op persistence.StorageOperations[S], convert func(obj S) *T) (res *connect.Response[T], err error) {
Expand Down
21 changes: 19 additions & 2 deletions service/internal/crud/crud_requests_test.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
// Copyright 2023 Christian Banse
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// This file is part of The Money Gopher.

package crud

import (
"errors"
"reflect"
"testing"

"connectrpc.com/connect"
"github.com/oxisto/assert"
portfoliov1 "github.com/oxisto/money-gopher/gen"
"github.com/oxisto/money-gopher/internal"
"github.com/oxisto/money-gopher/persistence"

"connectrpc.com/connect"
"github.com/oxisto/assert"
"google.golang.org/protobuf/types/known/emptypb"
)

Expand Down
6 changes: 3 additions & 3 deletions service/portfolio/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ package portfolio
import (
"context"

"connectrpc.com/connect"
"google.golang.org/protobuf/types/known/emptypb"

portfoliov1 "github.com/oxisto/money-gopher/gen"

"connectrpc.com/connect"
"github.com/oxisto/money-gopher/service/internal/crud"
"google.golang.org/protobuf/types/known/emptypb"
)

var bankAccountSetter = func(obj *portfoliov1.BankAccount) *portfoliov1.BankAccount {
Expand Down
5 changes: 3 additions & 2 deletions service/portfolio/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ import (
"context"
"testing"

"connectrpc.com/connect"
"github.com/oxisto/assert"
portfoliov1 "github.com/oxisto/money-gopher/gen"
"github.com/oxisto/money-gopher/gen/portfoliov1connect"
"github.com/oxisto/money-gopher/internal"
"github.com/oxisto/money-gopher/persistence"

"connectrpc.com/connect"
"github.com/oxisto/assert"
"google.golang.org/protobuf/types/known/fieldmaskpb"
)

Expand Down
2 changes: 1 addition & 1 deletion service/portfolio/portfolio.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import (

portfoliov1 "github.com/oxisto/money-gopher/gen"
"github.com/oxisto/money-gopher/service/internal/crud"
"google.golang.org/protobuf/types/known/emptypb"

"connectrpc.com/connect"
"google.golang.org/protobuf/types/known/emptypb"
)

var portfolioSetter = func(obj *portfoliov1.Portfolio) *portfoliov1.Portfolio {
Expand Down
5 changes: 3 additions & 2 deletions service/portfolio/portfolio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ import (
"testing"
"time"

"connectrpc.com/connect"
"github.com/oxisto/assert"
portfoliov1 "github.com/oxisto/money-gopher/gen"
"github.com/oxisto/money-gopher/gen/portfoliov1connect"
"github.com/oxisto/money-gopher/internal"
"github.com/oxisto/money-gopher/persistence"

"connectrpc.com/connect"
"github.com/oxisto/assert"
"google.golang.org/protobuf/types/known/fieldmaskpb"
"google.golang.org/protobuf/types/known/timestamppb"
)
Expand Down
3 changes: 2 additions & 1 deletion service/portfolio/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ package portfolio
import (
"testing"

"github.com/oxisto/assert"
"github.com/oxisto/money-gopher/gen/portfoliov1connect"
"github.com/oxisto/money-gopher/internal"

"github.com/oxisto/assert"
)

func TestNewService(t *testing.T) {
Expand Down
Loading

0 comments on commit cac7fb1

Please sign in to comment.