This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bytes" | |
"crypto" | |
"crypto/rand" | |
"crypto/rsa" | |
"crypto/sha512" | |
"fmt" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"database/sql" | |
"fmt" | |
"github.com/gdamore/tcell/v2" | |
_ "github.com/go-sql-driver/mysql" | |
"github.com/rivo/tview" | |
"log" | |
"strconv" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
"log" | |
) | |
type Builder struct { | |
ResponseRoot |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
"log" | |
) | |
type MyResponseRoot struct { | |
Version string `json:"version,omitempty"` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
"log" | |
) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
func increment(ptr *int) { | |
*ptr = *ptr + 1 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://go.dev/play/p/5Grp31thhPr | |
package main | |
import "fmt" | |
type Start struct { | |
Number1 float64 | |
Number2 float64 | |
Text string | |
RequestHandler RequestHandler |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
// using a variadic function | |
func find(num int, nums ...int) { | |
fmt.Printf("type of nums is %T\n", nums) | |
found := false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Response struct { | |
Text string `json:"text,omitempty"` | |
SessionAttributes map[string]any `json:"sessionAttributes,omitempty"` | |
} | |
func main() { | |
var renderA Response | |
renderA.Text = "dsds" | |
renderA.SessionAttributes = make(map[string]interface{}) //https://dev.to/rytsh/embed-map-in-json-output-5dnj | |
renderA.SessionAttributes["read"] = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://www.appsloveworld.com/go/12/embedding-when-to-use-pointer | |
//https://go.dev/play/p/IeUvieCOjs4 | |
//https://go.dev/play/p/IeUvieCOjs4 You can use one or the other: for struct type, the spec mentions: | |
//A field declared with a type but no explicit field name is an anonymous field, also called an | |
//embedded field or an embedding of the type in the struct. | |
//An embedded type must be specified as a type name T or as a pointer to a | |
//non-interface type name *T, and T itself may not be a pointer type | |
package main |