ChatGPT has taken the world by storm. There are a ton of use cases I have been playing with. The most profound of those being using chatgpt as a 'rubber ducky' feeding it code and an error in an attempt to solve the issue at hand. Unsure of which package has the needed functionality? ChatGPT may not give you an answer correctly the fist time, but given correct prompts and guidance can be a tool to rapidly speed up you development debugging.
When taking a piece of code to chatgpt one must be aware of the most efficient prompt templates that will generate the response we want, and not unrelated facts or formats. You can think of a prompt being the question we ask the AI.
Using code examples are a great way to give context to chatGPT about your current problem. Taking a main.go
as the first prompt field, then on a newline, informing chatGPT exactly what we wish to do with that main.go
.
Our prompt template can be thought of like this.
{Code example ie. main.go} {The request for new functionality specifying to edit the existing code and add a new function} {any specific guidance that may be needed}
To elaborate on the guidance, chatGPT may think something is a part of a package in Golang, when in fact is not. To give an example, I was asking chatGPT to explain how one might use a go function to load an executable into memory (more on AI runes later).
ChatGPT would get confused, and think packages that must be called via sys call.Syscall() could be called via the windows package. By looking at the original response we can add guidance that Windows does not contain the package it's looking for. More often than not, this would fix the response from ChatGPT to work as expected.
This is just a short way to use prompt templates to rubber ducky with chatGPT. I hope this can save you some StackExchange searches :)
Top comments (0)