mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-10-31 00:42:24 -05:00 
			
		
		
		
	* update dependencies, bump Go version to 1.19 * bump test image Go version * update golangci-lint * update gotosocial-drone-build * sign * linting, go fmt * update swagger docs * update swagger docs * whitespace * update contributing.md * fuckin whoopsie doopsie * linterino, linteroni * fix followrequest test not starting processor * fix other api/client tests not starting processor * fix remaining tests where processor not started * bump go-runners version * don't check last-webfingered-at, processor may have updated this * update swagger command * update bun to latest version * fix embed to work the same as before with new bun Signed-off-by: kim <grufwub@gmail.com> Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
		
			
				
	
	
		
			47 lines
		
	
	
	
		
			1.6 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			47 lines
		
	
	
	
		
			1.6 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package json
 | |
| 
 | |
| import (
 | |
| 	"github.com/goccy/go-json/internal/encoder"
 | |
| )
 | |
| 
 | |
| type (
 | |
| 	// FieldQuery you can dynamically filter the fields in the structure by creating a FieldQuery,
 | |
| 	// adding it to context.Context using SetFieldQueryToContext and then passing it to MarshalContext.
 | |
| 	// This is a type-safe operation, so it is faster than filtering using map[string]interface{}.
 | |
| 	FieldQuery       = encoder.FieldQuery
 | |
| 	FieldQueryString = encoder.FieldQueryString
 | |
| )
 | |
| 
 | |
| var (
 | |
| 	// FieldQueryFromContext get current FieldQuery from context.Context.
 | |
| 	FieldQueryFromContext = encoder.FieldQueryFromContext
 | |
| 	// SetFieldQueryToContext set current FieldQuery to context.Context.
 | |
| 	SetFieldQueryToContext = encoder.SetFieldQueryToContext
 | |
| )
 | |
| 
 | |
| // BuildFieldQuery builds FieldQuery by fieldName or sub field query.
 | |
| // First, specify the field name that you want to keep in structure type.
 | |
| // If the field you want to keep is a structure type, by creating a sub field query using BuildSubFieldQuery,
 | |
| // you can select the fields you want to keep in the structure.
 | |
| // This description can be written recursively.
 | |
| func BuildFieldQuery(fields ...FieldQueryString) (*FieldQuery, error) {
 | |
| 	query, err := Marshal(fields)
 | |
| 	if err != nil {
 | |
| 		return nil, err
 | |
| 	}
 | |
| 	return FieldQueryString(query).Build()
 | |
| }
 | |
| 
 | |
| // BuildSubFieldQuery builds sub field query.
 | |
| func BuildSubFieldQuery(name string) *SubFieldQuery {
 | |
| 	return &SubFieldQuery{name: name}
 | |
| }
 | |
| 
 | |
| type SubFieldQuery struct {
 | |
| 	name string
 | |
| }
 | |
| 
 | |
| func (q *SubFieldQuery) Fields(fields ...FieldQueryString) FieldQueryString {
 | |
| 	query, _ := Marshal(map[string][]FieldQueryString{q.name: fields})
 | |
| 	return FieldQueryString(query)
 | |
| }
 |