Run go fmt

parent d951292b
......@@ -236,18 +236,18 @@ func (a *Adapter) AddPolicy(sec string, ptype string, rule []string) error {
// AddPolicies adds policy rules to the storage.
func (a *Adapter) AddPolicies(sec string, ptype string, rules [][]string) error {
var lines []*CasbinRule
for _,rule := range rules{
for _, rule := range rules {
line := savePolicyLine(ptype, rule)
lines = append(lines, line)
}
err := a.db.RunInTransaction(func(tx *pg.Tx) error {
_, err := tx.Model(&lines).
OnConflict("DO NOTHING").
Insert()
OnConflict("DO NOTHING").
Insert()
return err
})
return err
}
......@@ -261,17 +261,17 @@ func (a *Adapter) RemovePolicy(sec string, ptype string, rule []string) error {
// RemovePolicies removes policy rules from the storage.
func (a *Adapter) RemovePolicies(sec string, ptype string, rules [][]string) error {
var lines []*CasbinRule
for _,rule := range rules{
for _, rule := range rules {
line := savePolicyLine(ptype, rule)
lines = append(lines, line)
}
err := a.db.RunInTransaction(func(tx *pg.Tx) error {
_, err := tx.Model(&lines).
Delete()
Delete()
return err
})
return err
}
......
......@@ -120,17 +120,17 @@ func (s *AdapterTestSuite) TestAutoSave() {
// The policy has a new rule: {"alice", "data1", "write"}.
s.assertPolicy(
[][]string{
{"alice", "data1", "read"},
{"bob", "data2", "write"},
{"data2_admin", "data2", "read"},
{"data2_admin", "data2", "write"},
{"alice", "data1", "write"},
{"bob", "data2", "read"},
{"alice", "data2", "write"},
{"alice", "data2", "read"},
{"bob", "data1", "write"},
{"bob", "data1", "read"},
},
{"alice", "data1", "read"},
{"bob", "data2", "write"},
{"data2_admin", "data2", "read"},
{"data2_admin", "data2", "write"},
{"alice", "data1", "write"},
{"bob", "data2", "read"},
{"alice", "data2", "write"},
{"alice", "data2", "read"},
{"bob", "data1", "write"},
{"bob", "data1", "read"},
},
s.e.GetPolicy(),
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment