module
0.0.0-20240610135142-bf44f1a53b44
Repository: https://github.com/golangast/sugargen.git
Documentation: pkg.go.dev
# README
General info
This is a utility for terminals, inputs and generating code.
Requirements
- go 1.21.5
Why build this?
-
Go never changes
-
Created sugar syntax to allow others and myself to create projects like Switchterm
-
This is a walkthrough video on explaining how to use this project.
-
the following is how you use it and there is an example file in the example folder.
// Parse command line input for a question
answer := input.InputScanDirections("what is your name?")
fmt.Println(answer, " nice name")
// show a list of selection and chosen one is stored
var colorsslice = []string{"red", "green", "blue", "yellow"}
//remember you can set the number from 1 to whatever you want. 1 is the number of columns
//to add colors update the colors/colors.go file and use https://en.wikipedia.org/wiki/ANSI_escape_code#colors
coloranswer := input.MenuInstuctions(colorsslice, 1, "purple", "purple", "which color do you prefer to use?")
fmt.Println(coloranswer, " is the right answer")
//what can you do with all this? Plenty!
//how about lets make a folder file from the answers
if err := filefolder.Makefolder(answer); err != nil {
text.Checklogger(err, "trying to create folder")
}
file, err := filefolder.Makefile(answer + "/" + coloranswer + ".txt")
text.Checklogger(err, "trying to add text to file")
//you wanna update text in it? Sure we can do that.
//we need some text first.
var sometext = `This is some text but lets add a template map {{.name}}`
//create a map
mb := make(map[string]string)
mb["name"] = answer
//now lets do some generating
if err := gen.Writetemplate(sometext, file, mb); err != nil {
text.Checklogger(err, "trying to create folder")
}
//now lets try to update the text "template map" in the file to "template cat".
text.UpdateText(answer+"/"+coloranswer+".txt", "template map", "template map", "template cat")
//now lets spit out whats in the file using bach in go.
if err := bash.ShellBash("cat ./" + answer + "/" + coloranswer + ".txt"); err != nil {
text.Checklogger(err, "trying to do bash in go")
}
//start training the model! specify the model name and the filename
chat.CheckIfSpanLimitsEqualText("server", "server.json")
//use an input to ask a question
ans := input.InputScanDirections("What would you like to do?")
//get data from the model
text, label := chat.GetTextLabelFromGlob(ans)
fmt.Println(text)
fmt.Println(label)
//start to use that data to run commands!
if slices.Contains(label, "server") {
fmt.Println("Starting the server...")
}
//how do you train your own model? the following explains how.
//a training file is required and it does have to have pre-processed data
//in a particular format.
/*
[
{
"Text": "sentence that contains the text or phrase",
"Spans": [
{
"Start": 13, //where the word or phrase starts
"End": 28, //where the word or phrase ends
"Label": "server" //name of the mobel
}
],
"Answer": "reject" //whether it will be accepted or rejected
},
]
technically you can add spans and create more models and
change the format but you will need to update the data structure
right now we are going to use /server.json
The name of the model does matter
*/
//now you have the ability to get user input two different ways and generate files, update text, use bash,
//and train a model and use that data for commands
//the rest is up to you!
Things to remember
- using atomicgo.dev/keyboard there is no way to call itself after a key press
Licenses
- GNU 3 for my code
- MIT License for atomicgo keyboard
- MIT License for sprig
- BSD-3-Clause for sqlite driver
- MIT License for Prose
- BSD-3-Clause for Go itself
Special thanks
- Go Team because they are gods
- Creators of https://pkg.go.dev/modernc.org/sqlite -
- Creators of https://github.com/Masterminds/sprig-
- Creators of https://github.com/atomicgo/keyboard -
- Creators of https://github.com/jdkato/prose
Why Go?
- The language is done since 1.0.https://youtu.be/rFejpH_tAHM there are little features that get added after 10 years but whatever you learn now will forever be useful.
- It also has a compatibility promise https://go.dev/doc/go1compat
- It was also built by great people. https://hackernoon.com/why-go-ef8850dc5f3c
- 14th used language https://insights.stackoverflow.com/survey/2021
- Highest starred language https://github.com/golang/go
- It is also number 1 language to go to and not from https://www.jetbrains.com/lp/devecosystem-2021/#Do-you-plan-to-adopt--migrate-to-other-languages-in-the-next--months-If-so-to-which-ones
- Go is growing in all measures https://madnight.github.io/githut/#/stars/2023/3
- Jobs are almost doubling every year. https://stacktrends.dev/technologies/programming-languages/golang/
- Companies that use go. https://go.dev/wiki/GoUsers
- Why I picked Go https://youtu.be/fD005g07cU4
# Packages
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author