Skip to content

Commit

Permalink
chore: gofumpt (#183)
Browse files Browse the repository at this point in the history
* fumpt without bak
* chore: cleanup

Signed-off-by: Jacob Gadikian <[email protected]>
Co-authored-by: Manfred Touron <[email protected]>
  • Loading branch information
moul authored May 9, 2022
1 parent bcb1582 commit bcfe472
Show file tree
Hide file tree
Showing 258 changed files with 1,800 additions and 1,539 deletions.
1 change: 1 addition & 0 deletions alloc.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const (
_allocType = 200 // XXX
_allocAny = 200 // XXX
)

const (
allocString = _allocBase
allocStringByte = 1
Expand Down
2 changes: 1 addition & 1 deletion cmd/genproto/genproto.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func main() {
multisig.Package,
merkle.Package,
abci.Package,
//types.Package,
// types.Package,
}
for _, pkg := range pkgs {
genproto.WriteProto3Schema(pkg)
Expand Down
7 changes: 4 additions & 3 deletions cmd/gnodev/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ func main() {
}
}

type AppItem = command.AppItem
type AppList = command.AppList
type (
AppItem = command.AppItem
AppList = command.AppList
)

var mainApps AppList = []AppItem{
{precompileApp, "precompile", "precompile .gno to .go", DefaultPrecompileOptions},
Expand Down Expand Up @@ -52,5 +54,4 @@ func runMain(cmd *command.Command, exec string, args []string) error {

// unknown app command!
return errors.New("unknown command " + args[0])

}
2 changes: 1 addition & 1 deletion cmd/gnodev/precompile.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func precompileFile(srcPath string, opts precompileOptions) error {

// write .go file.
targetPath := strings.TrimSuffix(srcPath, ".gno") + ".gno.gen.go"
err = ioutil.WriteFile(targetPath, []byte(transformed), 0644)
err = ioutil.WriteFile(targetPath, []byte(transformed), 0o644)
if err != nil {
return fmt.Errorf("write .go file: %w", err)
}
Expand Down
17 changes: 8 additions & 9 deletions cmd/gnofaucet/gnofaucet.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ import (
"github.com/gnolang/gno/pkgs/std"
)

type AppItem = command.AppItem
type AppList = command.AppList
type (
AppItem = command.AppItem
AppList = command.AppList
)

var mainApps AppList = []AppItem{
{serveApp, "serve", "serve faucet", DefaultServeOptions},
}

func runMain(cmd *command.Command, exec string, args []string) error {

// show help message.
if len(args) == 0 || args[0] == "help" || args[0] == "--help" {
cmd.Println("available subcommands:")
Expand All @@ -46,7 +47,6 @@ func runMain(cmd *command.Command, exec string, args []string) error {

// unknown app command!
return errors.New("unknown command " + args[0])

}

func main() {
Expand Down Expand Up @@ -138,8 +138,8 @@ func serveApp(cmd *command.Command, args []string, iopts interface{}) error {
resdata := qres.Response.Data
var acc gnoland.GnoAccount
amino.MustUnmarshalJSON(resdata, &acc)
var accountNumber = acc.BaseAccount.AccountNumber
var sequence = acc.BaseAccount.Sequence
accountNumber := acc.BaseAccount.AccountNumber
sequence := acc.BaseAccount.Sequence

// Get password for supply account.
// Test by signing a dummy message;
Expand Down Expand Up @@ -224,7 +224,6 @@ func serveApp(cmd *command.Command, args []string, iopts interface{}) error {
}

func sendAmountTo(cmd *command.Command, cli rpcclient.Client, name, pass string, toAddr crypto.Address, accountNumber, sequence uint64, send std.Coins, opts serveOptions) error {

// Read supply account pubkey.
kb, err := keys.NewKeyBaseFromDir(opts.Home)
if err != nil {
Expand Down Expand Up @@ -259,7 +258,7 @@ func sendAmountTo(cmd *command.Command, cli rpcclient.Client, name, pass string,
// fill tx signatures.
signers := tx.GetSigners()
if tx.Signatures == nil {
for _, _ = range signers {
for range signers {
tx.Signatures = append(tx.Signatures, std.Signature{
PubKey: nil, // zero signature
Signature: nil, // zero signature
Expand All @@ -281,7 +280,7 @@ func sendAmountTo(cmd *command.Command, cli rpcclient.Client, name, pass string,
}

found := false
for i, _ := range tx.Signatures {
for i := range tx.Signatures {
// override signature for matching slot.
if signers[i] == fromAddr {
found = true
Expand Down
5 changes: 2 additions & 3 deletions cmd/gnofaucet/throttle.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ type SubnetThrottler struct {
service.BaseService
ticker *time.Ticker
subnets3 [2 << (8 * 3)]uint8
//subnets2 [2 << (8 * 2)]uint8
//subnets1 [2 << (8 * 1)]uint8
// subnets2 [2 << (8 * 2)]uint8
// subnets1 [2 << (8 * 1)]uint8
}

func NewSubnetThrottler() *SubnetThrottler {
Expand Down Expand Up @@ -61,5 +61,4 @@ func (st *SubnetThrottler) Request(ip net.IP) bool {
st.subnets3[bucket3] += 1
}
return true

}
18 changes: 12 additions & 6 deletions cmd/gnokey/gnokeys.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,21 @@ func main() {
}

var makeTxApps client.AppList = []client.AppItem{
{makeAddPackageTxApp,
{
makeAddPackageTxApp,
"addpkg", "upload new package",
defaultMakeAddPackageTxOptions},
{makeCallTxApp,
defaultMakeAddPackageTxOptions,
},
{
makeCallTxApp,
"call", "call public function",
defaultMakeCallTxOptions},
{makeSendTxApp,
defaultMakeCallTxOptions,
},
{
makeSendTxApp,
"send", "send coins",
defaultMakeSendTxOptions},
defaultMakeSendTxOptions,
},
}

func makeTxApp(cmd *command.Command, args []string, iopts interface{}) error {
Expand Down
5 changes: 3 additions & 2 deletions cmd/gnoland/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func makeGenesisDoc(pvPub crypto.PubKey) *bft.GenesisDoc {
},
}
gen.Validators = []bft.GenesisValidator{
bft.GenesisValidator{
{
Address: pvPub.Address(),
PubKey: pvPub,
Power: 10,
Expand Down Expand Up @@ -165,7 +165,8 @@ func makeGenesisDoc(pvPub crypto.PubKey) *bft.GenesisDoc {
"r/foo20",
"r/users",
"r/boards",
"r/banktest"} {
"r/banktest",
} {
// open files in directory as MemPackage.
memPkg := gno.ReadMemPackage("./examples/gno.land/"+path, "gno.land/"+path)
var tx std.Tx
Expand Down
2 changes: 1 addition & 1 deletion cmd/gnotxport/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func txExportApp(cmd *command.Command, args []string, iopts interface{}) error {
} else {
last = opts.EndHeight
}
out, err := os.OpenFile(opts.OutFile, os.O_RDWR|os.O_CREATE, 0755)
out, err := os.OpenFile(opts.OutFile, os.O_RDWR|os.O_CREATE, 0o755)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/gnotxport/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func txImportApp(cmd *command.Command, args []string, iopts interface{}) error {
lines := strings.Split(strings.TrimSpace(string(filebz)), "\n")
for i, line := range lines {
print(".")
//time.Sleep(10 * time.Second)
// time.Sleep(10 * time.Second)
if len(line) == 0 {
panic(i)
}
Expand Down
7 changes: 4 additions & 3 deletions cmd/gnotxport/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import (
"github.com/gnolang/gno/pkgs/errors"
)

type AppItem = command.AppItem
type AppList = command.AppList
type (
AppItem = command.AppItem
AppList = command.AppList
)

var mainApps AppList = []AppItem{
{txExportApp, "export", "export txs from node", defaultTxExportOptions},
Expand Down Expand Up @@ -41,5 +43,4 @@ func main() {

// unknown app command!
panic(errors.New("unknown command " + args[0]))

}
8 changes: 4 additions & 4 deletions cmd/gnoview/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ import (
"github.com/gnolang/gno/logos"
)

var row = 0
var tc_style = tcell.StyleDefault
var (
row = 0
tc_style = tcell.StyleDefault
)

func bootGnoland() (*gno.PackageValue, *bytes.Buffer) {

// Create a new machine.
rr := makeRealmer()
pn := gno.NewPackageNode("main", "gno.land/r/main", &gno.FileSet{})
Expand Down Expand Up @@ -60,7 +61,6 @@ func bootGnoland() (*gno.PackageValue, *bytes.Buffer) {
}

func main() {

// bootGnoland
pv, out := bootGnoland()

Expand Down
6 changes: 3 additions & 3 deletions cmd/gnoview/value_elem.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import (
)

var tstyle = &logos.Style{ // text
//Background: tcell.ColorWhite,
// Background: tcell.ColorWhite,
CursorStyle: &logos.Style{
Background: tcell.ColorYellow,
},
}

var istyle = &logos.Style{ // elem in list
//Background: tcell.ColorWhite,
// Background: tcell.ColorWhite,
Padding: logos.Padding{2, 0, 0, 0},
Border: logos.LeftBorder(),
CursorStyle: &logos.Style{
Expand All @@ -27,7 +27,7 @@ var istyle = &logos.Style{ // elem in list
}

var bstyle = &logos.Style{ // box style
//Background: tcell.ColorWhite,
// Background: tcell.ColorWhite,
Padding: logos.Padding{2, 0, 2, 1},
Border: logos.DefaultBorder(),
CursorStyle: &logos.Style{
Expand Down
1 change: 0 additions & 1 deletion cmd/goscan/goscan.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,4 @@ func main() {

// Print the imports from the file's AST.
spew.Dump(f)

}
8 changes: 5 additions & 3 deletions data/gnoland/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package main

var root Node

type Node interface{}
type Key interface{}
type Value interface{}
type (
Node interface{}
Key interface{}
Value interface{}
)

type InnerNode struct {
Key Key
Expand Down
1 change: 0 additions & 1 deletion frame.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import "fmt"
// (runtime) Frame

type Frame struct {

// general
Label Name // for break/continue
Source Node // source of frame
Expand Down
6 changes: 1 addition & 5 deletions gno_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ func TestTypeConversion(t *testing.T) {
z := v.(Interface1)
fmt.Println(z)
})

}

func TestSomething(t *testing.T) {
Expand All @@ -205,7 +204,6 @@ func TestSomething(t *testing.T) {
fmt.Println(unsafe.Sizeof(Foo{X: reflect.ValueOf(0)}.X)) // still 16? weird.
fmt.Println(unsafe.Sizeof(reflect.ValueOf(0))) // 24
fmt.Println(unsafe.Sizeof(Bar{}))

}

// XXX is there a way to test in Go as well as Gno?
Expand Down Expand Up @@ -277,7 +275,6 @@ func TestBinaryShortCircuit(t *testing.T) {
} else {
fmt.Println("done")
}

}

// XXX is there a way to test in Go as well as Gno?
Expand Down Expand Up @@ -327,8 +324,7 @@ func TestMultiAssignment(t *testing.T) {
return i
}

*ref(0), *ref(1), *ref(2), *ref(3) =
val(11), val(22), val(33), val(44)
*ref(0), *ref(1), *ref(2), *ref(3) = val(11), val(22), val(33), val(44)

/*
ref(0) called
Expand Down
4 changes: 2 additions & 2 deletions gnoland/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ func NewApp(rootDir string, logger log.Logger) (abci.Application, error) {
baseApp.SetAnteHandler(
// Override default AnteHandler with custom logic.
func(ctx sdk.Context, tx std.Tx, simulate bool) (
newCtx sdk.Context, res sdk.Result, abort bool) {
newCtx sdk.Context, res sdk.Result, abort bool,
) {
// Override auth params.
ctx = ctx.WithValue(
auth.AuthParamsContextKey{}, auth.DefaultParams())
// Continue on with default auth ante handler.
newCtx, res, abort = authAnteHandler(ctx, tx, simulate)
return

},
)

Expand Down
4 changes: 2 additions & 2 deletions gnoland/website/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,8 @@ func handlerStaticFile(app gotuna.App) http.Handler {
}

// TODO: ModTime doesn't work for embed?
//w.Header().Set("ETag", fmt.Sprintf("%x", stat.ModTime().UnixNano()))
//w.Header().Set("Cache-Control", fmt.Sprintf("max-age=%s", "31536000"))
// w.Header().Set("ETag", fmt.Sprintf("%x", stat.ModTime().UnixNano()))
// w.Header().Set("Cache-Control", fmt.Sprintf("max-age=%s", "31536000"))
fileapp.ServeHTTP(w, r)
})
}
Expand Down
2 changes: 0 additions & 2 deletions go2gno.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ func MustParseExpr(expr string) Expr {

// filename must not include the path.
func ParseFile(filename string, body string) (fn *FileNode, err error) {

// Parse src but stop after processing the imports.
fs := token.NewFileSet()
f, err := parser.ParseFile(fs, filename, body, parser.ParseComments|parser.DeclarationErrors)
Expand Down Expand Up @@ -621,7 +620,6 @@ func toDecls(fs *token.FileSet, gd *ast.GenDecl) (ds Decls) {
var lastValues Exprs // (see Go iota spec above)
var lastType Expr // (see Go iota spec above)
for si, s := range gd.Specs {

switch s := s.(type) {
case *ast.TypeSpec:
name := toName(s.Name)
Expand Down
Loading

1 comment on commit bcfe472

@moul
Copy link
Member Author

@moul moul commented on bcfe472 May 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original author is @faddat, see #151 (comment)

Please sign in to comment.