ondrajz / go-callvis

Visualize call graph of a Go program using Graphviz
https://ofabry.github.io/go-callvis
MIT License
5.85k stars 406 forks source link

the parametes '-tags' not take effect #81

Open cgyFight opened 3 years ago

cgyFight commented 3 years ago

~help wanted I make an examples, the project dir like this: . ├── dir1 │ ├── f1.go │ └── f1_nolic.go └── main.go

if i build with

go build

it will call the f1.go function TfuncA if i build with

go build -tags nolic

it will call the f2.go function TfuncA

but whether i use -tags with nolic in go-callvis, they both call f1.go function TfuncA :

go-callvis -tags nolic .
go-callvis .

Did I use it wrong?

main.go

package main

import (
    "cgy/test-calvis/dir1"
)

func main() {
    println("hello")
    dir1.TfuncA()
}

f1.go

//+build !nolic

package dir1

func TfuncB() {
    println("t func b")
}

func TfuncA() {
    println("t func a")
    TfuncB()
}

f1_nolic.go

//+build nolic

package dir1

func TfuncA() {
    println("t func a nolic")
}
yanjinbin commented 2 years ago

similar situation with you when I integrate with c++ librdkafka SDK , error as like below

go-callvis -tags=dynamic  ./src/cmd/app.go

image

system env:


mac m1   Monterey 12.0.1  

go 1.17.6

cgo related 

CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/dp/m7czp6r110x0rsskffnn0_t40000gn/T/go-build2512158920=/tmp/go-build -gno-record-gcc-switches -fno-common"

however I use

go build -tags dynamic ./src/cmd

is okay

yanjinbin commented 2 years ago
-Qunused-argume
  • [x] fix it replay myself , go-callvis use go build , so try go build [your main package directory not your main.go filename ]