Upgrading To v1.11 From v1.10
v1.11.3
Bug Fixes 🐛
- The problem of process interruption caused by panic in Schedule
- The problem that DailyAt in Schedule will be executed every minute
v1.11.2
Bug Fixes 🐛
v1.11.1
Exciting New Features 🎉
Bug Fixes 🐛
- Fix the error of incorrect windows path for Filesystem
- Fix the panic of the Header method for Request
v1.11.0
Exciting New Features 🎉
Enhancements 🚀
- Cache add and optimize methods(1.11.0)
- Route supports Fallback route(1.11.0)
- Orm adds new methods(1.11.0)
- Optimize facades.Config.Add()(1.11.0)
- Change Sqlite driver(1.11.0)
- contracts/http add method mapping of net/http(1.11.0)
Breaking Changes 🛠
Bug Fixes 🐛
- The problem that the hashing configuration does not take effect under some situations(1.11.0)
- Non-thread safety problems in RateLimiter(1.11.0)
Upgrade Guide
Please upgrade the framework step by step according to the content in this section.
Estimated Upgrade Time: 1 Minutes
1. Updating Dependencies
Update dependencies in the go.mod file:
go get -u github.com/goravel/framework@v1.11.0 && go mod tidy2. Remove deprecated methods
import (
"github.com/goravel/framework/database"
"github.com/goravel/framework/database/gorm"
)
// Deprecated
database.NewGormInstance()
// Replace with(Note: This method is not recommended, please try not to use it)
gorm.New()
// Deprecated
facades.Orm.Query().Updates()
// Replace with(Only modify the method name is fine, no need to modify the parameters)
facades.Orm.Query().Update()
// The Update method changes return value
// Before
err := facades.Orm.Query().Update()
// After
res, err := facades.Orm.Query().Update()New Content
This section does not involve code changes, only enhancements.
Orm add model events
Version: v1.11.1
Orm models dispatch several events, allowing you to hook into the following moments in a model's lifecycle: Retrieved, Creating, Created, Updating, Updated, Saving, Saved, Deleting, Deleted, ForceDeleting, ForceDeleted.
Cache add and optimize methods
Version: v1.11.1
New Methods
| Methods | Action |
|---|---|
| Decrement | Decrement |
| Increment | Increment |
| Lock | Atomic Locks |
| Store | Accessing Multiple Cache Stores |
Optimize methods
Get, GetBool, GetInt, GetInt64, GetString, Pull no longer need to pass a default value(Backwards compatible).
Route supports Fallback route
Version: v1.11.1
You may define a route that will be executed when no other route matches the incoming request.
facades.Route.Fallback(func(ctx http.Context) http.Response {
return ctx.Response().String(404, "not found")
})Orm adds new methods
Version: v1.11.1
| Method | Action |
|---|---|
| db.Raw | Raw Expressions |
| LockForUpdate | Pessimistic Locking |
| SharedLock | Pessimistic Locking |
Optimize facades.Config.Add()
Version: v1.11.0
The configuration parameter of facades.Config.Add() changes to any from map[string]any, make configuration more flexible.
Change Sqlite driver
Because github.com/mattn/go-sqlite3 requires CGO to be started, so replacing a third-party package that does not require CGO: github.com/glebarez/go-sqlite.
contracts/http add method mapping of net/http
Version: v1.11.0
You can use http.MethodGet in controller directly, instead of import net/http.
Route Add Resource Routing
Version: v1.11.1
facades.Route.Resource("/resource", resourceController)Request Add New Methods
Version: v1.11.1
| Method | Action |
|---|---|
| All | Retrieving all input data |
| Host | Retrieving the request HOST |
| Queries | Retrieving input from the query string |
About to be deprecated the Form, Json methods, please use Input instead.
Storage Add New Methods
Version: v1.11.1
| Method | Action |
|---|---|
| LastModified | Get the last modified time of file |
| MimeType | Get the mime type of file |
File Add New Methods
Version: v1.11.1
| Method | Action |
|---|---|
| LastModified | Get the last modified time of file |
| MimeType | Get the mime type of file |
| Size | Get the size of file |
Fix The Error Of Incorrect Windows Path For Filesystem
Version: v1.11.1
There is a wrong slash in windows system.
Fix The Panic Of The Header Method For Request
Version: v1.11.1
ctx.Request().Header( key: "token") will panic.
Fix The Data Error Of Using Request.Input() And Request.Bind() At The Same Time
Version: v1.11.2
Request.Input() will clear Request.Body, if you use Request.Bind() after that, you will not be able to get the data correctly.
The problem of process interruption caused by panic in Schedule
Version: v1.11.3
The Schedule process will interruption when occurring panic, all tasks wil lbe affected.
The problem that DailyAt in Schedule will be executed every minute
Version: v1.11.3
Fix the problem that DailyAt will be executed every minute:
func (kernel *Kernel) Schedule() []schedule.Event {
return []schedule.Event{
facades.Schedule.Call(func() {
fmt.Print("1")
}).DailyAt("18:00"),
}
}