AG-Grid? ??, ???, ??? ??? ?? ??? ?? ?? ??? ???? ???? ? ???? ??? JavaScript ??? ??? ????????. ? ????? AG-Grid? ???? ?? Go?? API? ???? ???, ??, ??? ??? ??? ???? ?? ? ??? ??? ???? ???. AG-Grid? Go API? ???? ??? ??? ??? ??? ?? ??? ??? ???? ??? ???? ??? ????.
?? ??
- 1.21? ??
- MySQL
???? ??
Go ???? ???? ?????.
go mod init app go get github.com/gin-gonic/gin go get gorm.io/gorm go get gorm.io/driver/mysql go get github.com/joho/godotenv
"example"??? ???? ??????? ???? Database.sql ??? ???? ???? ???? ?????.
???? ??
├─ .env ├─ main.go ├─ config │ └─ db.go ├─ controllers │ └─ product_controller.go ├─ models │ └─ product.go ├─ public │ └─ index.html └─ router └─ router.go
???? ??
.env
? ???? ?????? ?? ??? ???? ????.
DB_HOST=localhost DB_PORT=3306 DB_DATABASE=example DB_USER=root DB_PASSWORD=
db.go
? ??? GORM? ???? ?????? ??? ?????. ??? ???????? ??? ?????? ?? ????? ???? ?? ?? ?? DB? ?????.
package config import ( "fmt" "os" "github.com/joho/godotenv" "gorm.io/driver/mysql" "gorm.io/gorm" "gorm.io/gorm/schema" ) var DB *gorm.DB func SetupDatabase() { godotenv.Load() connection := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", os.Getenv("DB_USER"), os.Getenv("DB_PASSWORD"), os.Getenv("DB_HOST"), os.Getenv("DB_PORT"), os.Getenv("DB_DATABASE")) db, _ := gorm.Open(mysql.Open(connection), &gorm.Config{NamingStrategy: schema.NamingStrategy{SingularTable: true}}) DB = db }
router.go
? ??? Gin ? ??????? ?? ???? ?????. DataTables API? ???? ????? ?? URL?? ?? index.html ??? ?????.
package router import ( "app/controllers" "github.com/gin-gonic/gin" ) func SetupRouter() { productController := controllers.ProductController{} router := gin.Default() router.StaticFile("/", "./public/index.html") router.GET("/api/products", productController.Index) router.Run() }
product.go
? ??? ??????? ?? ??? ?????.
package models type Product struct { Id int Name string Price float64 }
product_controller.go
? ??? ???? ??? ???? DataTables ???? ???? ??? ?????.
package controllers import ( "app/config" "app/models" "net/http" "strconv" "github.com/gin-gonic/gin" ) type ProductController struct { } func (con *ProductController) Index(c *gin.Context) { size, _ := strconv.Atoi(c.DefaultQuery("length", "10")) start, _ := strconv.Atoi(c.Query("start")) order := "id" if c.Query("order[0][column]") != "" { order = c.Query("columns[" + c.Query("order[0][column]") + "][data]") } direction := c.DefaultQuery("order[0][dir]", "asc") var products []models.Product query := config.DB.Model(&products) var recordsTotal, recordsFiltered int64 query.Count(&recordsTotal) search := c.Query("search[value]") if search != "" { search = "%" + search + "%" query.Where("name like ?", search) } query.Count(&recordsFiltered) query.Order(order + " " + direction). Offset(start). Limit(size). Find(&products) c.JSON(http.StatusOK, gin.H{"draw": c.Query("draw"), "recordsTotal": recordsTotal, "recordsFiltered": recordsFiltered, "data": products}) }
product_controller.go ??? Gin ?????? ???? Go ???????? ?? ?? API ??? ???? ?? ????? ?????. ??? ??, ?? ? ??? ?? ?? ????? ???? ???? ??? ?? ??? ???? Index ???? ?????. ? ???? ??? ??? ?? ?? ??? ????, ???????? ??? ???? ??? ????, ???? ???? ???? ?????. ???? ? ?? ?? ??? ? ?? ???? ? ??? ??? JSON ??? ???? ?? ??? ???? ???? ????? ???????? ??? ???? ???.
main.go
? ??? ??????? ?? ??????. Gin ? ??????? ???? ?????.
package main import ( "app/config" "app/router" ) func main() { config.SetupDatabase() router.SetupRouter() }
index.html
<!DOCTYPE html> <head> <script src="https://cdn.jsdelivr.net/npm/ag-grid-community/dist/ag-grid-community.min.js"></script> </head> <body> <div> <p>The index.html file sets up a web page that uses the AG-Grid library to display a dynamic data grid for products. It includes a grid styled with the AG-Grid theme and a JavaScript section that constructs query parameters for pagination, sorting, and filtering. The grid is configured with columns for ID, Name, and Price, and it fetches product data from an API endpoint based on user interactions. Upon loading, the grid is initialized, allowing users to view and manipulate the product list effectively.</p> <h2> Run project </h2> <pre class="brush:php;toolbar:false">go run main.go
? ????? ?? http://localhost:8080
?? ?????.
? ??? ???? ?? ? ????.
???
??? ?? ???
'??? ??' ?????? 50? ???? ??? ??? ?????. ???? 50?? ???? ???? ??? ???? 5??? 2?? ?????.
?? ???
? ?? ?? ??? ?????. id ??? ?????? ???? ?? ?? ? ? ????.
?? ???
'??' ??? ???? '???'? ????? ???? ?? ???? ?? ? ????.
??
????? ??? AG-Grid? Go API? ????? ???? ???? ???? ??? ??? ???? ??????. Go? ??? ??? ???? AG-Grid? ??? ???, ?? ? ??? ??? ??? ? ??? ?? ??? ??? ????? ??? ??? ??????. ? ??? ??? ??? ???? ?? ??? ?????? ?? ??? ???? ?? ??? ??? ??????. AG-Grid? Go? ???? ???? ?? ??????? ??? ?? ??? ??? ??? ???? ??????.
?? ??: https://github.com/stackpuz/Example-AG-Grid-Go
? ? ?? CRUD ? ? ???: https://stackpuz.com
? ??? Go? ???? AG-Grid? API ???? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

??? ??











GO? ????? ????? ??? ????? ??????. ?? ??? ?? ?????. 1. ? ??? ?? : Linux ????? ?? ??? ?????? ??? ??? ? ????. 2. ?? ??? ??? ?? ???? ???? ?? ??? ????? ?? ??? ?? ?? ??? ?? ??? ? ? ????. 3. ?? ?? ???? ?? : ?? ????? ??? ??? ?? ??? ??? ???? ??????. 4. ??? ?? ??? : ??? ???? ????? ?? ?????? ? ???? ? ? ??? ??? ? ??? ?????. ??? ??? CLI ??, ???? ??? ? ?? ????? ????? ????? ????? ?? ??? ??? ???? ????? ???? ??? ?????.

goensuresmemorysafety? ?? MemolemanucameThrougatomaticgargarbagecollection, nopointerarithmetic, safeconcurrency, andruntimechecks.first, go'sgarbagecollectoricallyally reclaimsunusedmemory, ??, itdisallowspointe, itdisallowspointe ??

GO?? ?? ??? ???? MAKE ??? ?? ?? ?? ? ??????. ?? ??? ???? ??? ??? ???? ?? ? ???? ?? ? ?? ??? ???? ?? ? ???? ??? ??? ? ????. ?? ??, ch : = make (Chanint, 10)? ?? 10 ?? ?? ?? ??? ??? ?? ??? ????. ???? ?? ??? ??, ??? ???? ?? ???? ??? ???? ???? ?? ? ??? ??? ????? ?????. ??? ??? ?, ?? : 1. ?? ??? ??? ??? ?? ??? ??? ??? ?? ?????????. 2. ??? ??? ??? ??? ??? ???? ?? ???????. 3. ??? chanstruct {} ??? ?? ?? ? ? ????. ???? ?????? ??? ?, ??? ??? ?? ? ???? ?????.

GO? ??? ?????? ??????. C? ?? ??? ? ??? ??? ?? ??? ?? ??? ? ??? ???? ?? ?????. 1. ?? ? ???? ?? ???? Go? OS ???? ?? ? ????? ????? ??? ??, ??, ?? ??? ? ???? ?? ?????. OS.ReadFile? ???? ? ?? ??? ?? ??? ?????. ?? ???? ?? ?? ?? ??? ???? ? ?????. 2. ???? ?? ???? OS/EXEC ???? exec.command ??? ?? ??? ????, ??? ????, ?? ??? ????, ?? ? ?? ??? ?????? ?? ??, ??? ?? ? ?? ????? ??? ???? ????? ?? ? ? ????. 3. ???? ? ??? ???? Net ???? TCP/UDP ?????, DNS ?? ? ?? ??? ?????.

GO ???? ?? ??? ????? ?? ???? ????? ?? ? ???? ???? ??? ??? ???? ????????. ?? ???? ??? ?, ???? ? ??? ?? ??? ???? ?? ?? ? ? ????. 1. func (rrectangle) area () int? ?? ? ???? ???? rect.area ()? ?? ?? ??????. 2. ??? ?? ???? ?? func (r*???) setwidth (...)? ?? ??? ???? ???? ???? ?? ??? ???? ?????. 3. ??? ?? ? ?, ?? ??? ??? ?? ? ???, ?? ??? ?? ?? ?? ? ???. 4. Go? Getter/Setter? ??? ???? ??????.

GO?? ?????? ??? ???? ?? ??? ???? ?????. ?????? ??? ???? ???? ??? ??? ???? ?? ??? ?????? ???? ??????. ?? ??, speak () ???? ?? ? ??? ?????? ???? ???? ???? ?? ??? ???? ?? ? ? ????. ?????? ???? ??, ?? ?? ?? ?? ? ????? ?? ????? ???? ? ?????. ?????? ???? ????? ???? ???? ??? ??? ???? ??? ?? ??? ???? ?? ?????? ?????. ???? ?? ???? ??, ??, ?? ?????? ?? ???? ??? ? ?? ???? ?????. ?? ??, ?? ?? ??? ?? ??? ??? ???? ??? Anno? ??? ? ????.

Go Language?? ??? ??? ?? ??? ??? ? ?? ??? ?? ?????. 1.Strings.contains ()? ???? ?? ???? ???? ??? ??? ???? ?? ?? ???? ? ?????. 2.strings.index ()? ???? ?? ???? ???? ??? ?? ? ??? ???? ??? -1? ?????. 3.strings.replaceall ()? ?? ???? ?? ??? ?? ? ? ??? Strings.replace ()? ?? ?? ?? ?? ? ? ????. 4.Len () ??? ???? ??? ??? ?? ? ????? ?? ??? ?? ? ?? ??? ???? ?????? ???????. ??? ??? ?? ??? ???, ??? ?? ?? ? ??? ??? ?? ?????? ?????.

TheGoiopackageprovidesinterfaceslikeReaderandWritertohandleI/Ooperationsuniformlyacrosssources.1.io.Reader'sReadmethodenablesreadingfromvarioussourcessuchasfilesorHTTPresponses.2.io.Writer'sWritemethodfacilitateswritingtodestinationslikestandardoutpu
