Golang - How to check a function is referenced in other source file? - testing

I'm a fresh man of golang and here is my problem:
I have a array of function names like this: [FunctionA FunctionB]
I want to check if those functions are referenced in other source files like: somefile.go.
What is the best way to achieve this?
In one word: How can I verify some functions are used in other source files in golang?
[Update]
Yes, it's something like grep -rl "funcName" files, but how can I omit comments in this case?

Related

is there any way to splitting Variables in VSCode?

I wonder there is any way to splitting some variables in VSCode?
my example will explain my question better:
I have an exe file in such path C:\path\to\workspace\main\project\project.exe
my cpp source path that will create exe file is this C:\path\to\workspace\main\project\test.cpp
I want to create a task in tasks.json but my oder of variables does not give me the right path
as you understand:
${workspaceFolder} is C:\path\to\workspace
${fileDirname} returns C:\path\to\workspace\main\project
and ${relativeFileDirname}.exe returns main\project.exe
and combination of "${fileDirname}\\${relativeFileDirname}.exe" as a command will return C:\path\to\workspace\main\project\main\project.exe that is wrong.
so I wanted to know there is any other variable that just return the parent of current file or not?
if not can we split variables with \ ?
I hope it makes some sense
thanks
Add new fileDirnameBasename variable
see https://github.com/microsoft/vscode/commit/551db7ec94f02a4bdc8999092cf8bef642b3992d
${fileDirnameBasename} is being added to vscode v1.52 which I believe is what you are looking for.
You can use the extension Command Variable
Use the commands:
extension.commandvariable.file.fileDirBasename
extension.commandvariable.file.fileDirBasename1Up
extension.commandvariable.file.fileDirBasename2Up
btw, as an workaround, this worked for me
"${fileDirname}\\*.exe"
but need a variable for getting parent folder of current open file
any idea?

Labview : delete files having same extension

I've been trying to delete files having same extension by using labview.
I am using delete.vi to delete files like below.
But, I want to delete all files having same extension.
Imagine a folder like below.
Here, I would like to delete all files having '.MASTER, .jou, .IFPDAT, . f06, .f04, .DBALL' as extension.
I would like to make an automatic file delete function like below.
Would there be any good examples?
The best way is to use "List Folder" with wild-cards (using "pattern" input) to get an array of files. Then you have to delete files one by one.
You can use System Exec.vi.
Here's an example to delete all DXF files in a folder:
Drawback: portability

How can I get information about type of a Go variable

Suppose I have the following code in Go:
foo, bar := someFunc(baz)
I would like to create a Vim function to check type of foo or bar when editing a file.
Is there any tool or reliable source of information for functions from Go's packages I could use or? As for the functions declared in the file I'm editing I was thinking about simply parsing all the functions declared in that file.
You are looking for something like godef
If the -t flag is given, the type of the expression will also be
printed. The -a flag causes all the public members (fields and
methods) of the expression, and their location, to be printed also;
the -A flag prints private members too.
I know it is being used by various vim and emacs scripts.
The Go Oracle does this and much more.
vim-go is a complete vim setup for Go.
It includes integration with the previously mentioned godef (as :GoDef) and Go oracle (as :GoImplements, :GoCallees, :GoReferrers, etc) as well as other tools.

Sifteo: how to create a file.txt with LUA script?

i'm trying to create a Sifteo game able to detect accelerometer data and write them on a file.txt;
I know that several methods exist that allow to visualize data on the shell (but it need to connect the base on the pc) or storing them in a StoredObject, but i'd like to create a text file.
In the documentation of sifteo sdk I found something about script lua.
I didn't understand it, Can you help me???
Thanks
If you're simply asking for how to make a .txt file in a lua script it should be something like
file = io.open("FileName.txt","w")
file:write("Information")
file:close()
If you're new to lua you can also insert information from a variable or a table by replacing it with the string "Information".
Hope this helped.

Matlab can't find member functions when directory changes. What can I do?

I have a Matlab program that does something like this
cd media;
for i =1:files
d(i).r = %some matlab file read command
d(i).process();
end
cd ..;
When I change to my "media" directory I can still access member properties (such as 'r'), but Matlab can't seem to find functions like process(). How is this problem solved? Is there some kind of global function pointer I can call? My current solution is to do 2 loops, but this is somewhat deeply chagrining.
There are two solutions:
don't change directories - instead give the file path the your file read command, e.g.
d(i).r = load(['media' filesep 'yourfilename.mat']);
or
add the directory containing your process() to the MATLAB path:
addpath('C:\YourObjectsFolder');
As mentioned by tdc, you can use
addpath(genpath('C:\YourObjectsFolder'));
if you also want to add all subdirectories to your path.
Jonas already mentioned addpath, but I usually use it in combination with genpath:
addpath(genpath('path_to_folder'));
which also adds all of the subdirectories of 'path_to_folder' as well.