1212
1313[ English] ( README.md ) | [ 中文] ( README_CN.md )
1414
15+ > The project has been officially released, welcome to use!
16+
1517** Go-Spring is a high-performance framework for modern Go application development, inspired by the Spring / Spring Boot
1618ecosystem in the Java community.**
1719Its design philosophy deeply integrates the characteristics of the Go language, retaining mature development paradigms
@@ -105,8 +107,8 @@ func init() {
105107 return http.DefaultServeMux
106108 })
107109
108- sysconf. Set (" start-time" , time.Now ().Format (timeLayout))
109- sysconf. Set (" refresh-time" , time.Now ().Format (timeLayout))
110+ gs. Property (" start-time" , time.Now ().Format (timeLayout))
111+ gs. Property (" refresh-time" , time.Now ().Format (timeLayout))
110112}
111113```
112114
@@ -126,7 +128,7 @@ func (s *Service) Echo(w http.ResponseWriter, r *http.Request) {
126128}
127129
128130func (s *Service ) Refresh (w http .ResponseWriter , r *http .Request ) {
129- sysconf. Set (" refresh-time" , time.Now ().Format (timeLayout))
131+ gs. Property (" refresh-time" , time.Now ().Format (timeLayout))
130132 gs.RefreshProperties ()
131133 w.Write ([]byte (" OK!" ))
132134}
@@ -387,7 +389,7 @@ func (a *App) ServeHTTP(w http.ResponseWriter, r *http.Request) {
387389}
388390
389391func RefreshVersion (w http .ResponseWriter , r *http .Request ) {
390- sysconf. Set (versionKey, " v2.0.1" )
392+ gs. Property (versionKey, " v2.0.1" )
391393 gs.RefreshProperties ()
392394 fmt.Fprintln (w, " Version updated!" )
393395}
@@ -563,47 +565,7 @@ func init() {
563565
564566## ⏳ Mock and Unit Testing
565567
566- Go-Spring provides a unit testing framework that seamlessly integrates with the standard ` go test ` , making dependency
567- injection and mock testing simple and efficient.
568-
569- ### 1. Mock Object Injection
570-
571- Use ` gstest.MockFor[T]().With(obj) ` to easily replace any bean at runtime:
572-
573- ``` go
574- gstest.MockFor [*book_dao.BookDao ]().With (&book_dao.BookDao {
575- Store : map [string ]book_dao.Book {
576- " 978-0132350884" : {
577- Title: " Clean Code" ,
578- Author: " Robert C. Martin" ,
579- ISBN: " 978-0132350884" ,
580- Publisher: " Prentice Hall" ,
581- },
582- },
583- })
584- ```
585-
586- ### 2. Obtain Test Objects
587-
588- There are two ways to obtain the object under test:
589-
590- ** Directly Get Instance** :
591-
592- ``` go
593- o := gstest.Get [*BookDao](t)
594- assert.NotNil (t, o)
595- ```
596-
597- ** Structured Injection** :
598-
599- ``` go
600- s := gstest.Wire (t, new (struct {
601- SvrAddr string ` value:"${server.addr}"`
602- Service *BookService ` autowire:""`
603- BookDao *book_dao.BookDao ` autowire:""`
604- }))
605- assert.That (t, s.SvrAddr ).Equal (" 0.0.0.0:9090" )
606- ```
568+ ...
607569
608570## 📚 Comparison with Other Frameworks
609571
0 commit comments