Giter Club home page Giter Club logo

go-instrument's Introduction

👋🏻 hello 안녕 你好 こんにちは привет привіт
🔭 I’m currently working on backend
🌱 I’m currently learning Neuroscience, C, and OpenStack
🌏 I’m doing opensource Kong [#28] json-iterator/go [#480] and lots more!
🖥 I’m hosting calendarheatmap | go-cover-treemap | neuroscience-landscape.com
📖 I’m talking at seminars
🎓 KAIST Computer Science BSc
📜 Certifications CKAD | CKA | TOGAF | DAMA CDMP | PCA | 4x AWS | 1x GCP | NVIDIA | Redis | Datadog | Terraform
💬 Ask me about Go, Python, Software, Data, ML, Neuroscience

Hits

go-instrument's People

Contributors

burik666 avatar dependabot[bot] avatar jfallis avatar matino avatar nikolaydubina avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

go-instrument's Issues

Instrument error

Hi,

First of all thanks for your awesome work ❤️

I'm trying to use your project on our code base, but I'm getting some errors.
The following perfectly valid code fails to instrument:

package foo

import "context"

type SomeCommand struct{}

func (cmd SomeCommand) Validate() error {
	return nil
}

func SomeFunction(ctx context.Context, cmd SomeCommand) error {
	if err := cmd.Validate(); err != nil {
		return err
	}

	if err := Exec(ctx, func(ctx context.Context) error {
		return nil
	}); err != nil {
		return err
	}
	return nil
}

func Exec(ctx context.Context, fn func(ctx context.Context) error) error {
	return fn(ctx)
}

The error is rather cryptic missing ',' before newline in argument list (and 10 more errors).
My guess is that it doesn't like the invocation of Exec function.

Ignore files ignored by build

If a file begins with

//go:build ignore
// +build ignore

it should be ignored by this tool. Otherwise these comments get stripped, and obviously that causes issues as now a file which should be ignored during build is not.

We end up with an error like

#17 0.634 somepackage/somefile.go:7:2: found packages somepackage (fileA.go) and main (fileB.go) in /app

Do not change the indentation

I ran this tool against some of my code bases using the command provided in the README:

find . -name "*.go" | xargs -I{} go-instrument -app my-service -w -filename {}

It seems to change the indentation of various files, even though they are already properly formatted using go fmt. A git diff of one of those files:

index 6da35ba..8c5f832 100644
--- a/defaults.go
+++ b/defaults.go
@@ -10,58 +10,58 @@ import (
 )

 const (
-    logFormatJSON = "json"
+    logFormatJSON   = "json"

-    logTargetStdout = "stdout"
-    logTargetStderr = "stderr"
+    logTargetStdout = "stdout"
+    logTargetStderr = "stderr"

-    logLevelPanic = "panic"
-    logLevelFatal = "fatal"
-    logLevelError = "error"
-    logLevelWarn  = "warn"
-    logLevelInfo  = "info"
-    logLevelDebug = "debug"
-    logLevelTrace = "trace"
+    logLevelPanic   = "panic"
+    logLevelFatal   = "fatal"
+    logLevelError   = "error"
+    logLevelWarn    = "warn"
+    logLevelInfo    = "info"
+    logLevelDebug   = "debug"
+    logLevelTrace   = "trace"
 )

// ...

Handle files with generics

$ find . -name "*.go" | xargs -I{} go-instrument -app my-service -w -filename {}
2023/03/25 16:41:44 can not parse input file: ./pkg/model/utils/pointer.go:3:9: expected '(', found '['

$ cat ./pkg/model/utils/pointer.go
package utils

func Ptr[T any](v T) *T {
	return &v
}

Do not remove comments

I ran this tool against some of my code bases using the command provided in the README:

find . -name "*.go" | xargs -I{} go-instrument -app my-service -w -filename {}

It seems to remove all comments. A git diff of one of those files:

diff --git a/pprof.go b/pprof.go
index 352adf6..975e75f 100644
--- a/pprof.go
+++ b/pprof.go
// ...

     go func() {
         <-ctx.Done()
-        defer cpuf.Close() //nolint:errcheck,gosec // error ignored on purpose
-        defer memf.Close() //nolint:errcheck,gosec // error ignored on purpose
+        defer cpuf.Close()
+        defer memf.Close()

         pprof.StopCPUProfile()
         if err := pprof.WriteHeapProfile(memf); err != nil {

Regexp directives

suggested:

image

issues:

  • how to combine?
  • case 1: exclude all, but select some
  • case 2: include all, but select some

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.