Skip to main content
Version: 2.8.x(Latest)

GoFrame

GoFrame is a modular, high-performance, production-grade Go foundational development framework. It implements comprehensive infrastructure and development toolchains, offering common foundational development modules such as cache, logging, queues, arrays, collections, containers, timers, command lines, memory locks, object pools, configuration management, resource management, data validation, data encoding, scheduled tasks, database ORM, TCP/UDP components, process management/communication, etc. It also provides a series of core components for Web service development, such as Router, Cookie, Session, Middleware, service registration, template engine, etc., supporting features like hot restart, hot updates, domain binding, TLS/HTTPS, Rewrite, etc.

Features

  • Modular and loosely-coupled design;
  • Rich modules, ready to use;
  • Simple and easy to use, easy to maintain;
  • High code quality, high unit test coverage;
  • Active community, with humble and approachable experts;
  • Detailed development documentation and examples;
  • Comprehensive local Chinese support;
  • Designed for team and enterprise use;

Support Us

The OSC Best Open Source Project competition has begun. If you like GoFrame, please cast your valuable vote for GoFrame 🙏 https://www.oschina.net/p/goframe

Change Log

Since GoFrame is designed modularly, the update log for each version is introduced in the form of modules.

Important updates:

  1. Replaced all json operations within the framework from the standard library to json-iterator/go, improving operational efficiency.
  2. Refactored the underlying design of the cache module, adding adapter design patterns, and adding memory and Redis adapter support. The memory adapter is provided by the default core module, while the Redis adapter is provided by the community module: https://goframe.org/os/gcache/adapter
  3. Added customizable validation rule registration feature: https://goframe.org/util/gvalid/customrule
  4. Web Server added examples for all configuration items: https://goframe.org/net/ghttp/config/example
  5. ORM added SQL cache adapter based on Redis: https://goframe.org/database/gdb/model/cache
  6. ORM added experimental feature for model associations: https://goframe.org/database/gdb/model/association
  7. Improved automatic update feature of time in ORM, adding customizable time fields: https://goframe.org/database/gdb/model/auto-time
  8. Error handling module added Current and Next methods: https://goframe.org/errors/gerror/index

net

  1. ghttp
    • Client
    • Request
      • Added ParseQuery, ParseForm methods to parse specified parameter types and bind them to a given object.
      • Added GetHeader method to get specified Header parameters.
      • Added GetRemoteIp method to get the IP of the requesting client. When using IP whitelist restrictions, use GetRemoteIp instead of GetClientIp, as the latter can be forged through Header.
      • Added ReloadParam method, often used in middleware processing when middleware modifies request parameters and calls this method to reparse them.
      • Added GetRouterMap method to get all routing parameters returned as a map.
    • Response
      • Renamed Output method to Flush, used for writing buffer data to the client stream.
    • Server
      • Server added examples for all configuration items: https://goframe.org/net/ghttp/config/example
      • Added SessionCookieOutput configuration to control whether to output SessionId to Cookie, enabled by default.
      • Improved route parsing to support URI with repeated / symbols.
      • Pprof function routes support Domain binding.
      • Other minor improvements.
    • Cookie
      • Added SetHttpCookie method to set Cookie based on a standard library http.Cookie object.
      • Other functional improvements.

database

  1. gdb

    • Added experimental feature for model associations: https://goframe.org/database/gdb/model/association
    • Improved automatic update feature of time, adding customizable time fields: https://goframe.org/database/gdb/model/auto-time
    • Added SQL cache adapter based on Redis: https://goframe.org/database/gdb/model/cache
    • Added automatic recognition mapping feature for input parameter key names and field names: https://goframe.org/database/gdb/senior
    • Added DB.HasTable method to determine whether the current database contains the specified table.
    • Added Model.HasField method to determine whether the current table contains the specified field.
    • Added Model.ScanList method to intelligently bind the current struct/slice to the specified list corresponding attributes.
    • Added Result.MapKeyValue method to convert the current Result to map[string]Value type.
    • Added Result.IsEmpty/Len/Size/ScanList methods.
    • Added ListItemValues and ListItemValuesUnique methods to automatically get the values or properties with specified names in the list, returning them as a slice.
    • SQL log content includes group name printing.
    • Improved DataToMapDeep method.
    • Other minor improvements.
  2. gredis

container

  1. gvar
    • Added Scan and ScanDeep methods for automatic recognition and conversion of struct/slice.
    • Added ListItemValues and ListItemValuesUnique methods to automatically get the values or properties with specified names in the list, returning them as a slice.
    • Added MapStrAny interface implementation method.

os

  1. gcache

    • Added GetVar method to get cached data and return it as a generic object.
    • Added Update method to only modify cache values without modifying expiration times.
    • Added UpdateExpire method to only modify cache expiration times without modifying values.
    • Refactored underlying design, adding adapter design patterns, and memory and Redis adapter support. The memory adapter is provided by the default core module, and the Redis adapter is provided by the community module: https://goframe.org/os/gcache/adapter
    • Note, this module modification may have some method incompatibility, some methods added error parameter return, please review carefully when upgrading. Compilation will not pass.
    • Other functional improvements.
  2. gfile

    • Added ScanDirFileFunc method for recursive directory file traversal with a custom function handler.
    • Improved Scan* methods with added recursion level limits, default is 100000.
  3. gfsnotify

    • Removed Watcher object creation during module initialization, adjusted to runtime on-demand creation, with added concurrency safety controls.
  4. grpool

    • Added AddWithRecover method for adding asynchronous tasks with a given recover handling method, processing panic in tasks to prevent the entire process crash.
    • Solves the issue that recover can only capture panic in the current goroutine, therefore a specific recover handling method can only be specified when creating asynchronous tasks.
  5. gtime

    • Added ParseDuration method with support for time unit d representing days.
    • Improved `` method with support to create gtime.Time objects from strings, timestamps, time.Time objects, https://goframe.org/os/gtime/time
    • Improved Add/AddStr/ToLocation/ToZone/UTCLocal/AddDate/Truncate/Round methods, these methods now create and return new gtime.Time objects without altering the current object itself to ensure consistency with the standard library time.Time logic and avoid confusion.
    • Other minor improvements.
  6. gtimer

    • Added Reset method for resetting timer task counts.
  7. gfcache

    • Removed the module, as its functionality was not particularly significant.

debug

  1. gdebug
    • Added GoroutineId method to get the goroutine id of the current execution, for debugging purposes only.

encoding

  1. gjson

    • Added GetScan/GetScanDeep methods.
    • Added ToScan/ToScanDeep methods.
    • Added LoadContentType method to create Json operation objects based on specified content types.
    • Added IsValidDataType method to determine if a given data type is parseable.
    • Other improvements.
    • Comprehensive unit testing.
  2. gcompress

    • Added GzipFile/UnGzipFile methods based on gzip compression algorithm for file compression/decompression.

i18n

  1. gi18n

text

  1. gstr
    • Added SnakeFirstUpperCase method, which adds connectors before uppercase letters and does not process numbers, e.g., SnakeFirstUpperCase("RGBCodeMd5") will return rgb_code_md5.

util

  1. gconv

    • Added support for basic pointer type conversion.
    • Added Scan/ScanDeep methods for automatic recognition and conversion of Struct/[]Struct.
    • Improved recursive layer handling in MapDeep method.
    • Other minor and performance improvements.
  2. gutil

    • Added ListItemValues and ListItemValuesUnique methods to automatically get values or properties with specified names in the list, returning them as a slice.
    • Added ItemValue method to get key/property values of specified map/*map/struct/*struct types.
    • Added MapOmitEmpty method to filter empty values in a map.
    • Added SliceDelete method for array item deletion.
    • Added Try method, which executes a given method through a closure and returns error if the method panic, otherwise returns nil.
    • Improved TryCatch(try func(), catch ...func(exception interface{})) to TryCatch(try func(), catch ...func(exception error))
  3. gvalid

error

  1. gerror
    • Added Current method to get the error interface object of the current error level.
    • Added Next method to get the next level error error interface object. If the next level does not exist, returns nil.
    • Documentation update: https://goframe.org/errors/gerror/index

Bug Fix

  1. Fixed Unique method issue in garray module.
  2. Fixed goroutine leak issue in glog during lazy initialization of the timer.
  3. Fixed naming Case conversion issues in gstr when names contain numbers and special characters.
  4. Fixed CORS cross-domain setting Header detail issue in ghttp module.
  5. Other BUG fixes: https://github.com/gogf/gf/issues?q=is%3Aissue+label%3Abug+is%3Aclosed