Working with monkey patches [closed] - go

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
Is monkey patching possible in Go as in Ruby?
If so, I have a third party library build, which contains one function called encrypt. Now i want to overwrite the behaviour of the function. Is that possible?

Golang is a compiled language, you'll have to edit the code, recompile and deploy all over again. "monkey patching" isn't possible as if you're talking about changing the software after it is already deployed like ruby. (which is an interpreted language).
But if your concerns are beyond an hotfix and involve adding new code at runtime from external source, you might want to have a look at go plugins.
here's a nice medium post about it.

I'm not big on ruby so to make sure we are on the same page: my understanding is that monkey patching allows you to change the underlying behaviours (methods) attached to a given type at runtime.
In go this would be a big fat no no, probably should be in ruby too for the most part :)
Types are concrete in go, everything has to know what it is dealing with at compile time. It's difficult to propose a solution without a clearer understanding of the end goal, can you provide a more concrete example?

Related

How to read file properties in Go [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I'm looking for a way to read the properties of a file so that I can programmatically verify a file came from a specific company. I just want to perform the basic checks such as 'is it signed' and 'who signed it' - the information that you can get when you right-click the file and select 'Digital Signatures'. I can't call any OS specific tool (e.g. signtool --verify) and ideally want to avoid any third party libraries as we have a super strict policy in regards to using them.
This will be initially on windows using GoLang and will be used to verify some signed msi files. I was thinking I could load one of the OS dlls to help out but not sure what one would be able to provide that information. If someone can point me in the right direction I should be taking in order to solve this problem or provide a short example of something similiar that would be great.
It sounds like you want to call WinVerifyTrust, WinVerifyTrustEx, or some similar functionality. Searching for golang WinVerifyTrust, it looks like there exists some example go code you could reference for invoking the system's wintrust.dll. Assuming you're willing to write code that only works on Windows, that's probably the direction I would recommend.
From a more cross-platform perspective, you could instead look for OpenSSL wrappers or implementations. Reportedly, Windows PE digital signatures are based on PKCS#7, which OpenSSL should be able to support with enough glue code.

Designing a makefile for installing / uninstalling software that I design [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I'm writing a compiler and there are certain things that I simply can't do without knowing where the user will have my compiler and its libraries installed such as including and referencing libraries that add built-in functionality like std I/O. Since this is my first venture into compilers I feel that it's appropriate to only target Linux distributions for the time being.
I notice that a lot of compilers (and software projects in general) include makefiles or perhaps an install.py file that move parts of the application across the user's file system and will ultimately leave the user with something like a new shell command to run the program, which, (in a compiler such as python's case) knows where the necessary libraries are and where the other necessary files have been placed in order to run the program properly.
How does this work? Is there some sort of guideline to follow when designing these install files?
I think the best guideline I can give you at a high level would be:
Don't do this yourself. Just don't.
Use something like the autotools or any of the dozen or so other build systems out there that handle much of the details involved here for you.
That being said they also add a certain amount of complexity when you are just starting out and that may or may not be worth the effort to start with but they will all pay off in the end assuming you use them appropriately and don't need anything too extensively specialized that they don't provide nicely.

possible issues with class dependencies in Ruby [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
After learning power of Rails framework, I have started learning ruby. In Ruby, I learnt that I can add methods to a class at runtime. In Java, we have to define all methods before compilation. I suppose, this advantage in Ruby gives rise to issues with class dependancies. As I am new to Ruby, could anyone please explain in what way do I lose control by adding methods dynamically.
Being able to add methods at runtime doesn't impact the dependencies in any way, or at least not any more than writing any other code would.
The only difference is that you can now have methods "written" as-needed, but you will still have the same dependency issues if you wrote the code yourself. Since ruby is a dynamic language, it's sense of dependencies is rather different from a more "traditional" statically compiled language like C++ or Java, but even in Java you can load arbitrary code at runtime (it's much more difficult, but still possible).

Pitfalls to avoid when writing project specs [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
I'm currently trying to write up some software specs for a large-ish project that I'd like to bid out on oDesk (maybe 3k-6k). I have a classical education in computer science, but minimal work experience and I've never worked in a corporate environment.
I've written up 15 pages of project specs for an API that I want to run on Google App Engine. I'm finding the subtleties difficult with issues such as: where to draw the line on what to specify and what not to; how to break the project up into pieces so that if one part goes wrong, other parts can still be used; where and how to set milestones; and how to screen for a candidate who has the skills to properly implement the specs.
I asked a friend what issues I should watch out for and he said:
Make sure specs do not have contradictory information
Make sure specs are not unnecessarily specific because this will turn off more skilled developers
What other pitfalls and common mistakes should I look out for while drawing up project specs?
While it is important to focus on the functionality of what you want to achieve, also keep in mind the non-functional requirements as well. Think about how you want it to perform, security considerations, etc.
One to add to the list
Make sure the specs are unambiguous. (Can only be interpreted one way...Hopefully)
I think these two links will help:
On Reqs And Specs: http://www.pragmaticmarketing.com/publications/topics/02/0204sj
Painless Functional Specifications - Part 2: What's a Spec?: http://www.joelonsoftware.com/articles/fog0000000035.html

how to manage a compiler project? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I am a CS student and I have a compiler project this year.
I want to know how to manage my project with my three partners.
I know that the compiler has many level and process, and I want to make use of these features to mange my project.
Thanks for any tips/pointers/resources you can provide for me to start.
You haven't really specified what it is that you are compiling, so it's a little difficult to make specific recommendations.
If you're doing something novel, I wrote a blog post a couple of weeks ago that has some specific things to consider:
http://www.plsadventures.com/2009/09/why-programming-language-design-is-hard.html
If it is a pre-existing language you are compiling, then I would work to generate a decent test corpus, and consider using test-driven development to manage your progress.
As you mentioned, there are some obvious components in most compilers that are relatively discrete. I would consider documenting the interfaces that connect these components. For example, if one person is writing the lexer and another is writing the parser, then ensure that you have a list of tokens written down somewhere. The format for your parse and/or abstract syntax trees should be defined and written down so that anybody working on optimisation or code generation is on the same page.
Above all, tests really help this kind of integration. You should be able to build these components separately and put them together, for the most part.
You should use a DCVS like Git or Mercurial, so each of you can develop individually while it's still easy to merge changes.
Next, you should define test cases to know which features you'll need and how you will know that a feature works.
That should help to figure out different areas of the project which don't overlap too much so each member of the team can work without stepping on each others toes.

Resources