Problems running protoc with proto_path to generate Gocode - go

I am having a little bit of an issue to correctly understand the format of running protoc to generate Go source from proto files.
I have tried
protoc --proto_path=api/auth-service api/auth-service/proto/*.proto --go_out=pluigins=grpc:pb
and
protoc --proto_path=api/auth-service/proto/*.proto --go_out=pluigins=grpc:pb
The above always print
api/auth-service/proto/*.proto: warning: directory does not exist.
or
Missing input file.
eventually, after a lot of playing around it seems that thing works.
protoc --proto_path=api/auth-service api/auth-service/proto/*.proto --go_out=pluigins=grpc:pb
But I am very confused about the actual correct format (passing in the directory twice and the 2nd passing in *.proto)
I tried finding some syntax why it was working this way but I couldn't.
There was also passing -I instead of --proto_path.

You have to run with a named proto ( so replace the * with your proto filename, should fix it)

Related

Where is libpcap.dylib?

I able to load libpcap.dylib which is confusing cause I can't figure out the actual file location. Doing find / -name libpcap.A.dylib or libpcap.dylib says no such file.
Also finder search with libpcap just results in libpcap.A.tbd and libpcap.rb.
libpcap.A.tbd shows "Install location /usr/lib/libpcap.A.dylib", but it does not actually exist there.
I wanted to locate the actual dylib file cause I running into issue with being able to import function, So I wanted to check file to make sure I have function names correct.
So I wanted to check file to make sure I have function names correct.
The first thing to check is the pcap man page - from the command line, it'd be
man pcap
It's a bit long, but it should mention all the functions available in libpcap; it may be easier than
nm /usr/lib/libpcap.dylib | egrep ' T '
(and doesn't require you to remember that the leading underscores in the output of that command are NOT part of the name of the function, they're a leftover from ancient UNIX history).
Where is libpcap.dylib?
/usr/lib/libpcap.A.dylib. /usr/lib/libpcap.dylib is a symbolic link to it.

File does not reside within any path specified using proto_path

I am testing out importing .proto file from another directory.
$GOPATH/src/A/A.proto
syntax = "proto3";
package A;
message SomeMsg {
string msg = 2;
int64 id = 3;
}
$GOPATH/src/B/B.proto
syntax = "proto3";
package B; import "A/A.proto";
message Msg {
SomeMsg s = 1;
}
I'm doing this:
in folder A:
protoc A.proto --go_out=.
and then in folder B:
protoc B.proto --go_out=. --proto_path=$GOPATH/
But I will get this error:
B.proto: File does not reside within any path specified using --proto_path (or -I). You must specify a --proto_path which encompasses this file. Note that the proto_path must be an exact prefix of the .proto file names -- protoc is too dumb to figure out when two paths (e.g. absolute and relative) are equivalent (it's harder than you think).
Error seems clear enough to me, it is saying that you need to specify the exact directory that B.proto is in
protoc B.proto --go_out=. --proto_path=$GOPATH/src/B
or if you are in folder B already,
protoc B.proto --go_out=.
protoc B.proto --go_out=. --proto_path=$GOPATH/src/B --progo_path=. worked for me.
--progo_path=. may help you too.
Case1: The '..' cannot used in path of .proto file if all paths are in 'absolute format'.
Case2: Another word to explain that error. The relevant path and absolute path cannot use in mixed within -I and path to .proto file, since the 'prefix' means the STRING-PREFIX instead of 'a path can jump to by relevant-path in filesystem'.
=========
It seems that the .proto and -I its resided in should use both relative path or both, otherwise error occured.
In case of a reference to a proto file in a C# project, note that the path to the proto file is case sensitive. In my case a link to the proto file in a .net 4.6 project (VS2022 on Windows), looks like this. When I use uppercase characters in the path, the compiler gives the "File does not reside within any path specified using --proto_path" error, as mentioned. However, I can use relative paths.
<!-- all path characters must be lower case -->
<Protobuf Include="..\path.to.proto\protos\myfile.proto">
<Link>Protos\myfile.proto</Link>
</Protobuf>
Also note that you must change the csproj file manually to be sure that the xml-element is called 'Protobuf' and not 'None'! Of course, only applicable for visual studio project situations.

Biopython: SeqIO.parse() FileNotFoundError

I'm new in Bioinformatics and Biopython, so I have some difficulties with it.
I was reading the Biopython (SeqIO) documentation, but when I try to execute some SeqIO.parse() commands I get FileNotFoundError.
For example, I want to get "example.fasta" file (which I don't have it on my PC). I try to do it with this command:
for record in SeqIO.parse("example.fasta", "fasta"):
print(record.id)
But, all I get is FileNotFoundError: [Errno 2] No such file or directory
Can someone help me with this?
My understanding is that FileNotFoundError occurs when the code tries to open a file on your computer and does not find it.
This can happen either because you simply do not have this file, or you gave the name with a typo, or the path to the file is not correct (This is an important notion: the path to the file should be absolute, or relative to the current working directory (usually the one from which you executed the python script)).
As suggested in the comments to your question, you seem to be expecting SeqIO.parse to get the file for you. This is not the case. The first argument you give to this function (in the example "example.fasta") is the path to an existing file that you want to "parse", that is, interpret its information content and make this content available to the rest of your program in a convenient form.
So in order to get this example working, you first need to get a fasta file. If you do not already have one, you can download some manually from genbank, or find one in the biopython installation (if you installed it from source and know where the source code is located), for instance in Tests/Quality/example.fasta.

gcov can't find a file. Mac OSX

I have a problem with invoking gcov, it keeps returning - No such file or directory.
When I call
localhost:R-3.0.1 romantsegelskyi$ gcov src/main/eval.c
eval.c: No such file or directory
However file itself and information needed for gcov exists.
localhost:R-3.0.1 romantsegelskyi$ ls src/main/eval*
src/main/eval.c src/main/eval.d src/main/eval.gcda src/main/eval.gcno src/main/eval.o
I have tried specifying --object-directory but still no luck
localhost:R-3.0.1 romantsegelskyi$ gcov src/main/eval.c --object-directory=./src/main
eval.c: No such file or directory
Strangest thing is that it is only the case on OSX, on Linux everything works fine as intended. Any ideas?
Same behavior !! And more strange : I get the result (the .gcov file), following this mesg !! Perhaps, you have the result too ?
There two aspects in the problem :
gcov manual said that gcov should execute by default in the directory where the object file and the gcov data files are. The first and simplest working solution is : go in the appropriate directory and execute gcov cd src/main; gcov eval.c
why the --object-directory=... arg seems not working ? Because the expected value is a directory name and in the example given, it is a file name. So you should write --object-directory=src/main (this work too)
or --object-file=src/main/eval.c (according to the doc. I haven't tried this !)

Is there a way to compile Pascal program and put the generated files in a specific folder?

So I am trying to compile Pascal programs and everything is find; however, I would like to put the generated files after each compilation is a separated folder. I am looking of something like this: fpc "Destination Folder" "program.pas".
Thanks
From Alphabetical listing of command line options
-FE<x> Set exe/unit output path to <x>
-FU<x> Set unit output path to <x>, overrides -FE
So something like fpc program.pas -FEc:\output should work. I don't have fpc installed so I cannot verify. If you try it and get errors that you can't work through post them.
This one works for me:
fpc hello.pas -o"Web/hello.cgi"
I was using ubuntu, notice there is no space between the argument -o and the beginning of the path "Web/..."

Resources